Compare commits

...

4 Commits

Author SHA1 Message Date
方亮 28acec92ee 物料后端和大屏接口 2025-09-11 17:50:38 +08:00
方亮 065496ee69 Merge remote-tracking branch 'origin/main' 2025-09-11 17:45:09 +08:00
方亮 bed1d87881 Merge remote-tracking branch 'origin/main' 2025-09-11 16:54:58 +08:00
方亮 e1b8b00748 物料后端和大屏接口 2025-09-11 13:48:11 +08:00
10 changed files with 76 additions and 33 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

@ -1,21 +1,24 @@
package com.bonus.business.controller;
import com.bonus.business.domain.TbProduct;
import com.bonus.business.domain.TbPromotionMaterial;
import com.bonus.business.service.MaterialScreenService;
import com.bonus.business.service.ProductScreenService;
import com.bonus.common.core.controller.BaseController;
import com.bonus.common.core.domain.AjaxResult;
import com.bonus.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* 产品大屏
* 物料大屏
*/
@RestController
@RequestMapping("/screen/material/")
public class MaterialScreenController {
public class MaterialScreenController extends BaseController {
@Autowired
private MaterialScreenService service;
@ -26,8 +29,15 @@ public class MaterialScreenController {
*/
@PostMapping("/getMaterialList")
public AjaxResult getMaterialList(TbPromotionMaterial o ){
return service.getMaterialList(o) ;
public TableDataInfo getMaterialList(TbPromotionMaterial o){
try {
startPage();
List<TbPromotionMaterial> list = service.getMaterialList(o);
return getDataTable(list);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return getDataTable(new ArrayList<>());
}
}
}

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

@ -4,12 +4,14 @@ import com.bonus.business.domain.TbProduct;
import com.bonus.business.domain.TbPromotionMaterial;
import com.bonus.common.core.domain.AjaxResult;
import java.util.List;
public interface MaterialScreenService {
/**
* 查询展示中心
* @param o
* @return
*/
AjaxResult getMaterialList(TbPromotionMaterial o);
List<TbPromotionMaterial> getMaterialList(TbPromotionMaterial o);
}

View File

@ -32,21 +32,17 @@ public class MaterialScreenServiceImpl implements MaterialScreenService {
@Override
public AjaxResult getMaterialList(TbPromotionMaterial o) {
try{
List<TbPromotionMaterial> list = mapper.getMaterialList(o);
if(StringUtils.isNotEmpty(list)){
list.forEach(vo->{
vo.setImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName()+vo.getImage());
vo.setFilePath(minioConfig.getUrl()+"/"+minioConfig.getBucketName()+vo.getFilePath());
});
}
return AjaxResult.success(list);
}catch (Exception e){
log.error(e.toString());
public List<TbPromotionMaterial> getMaterialList(TbPromotionMaterial o) {
List<TbPromotionMaterial> list = mapper.getMaterialList(o);
if (StringUtils.isNotEmpty(list)) {
list.forEach(vo -> {
vo.setImage(minioConfig.getUrl() + "/" + minioConfig.getBucketName() + vo.getImage());
vo.setFilePath(minioConfig.getUrl() + "/" + minioConfig.getBucketName() + vo.getFilePath());
});
}
return AjaxResult.success(new ArrayList<TbPromotionMaterial>());
return list;
}
}

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>