物料后端和大屏接口
This commit is contained in:
parent
065496ee69
commit
28acec92ee
|
|
@ -17,6 +17,7 @@ import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URLEncoder;
|
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");
|
response.setHeader("Content-type", "text/html;charset=UTF-8");
|
||||||
String data = "文件下载失败";
|
String data = "文件下载失败";
|
||||||
OutputStream ps = response.getOutputStream();
|
OutputStream ps = response.getOutputStream();
|
||||||
ps.write(data.getBytes("UTF-8"));
|
ps.write(data.getBytes(StandardCharsets.UTF_8));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
outputStream = response.getOutputStream();
|
outputStream = response.getOutputStream();
|
||||||
|
|
@ -95,12 +96,13 @@ public class DownloadController {
|
||||||
String data = "文件下载失败";
|
String data = "文件下载失败";
|
||||||
try {
|
try {
|
||||||
OutputStream ps = response.getOutputStream();
|
OutputStream ps = response.getOutputStream();
|
||||||
ps.write(data.getBytes("UTF-8"));
|
ps.write(data.getBytes(StandardCharsets.UTF_8));
|
||||||
}catch (IOException e){
|
}catch (IOException e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
assert outputStream != null;
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
* @date 2025-09-10
|
* @date 2025-09-10
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/material")
|
@RequestMapping("/material")
|
||||||
public class MaterialController extends BaseController {
|
public class MaterialController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private ITbPromotionMaterialService service;
|
private ITbPromotionMaterialService service;
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ public class ProductController extends BaseController {
|
||||||
transactionManager.commit(status);
|
transactionManager.commit(status);
|
||||||
return ajaxResult;
|
return ajaxResult;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
|
||||||
transactionManager.rollback(status);
|
transactionManager.rollback(status);
|
||||||
}
|
}
|
||||||
return ajaxResult;
|
return ajaxResult;
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,17 @@ public class TbPromotionMaterial extends BaseEntity
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/** 创建人 */
|
/** 创建人 */
|
||||||
@Excel(name = "创建人")
|
|
||||||
private Long createUser;
|
private Long createUser;
|
||||||
|
|
||||||
|
@Excel(name = "创建人")
|
||||||
|
private Long createUserName;
|
||||||
|
|
||||||
/** 修改人 */
|
/** 修改人 */
|
||||||
@Excel(name = "修改人")
|
|
||||||
private Long updateUser;
|
private Long updateUser;
|
||||||
|
|
||||||
|
@Excel(name = "创建人")
|
||||||
|
private Long updateUserName;
|
||||||
|
|
||||||
/** 产品名称(通过,拼接) */
|
/** 产品名称(通过,拼接) */
|
||||||
@Excel(name = "产品名称(通过,拼接)")
|
@Excel(name = "产品名称(通过,拼接)")
|
||||||
private String productName;
|
private String productName;
|
||||||
|
|
@ -75,6 +79,8 @@ public class TbPromotionMaterial extends BaseEntity
|
||||||
/** 文件 */
|
/** 文件 */
|
||||||
private List<TbPromotionMaterialFiles> files;
|
private List<TbPromotionMaterialFiles> files;
|
||||||
|
|
||||||
|
private String delIds;
|
||||||
|
|
||||||
|
|
||||||
// 构造函数
|
// 构造函数
|
||||||
public TbPromotionMaterial() {}
|
public TbPromotionMaterial() {}
|
||||||
|
|
|
||||||
|
|
@ -90,4 +90,11 @@ public interface TbPromotionMaterialMapper {
|
||||||
* @param bean 宣传物料信息
|
* @param bean 宣传物料信息
|
||||||
*/
|
*/
|
||||||
void updateCover(TbPromotionMaterial bean);
|
void updateCover(TbPromotionMaterial bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除物料文件
|
||||||
|
*
|
||||||
|
* @param bean 宣传物料信息
|
||||||
|
*/
|
||||||
|
void deleteTbPromotionMaterialFilesById(TbPromotionMaterialFiles bean);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
|
||||||
for (TbPromotionMaterial bean : tbPromotionMaterials) {
|
for (TbPromotionMaterial bean : tbPromotionMaterials) {
|
||||||
//查询附件
|
//查询附件
|
||||||
bean.setTypeId(2L);
|
bean.setTypeId(2L);
|
||||||
|
bean.setImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + bean.getImage());
|
||||||
List<TbPromotionMaterialFiles> files = mapper.getFileMaterialId(bean);
|
List<TbPromotionMaterialFiles> files = mapper.getFileMaterialId(bean);
|
||||||
//拼接个访问前缀
|
//拼接个访问前缀
|
||||||
for (TbPromotionMaterialFiles o: files) {
|
for (TbPromotionMaterialFiles o: files) {
|
||||||
|
|
@ -130,8 +131,19 @@ public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialServi
|
||||||
//将产品与物料关系存到另一张表
|
//将产品与物料关系存到另一张表
|
||||||
List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial);
|
List<TbPromotionMaterial> split = tbPromotionMaterial.split(tbPromotionMaterial);
|
||||||
int n = mapper.insertMaterialProductRelevance(split);
|
int n = mapper.insertMaterialProductRelevance(split);
|
||||||
//将物料文件上传
|
if(!listFiles.isEmpty()){
|
||||||
int m = uploadFile(listFiles, "tb_promotion_material_files", tbPromotionMaterial.getId());
|
//删除以前的附件
|
||||||
|
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;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="image" column="image" />
|
<result property="image" column="image" />
|
||||||
<result property="version" column="version" />
|
<result property="version" column="version" />
|
||||||
<result property="description" column="description" />
|
<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="createTime" column="create_time" />
|
||||||
<result property="updateUser" column="update_user" />
|
<result property="updateUser" column="update_user" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
|
|
@ -25,11 +25,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTbPromotionMaterialList" parameterType="TbPromotionMaterial" resultMap="TbPromotionMaterialResult">
|
<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>
|
<where>
|
||||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
<if test="name != null and name != ''"> and aaa.name like concat('%', #{name}, '%')</if>
|
||||||
<if test="typeId != null "> and type_id = #{typeId}</if>
|
<if test="typeId != null "> and aaa.type_id = #{typeId}</if>
|
||||||
<if test="typeName != null and typeName != ''"> and type_name like concat('%', #{typeName}, '%')</if>
|
<if test="typeName != null and typeName != ''"> and aaa.type_name like concat('%', #{typeName}, '%')</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
@ -122,4 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<update id="updateCover">
|
<update id="updateCover">
|
||||||
update tb_promotion_material set image = #{image} where id = #{id}
|
update tb_promotion_material set image = #{image} where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteTbPromotionMaterialFilesById">
|
||||||
|
delete from tb_promotion_material_files where id = #{id}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue