物料后端和大屏接口

This commit is contained in:
方亮 2025-09-11 17:50:38 +08:00
parent 065496ee69
commit 28acec92ee
7 changed files with 47 additions and 12 deletions

View File

@ -17,6 +17,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
/**
* 下载指定路径下的文件
@ -71,7 +72,7 @@ public class DownloadController {
response.setHeader("Content-type", "text/html;charset=UTF-8");
String data = "文件下载失败";
OutputStream ps = response.getOutputStream();
ps.write(data.getBytes("UTF-8"));
ps.write(data.getBytes(StandardCharsets.UTF_8));
return;
}
outputStream = response.getOutputStream();
@ -95,12 +96,13 @@ public class DownloadController {
String data = "文件下载失败";
try {
OutputStream ps = response.getOutputStream();
ps.write(data.getBytes("UTF-8"));
ps.write(data.getBytes(StandardCharsets.UTF_8));
}catch (IOException e){
e.printStackTrace();
}
} finally {
try {
assert outputStream != null;
outputStream.close();
if (inputStream != null) {
inputStream.close();

View File

@ -26,7 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
* @date 2025-09-10
*/
@RestController
@RequestMapping("/system/material")
@RequestMapping("/material")
public class MaterialController extends BaseController {
@Resource
private ITbPromotionMaterialService service;

View File

@ -96,6 +96,7 @@ public class ProductController extends BaseController {
transactionManager.commit(status);
return ajaxResult;
}catch (Exception e){
transactionManager.rollback(status);
}
return ajaxResult;

View File

@ -50,13 +50,17 @@ public class TbPromotionMaterial extends BaseEntity
private String description;
/** 创建人 */
@Excel(name = "创建人")
private Long createUser;
@Excel(name = "创建人")
private Long createUserName;
/** 修改人 */
@Excel(name = "修改人")
private Long updateUser;
@Excel(name = "创建人")
private Long updateUserName;
/** 产品名称(通过,拼接) */
@Excel(name = "产品名称(通过,拼接)")
private String productName;
@ -75,6 +79,8 @@ public class TbPromotionMaterial extends BaseEntity
/** 文件 */
private List<TbPromotionMaterialFiles> files;
private String delIds;
// 构造函数
public TbPromotionMaterial() {}

View File

@ -90,4 +90,11 @@ public interface TbPromotionMaterialMapper {
* @param bean 宣传物料信息
*/
void updateCover(TbPromotionMaterial bean);
/**
* 删除物料文件
*
* @param bean 宣传物料信息
*/
void deleteTbPromotionMaterialFilesById(TbPromotionMaterialFiles bean);
}

View File

@ -60,6 +60,7 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
for (TbPromotionMaterial bean : tbPromotionMaterials) {
//查询附件
bean.setTypeId(2L);
bean.setImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + bean.getImage());
List<TbPromotionMaterialFiles> files = mapper.getFileMaterialId(bean);
//拼接个访问前缀
for (TbPromotionMaterialFiles o: files) {
@ -130,8 +131,19 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
//将产品与物料关系存到另一张表
List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial);
int n = mapper.insertMaterialProductRelevance(split);
//将物料文件上传
int m = uploadFile(listFiles, "tb_promotion_material_files", tbPromotionMaterial.getId());
if(!listFiles.isEmpty()){
//删除以前的附件
if(tbPromotionMaterial.getDelIds() != null && !tbPromotionMaterial.getDelIds().isEmpty()){
String[] splitId = tbPromotionMaterial.getDelIds().split(",");
for (String id : splitId) {
TbPromotionMaterialFiles bean = new TbPromotionMaterialFiles();
bean.setId(Long.valueOf(id));
mapper.deleteTbPromotionMaterialFilesById(bean);
}
}
//将物料文件上传
int m = uploadFile(listFiles, "tb_promotion_material_files", tbPromotionMaterial.getId());
}
}
return i;
}

View File

@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="image" column="image" />
<result property="version" column="version" />
<result property="description" column="description" />
<result property="createUser" column="create_user" />
<result property="createUserName" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
@ -25,11 +25,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectTbPromotionMaterialList" parameterType="TbPromotionMaterial" resultMap="TbPromotionMaterialResult">
<include refid="selectTbPromotionMaterialVo"/>
select aaa.id, aaa.name, aaa.type_id, aaa.type_name, aaa.image, aaa.version, aaa.description, su.user_name as create_user, aaa.create_time, aaa.update_user, aaa.update_time, aaa.product_name
from tb_promotion_material aaa
left join sys_user su on su.user_id = aaa.create_user
where aaa.del_flag = 0
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
<if test="typeName != null and typeName != ''"> and type_name like concat('%', #{typeName}, '%')</if>
<if test="name != null and name != ''"> and aaa.name like concat('%', #{name}, '%')</if>
<if test="typeId != null "> and aaa.type_id = #{typeId}</if>
<if test="typeName != null and typeName != ''"> and aaa.type_name like concat('%', #{typeName}, '%')</if>
</where>
</select>
@ -122,4 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateCover">
update tb_promotion_material set image = #{image} where id = #{id}
</update>
<delete id="deleteTbPromotionMaterialFilesById">
delete from tb_promotion_material_files where id = #{id}
</delete>
</mapper>