物料后端和大屏接口

This commit is contained in:
方亮 2025-09-11 18:31:04 +08:00
parent 25da6b3fe0
commit 343246c47f
7 changed files with 21 additions and 19 deletions

View File

@ -2,6 +2,7 @@ package com.bonus.business.controller;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -94,19 +95,18 @@ public class MaterialController extends BaseController {
// @PreAuthorize("@ss.hasPermi('system:material:edit')") // @PreAuthorize("@ss.hasPermi('system:material:edit')")
@Log(title = "修改宣传物料信息", businessType = BusinessType.UPDATE) @Log(title = "修改宣传物料信息", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @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 { try {
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class); 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("文件信息与文件数量不匹配或文件缺失"); 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]); listFile.get(i).setFile(files[i]);
} }
TbPromotionMaterial tbPromotionMaterial = FastJsonHelper.jsonStrToBean(params, TbPromotionMaterial.class); TbPromotionMaterial tbPromotionMaterial = FastJsonHelper.jsonStrToBean(params, TbPromotionMaterial.class);
return toAjax(service.updateTbPromotionMaterial(tbPromotionMaterial,listFile)); return toAjax(service.updateTbPromotionMaterial(tbPromotionMaterial,listFile));
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);

View File

@ -11,11 +11,7 @@ public class MapBeanPo {
private String name; private String name;
private Integer subComId; private Integer typeId;
private Integer proId;
private Integer subId;
public MapBeanPo(Integer id, String name) { public MapBeanPo(Integer id, String name) {
this.id = id; this.id = id;

View File

@ -81,7 +81,9 @@ public class TbPromotionMaterial extends BaseEntity
private String delIds; private String delIds;
private String type;
private List<String> productIds;
// 构造函数 // 构造函数
public TbPromotionMaterial() {} public TbPromotionMaterial() {}

View File

@ -97,4 +97,6 @@ public interface TbPromotionMaterialMapper {
* @param bean 宣传物料信息 * @param bean 宣传物料信息
*/ */
void deleteTbPromotionMaterialFilesById(TbPromotionMaterialFiles bean); void deleteTbPromotionMaterialFilesById(TbPromotionMaterialFiles bean);
List<String> getProductByMaterialId(TbPromotionMaterial bean);
} }

View File

@ -59,7 +59,7 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
List<TbPromotionMaterial> tbPromotionMaterials = mapper.selectTbPromotionMaterialList(tbPromotionMaterial); List<TbPromotionMaterial> tbPromotionMaterials = mapper.selectTbPromotionMaterialList(tbPromotionMaterial);
for (TbPromotionMaterial bean : tbPromotionMaterials) { for (TbPromotionMaterial bean : tbPromotionMaterials) {
//查询附件 //查询附件
bean.setTypeId(2L); bean.setType("2");
bean.setImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + bean.getImage()); bean.setImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + bean.getImage());
List<TbPromotionMaterialFiles> files = mapper.getFileMaterialId(bean); List<TbPromotionMaterialFiles> files = mapper.getFileMaterialId(bean);
//拼接个访问前缀 //拼接个访问前缀
@ -88,6 +88,8 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
o.setFilePath(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + o.getFilePath()); o.setFilePath(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + o.getFilePath());
} }
bean.setFiles(files); bean.setFiles(files);
List<String> products =mapper.getProductByMaterialId(bean);
bean.setProductIds(products);
return bean; return bean;
} }
@ -104,8 +106,6 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
tbPromotionMaterial.setCreateTime(DateUtils.getNowDate()); tbPromotionMaterial.setCreateTime(DateUtils.getNowDate());
int i = mapper.insertTbPromotionMaterial(tbPromotionMaterial); int i = mapper.insertTbPromotionMaterial(tbPromotionMaterial);
if (i > 0) { if (i > 0) {
//删除以前的关联关系
int x = mapper.deleteMaterialProductRelevance(tbPromotionMaterial.getId());
//将产品与物料关系存到另一张表 //将产品与物料关系存到另一张表
List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial); List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial);
int n = mapper.insertMaterialProductRelevance(split); int n = mapper.insertMaterialProductRelevance(split);
@ -128,6 +128,8 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
tbPromotionMaterial.setUpdateTime(DateUtils.getNowDate()); tbPromotionMaterial.setUpdateTime(DateUtils.getNowDate());
int i = mapper.updateTbPromotionMaterial(tbPromotionMaterial); int i = mapper.updateTbPromotionMaterial(tbPromotionMaterial);
if (i > 0) { if (i > 0) {
//删除以前的关联关系
int x = mapper.deleteMaterialProductRelevance(tbPromotionMaterial.getId());
//将产品与物料关系存到另一张表 //将产品与物料关系存到另一张表
List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial); List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial);
int n = mapper.insertMaterialProductRelevance(split); int n = mapper.insertMaterialProductRelevance(split);

View File

@ -8,8 +8,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id,name from tb_product select id,name from tb_product
<where> <where>
del_flag = 0 del_flag = 0
<if test="name != null and name != ''"> <if test="typeId != null and typeId != ''">
and name like '%${name}%' and type_id = #{typeId}
</if> </if>
</where> </where>
</select> </select>

View File

@ -81,14 +81,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="name != null">name = #{name},</if> <if test="name != null">name = #{name},</if>
<if test="typeId != null">type_id = #{typeId},</if> <if test="typeId != null">type_id = #{typeId},</if>
<if test="typeName != null">type_name = #{typeName},</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="version != null">version = #{version},</if>
<if test="description != null">description = #{description},</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="updateUser != null">update_user = #{updateUser},</if>
<if test="updateTime != null">update_time = #{updateTime},</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> <if test="productName != null">product_name = #{productName},</if>
</trim> </trim>
where id = #{id} 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 id="getFileMaterialId" resultType="com.bonus.business.domain.TbPromotionMaterialFiles">
select * from tb_promotion_material_files where material_id = #{id} 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> </select>
<insert id="insertMaterialProductRelevance"> <insert id="insertMaterialProductRelevance">
@ -129,4 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteTbPromotionMaterialFilesById"> <delete id="deleteTbPromotionMaterialFilesById">
delete from tb_promotion_material_files where id = #{id} delete from tb_promotion_material_files where id = #{id}
</delete> </delete>
<select id="getProductByMaterialId" resultType="java.lang.String">
select product_id from tb_promotion_material_product where material_id = #{id}
</select>
</mapper> </mapper>