物料后端和大屏接口
This commit is contained in:
parent
25da6b3fe0
commit
343246c47f
|
|
@ -2,6 +2,7 @@ package com.bonus.business.controller;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
|
@ -94,19 +95,18 @@ public class MaterialController extends BaseController {
|
|||
// @PreAuthorize("@ss.hasPermi('system:material:edit')")
|
||||
@Log(title = "修改宣传物料信息", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestParam(value = "files") MultipartFile[] files,@RequestParam(value = "fileMsg") String fileMsg, @RequestParam(value = "params")String params) {
|
||||
public AjaxResult edit(@RequestParam(value = "files",required = false) MultipartFile[] files,@RequestParam(value = "fileMsg") String fileMsg, @RequestParam(value = "params")String params) {
|
||||
try {
|
||||
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||
// 验证对应关系
|
||||
if (listFile.size() != files.length || files.length != 2) {
|
||||
if (listFile != null && listFile.size() != files.length) {
|
||||
return error("文件信息与文件数量不匹配或文件缺失");
|
||||
}
|
||||
//先将数据对应关系处理
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
for (int i = 0; i < Objects.requireNonNull(listFile).size(); i++) {
|
||||
listFile.get(i).setFile(files[i]);
|
||||
}
|
||||
TbPromotionMaterial tbPromotionMaterial = FastJsonHelper.jsonStrToBean(params, TbPromotionMaterial.class);
|
||||
|
||||
return toAjax(service.updateTbPromotionMaterial(tbPromotionMaterial,listFile));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@ public class MapBeanPo {
|
|||
|
||||
private String name;
|
||||
|
||||
private Integer subComId;
|
||||
|
||||
private Integer proId;
|
||||
|
||||
private Integer subId;
|
||||
private Integer typeId;
|
||||
|
||||
public MapBeanPo(Integer id, String name) {
|
||||
this.id = id;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,9 @@ public class TbPromotionMaterial extends BaseEntity
|
|||
|
||||
private String delIds;
|
||||
|
||||
private String type;
|
||||
|
||||
private List<String> productIds;
|
||||
// 构造函数
|
||||
public TbPromotionMaterial() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,4 +97,6 @@ public interface TbPromotionMaterialMapper {
|
|||
* @param bean 宣传物料信息
|
||||
*/
|
||||
void deleteTbPromotionMaterialFilesById(TbPromotionMaterialFiles bean);
|
||||
|
||||
List<String> getProductByMaterialId(TbPromotionMaterial bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
|
|||
List<TbPromotionMaterial> tbPromotionMaterials = mapper.selectTbPromotionMaterialList(tbPromotionMaterial);
|
||||
for (TbPromotionMaterial bean : tbPromotionMaterials) {
|
||||
//查询附件
|
||||
bean.setTypeId(2L);
|
||||
bean.setType("2");
|
||||
bean.setImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + bean.getImage());
|
||||
List<TbPromotionMaterialFiles> files = mapper.getFileMaterialId(bean);
|
||||
//拼接个访问前缀
|
||||
|
|
@ -88,6 +88,8 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
|
|||
o.setFilePath(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + o.getFilePath());
|
||||
}
|
||||
bean.setFiles(files);
|
||||
List<String> products =mapper.getProductByMaterialId(bean);
|
||||
bean.setProductIds(products);
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
|
@ -104,8 +106,6 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
|
|||
tbPromotionMaterial.setCreateTime(DateUtils.getNowDate());
|
||||
int i = mapper.insertTbPromotionMaterial(tbPromotionMaterial);
|
||||
if (i > 0) {
|
||||
//删除以前的关联关系
|
||||
int x = mapper.deleteMaterialProductRelevance(tbPromotionMaterial.getId());
|
||||
//将产品与物料关系存到另一张表
|
||||
List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial);
|
||||
int n = mapper.insertMaterialProductRelevance(split);
|
||||
|
|
@ -128,6 +128,8 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
|
|||
tbPromotionMaterial.setUpdateTime(DateUtils.getNowDate());
|
||||
int i = mapper.updateTbPromotionMaterial(tbPromotionMaterial);
|
||||
if (i > 0) {
|
||||
//删除以前的关联关系
|
||||
int x = mapper.deleteMaterialProductRelevance(tbPromotionMaterial.getId());
|
||||
//将产品与物料关系存到另一张表
|
||||
List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial);
|
||||
int n = mapper.insertMaterialProductRelevance(split);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select id,name from tb_product
|
||||
<where>
|
||||
del_flag = 0
|
||||
<if test="name != null and name != ''">
|
||||
and name like '%${name}%'
|
||||
<if test="typeId != null and typeId != ''">
|
||||
and type_id = #{typeId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -81,14 +81,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="name != null">name = #{name},</if>
|
||||
<if test="typeId != null">type_id = #{typeId},</if>
|
||||
<if test="typeName != null">type_name = #{typeName},</if>
|
||||
<if test="image != null">image = #{image},</if>
|
||||
<if test="version != null">version = #{version},</if>
|
||||
<if test="description != null">description = #{description},</if>
|
||||
<if test="createUser != null">create_user = #{createUser},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateUser != null">update_user = #{updateUser},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="productName != null">product_name = #{productName},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
|
|
@ -106,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="getFileMaterialId" resultType="com.bonus.business.domain.TbPromotionMaterialFiles">
|
||||
select * from tb_promotion_material_files where material_id = #{id}
|
||||
<if test="typeId != null">and type_id = #{typeId}</if>
|
||||
<if test="type != null">and type_id = #{type}</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertMaterialProductRelevance">
|
||||
|
|
@ -129,4 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<delete id="deleteTbPromotionMaterialFilesById">
|
||||
delete from tb_promotion_material_files where id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getProductByMaterialId" resultType="java.lang.String">
|
||||
select product_id from tb_promotion_material_product where material_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue