framework/src/main/java/cn/lili/modules/lmk/domain/entity/GoodsCustomizeTemplate.java
@@ -22,7 +22,10 @@ private String templateName; @TableField("status") /** 启用状态 */ /** * 启用状态 * @see cn.lili.modules.lmk.enums.general.EnableStatusEnums */ private String status; framework/src/main/java/cn/lili/modules/lmk/domain/entity/TemplateConstomizeTitle.java
@@ -3,7 +3,9 @@ import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; /** * 模板标题 @@ -12,6 +14,8 @@ * @since 2025-10-09 */ @Data @NoArgsConstructor @AllArgsConstructor @TableName("lmk_template_constomize_title") public class TemplateConstomizeTitle extends BaseEntity { @@ -27,7 +31,14 @@ @TableField("content_type") /** 标题类型 */ /** * @see cn.lili.modules.lmk.enums.general.TemplateContentTypeEnum */ private String contentType; public TemplateConstomizeTitle(String templateTitle,String contentType) { this.templateTitle = templateTitle; this.contentType = contentType; } } framework/src/main/java/cn/lili/modules/lmk/domain/entity/TemplateImgs.java
@@ -3,7 +3,9 @@ import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; /** * 模板图片 @@ -12,6 +14,8 @@ * @since 2025-10-09 */ @Data @NoArgsConstructor @AllArgsConstructor @TableName("lmk_template_imgs") public class TemplateImgs extends BaseEntity { @@ -25,5 +29,8 @@ /** 图片地址 */ private String imgUrl; public TemplateImgs(String imgUrl) { this.imgUrl = imgUrl; // 只赋值imgUrl,其他字段(如templateId)可后续通过业务逻辑补充 } } framework/src/main/java/cn/lili/modules/lmk/domain/form/GoodsCustomizeTemplateForm.java
@@ -4,6 +4,8 @@ import cn.lili.group.Add; import cn.lili.base.AbsForm; import cn.lili.modules.lmk.domain.entity.GoodsCustomizeTemplate; import cn.lili.modules.lmk.domain.entity.TemplateConstomizeTitle; import cn.lili.modules.lmk.domain.entity.TemplateImgs; import org.springframework.beans.BeanUtils; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @@ -12,6 +14,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; import java.util.List; /** * 定制商品模板表单 @@ -31,6 +34,10 @@ @ApiModelProperty("启用状态") private String status; private List<TemplateConstomizeTitle> titles; private List<TemplateImgs> listImages; public static GoodsCustomizeTemplate getEntityByForm(@NonNull GoodsCustomizeTemplateForm form, GoodsCustomizeTemplate entity) { if(entity == null) { entity = new GoodsCustomizeTemplate(); framework/src/main/java/cn/lili/modules/lmk/domain/query/GoodsCustomizeTemplateQuery.java
@@ -18,5 +18,9 @@ @Data @ApiModel(value = "GoodsCustomizeTemplate查询参数", description = "定制商品模板查询参数") public class GoodsCustomizeTemplateQuery extends AbsQuery { private String templateName; private String status; } framework/src/main/java/cn/lili/modules/lmk/domain/vo/GoodsCustomizeTemplateVO.java
@@ -3,6 +3,9 @@ import cn.lili.base.AbsVo; import cn.lili.modules.lmk.domain.entity.GoodsCustomizeTemplate; import java.util.List; import cn.lili.modules.lmk.domain.entity.TemplateConstomizeTitle; import cn.lili.modules.lmk.domain.entity.TemplateImgs; import org.springframework.lang.NonNull; import org.springframework.beans.BeanUtils; import io.swagger.annotations.ApiModel; @@ -28,6 +31,9 @@ @ApiModelProperty("启用状态") private String status; private List<TemplateImgs> listImages; private List<TemplateConstomizeTitle> titles; public static GoodsCustomizeTemplateVO getVoByEntity(@NonNull GoodsCustomizeTemplate entity, GoodsCustomizeTemplateVO vo) { if(vo == null) { vo = new GoodsCustomizeTemplateVO(); framework/src/main/java/cn/lili/modules/lmk/enums/general/TemplateContentTypeEnum.java
New file @@ -0,0 +1,22 @@ package cn.lili.modules.lmk.enums.general; import lombok.AllArgsConstructor; import lombok.Getter; /** * lmk-shop-java * * @author : zxl * @date : 2025-10-10 15:37 **/ @Getter @AllArgsConstructor public enum TemplateContentTypeEnum { /** * 类型 */ TEXT("文本"), IMAGE("图片"); private final String description; } framework/src/main/java/cn/lili/modules/lmk/service/GoodsCustomizeTemplateService.java
@@ -62,4 +62,6 @@ * @return */ Result all(); Result changeStatus(String id); } framework/src/main/java/cn/lili/modules/lmk/service/impl/GoodsCustomizeTemplateServiceImpl.java
@@ -1,10 +1,18 @@ package cn.lili.modules.lmk.service.impl; import cn.lili.modules.lmk.domain.entity.TemplateConstomizeTitle; import cn.lili.modules.lmk.domain.entity.TemplateImgs; import cn.lili.modules.lmk.enums.general.EnableStatusEnums; import cn.lili.modules.lmk.service.TemplateConstomizeTitleService; import cn.lili.modules.lmk.service.TemplateImgsService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import cn.lili.modules.lmk.domain.entity.GoodsCustomizeTemplate; import cn.lili.modules.lmk.mapper.GoodsCustomizeTemplateMapper; import cn.lili.modules.lmk.service.GoodsCustomizeTemplateService; import cn.lili.base.Result; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import cn.lili.modules.lmk.domain.form.GoodsCustomizeTemplateForm; import cn.lili.modules.lmk.domain.vo.GoodsCustomizeTemplateVO; @@ -13,6 +21,7 @@ import lombok.RequiredArgsConstructor; import cn.lili.utils.PageUtil; import org.springframework.beans.BeanUtils; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import java.util.List; @@ -30,15 +39,32 @@ private final GoodsCustomizeTemplateMapper goodsCustomizeTemplateMapper; private final TemplateImgsService templateImgsService; private final TemplateConstomizeTitleService templateConstomizeTitleService; /** * 添加 * @param form * @return */ @Override @Transactional(rollbackFor = Exception.class) public Result add(GoodsCustomizeTemplateForm form) { GoodsCustomizeTemplate entity = GoodsCustomizeTemplateForm.getEntityByForm(form, null); entity.setStatus(EnableStatusEnums.ENABLE.name()); baseMapper.insert(entity); String templateId = entity.getId(); List<TemplateImgs> listImages = form.getListImages(); for (TemplateImgs templateImgs : listImages) { templateImgs.setTemplateId(templateId); } List<TemplateConstomizeTitle> titles = form.getTitles(); for (TemplateConstomizeTitle title : titles) { title.setTemplateId(templateId); } templateImgsService.saveBatch(listImages); templateConstomizeTitleService.saveBatch(titles); return Result.ok("添加成功"); } @@ -48,12 +74,47 @@ * @return */ @Override @Transactional(rollbackFor = Exception.class) public Result update(GoodsCustomizeTemplateForm form) { GoodsCustomizeTemplate entity = baseMapper.selectById(form.getId()); // 为空抛IllegalArgumentException,做全局异常处理 Assert.notNull(entity, "记录不存在"); BeanUtils.copyProperties(form, entity); //先删除之前的模板信息然后添加新信息 List<TemplateImgs> templateImgsList = new LambdaQueryChainWrapper<>(templateImgsService.getBaseMapper()) .eq(TemplateImgs::getTemplateId, entity.getId()) .eq(TemplateImgs::getDeleteFlag, Boolean.FALSE) .list(); List<String> imgIds = templateImgsList.stream() .map(TemplateImgs::getId) .collect(Collectors.toList()); List<TemplateConstomizeTitle> templateConstomizeTitleList = new LambdaQueryChainWrapper<>(templateConstomizeTitleService.getBaseMapper()) .eq(TemplateConstomizeTitle::getTemplateId, entity.getId()) .eq(TemplateConstomizeTitle::getDeleteFlag, Boolean.FALSE) .list(); List<String> titleIds = templateConstomizeTitleList.stream() .map(TemplateConstomizeTitle::getId) .collect(Collectors.toList()); templateImgsService.removeBatchByIds(imgIds); templateConstomizeTitleService.removeBatchByIds(titleIds); List<TemplateImgs> listImages = form.getListImages(); for (TemplateImgs templateImgs : listImages) { templateImgs.setTemplateId(entity.getId()); } List<TemplateConstomizeTitle> titles = form.getTitles(); for (TemplateConstomizeTitle title : titles) { title.setTemplateId(entity.getId()); } templateImgsService.saveBatch(listImages); templateConstomizeTitleService.saveBatch(titles); baseMapper.updateById(entity); return Result.ok("修改成功"); } @@ -75,8 +136,32 @@ * @return */ @Override @Transactional(rollbackFor = Exception.class) public Result removeById(String id) { List<TemplateImgs> templateImgsList = new LambdaQueryChainWrapper<>(templateImgsService.getBaseMapper()) .eq(TemplateImgs::getTemplateId, id) .eq(TemplateImgs::getDeleteFlag, Boolean.FALSE) .list(); List<String> imgIds = templateImgsList.stream() .map(TemplateImgs::getId) .collect(Collectors.toList()); List<TemplateConstomizeTitle> templateConstomizeTitleList = new LambdaQueryChainWrapper<>(templateConstomizeTitleService.getBaseMapper()) .eq(TemplateConstomizeTitle::getTemplateId, id) .eq(TemplateConstomizeTitle::getDeleteFlag, Boolean.FALSE) .list(); List<String> titleIds = templateConstomizeTitleList.stream() .map(TemplateConstomizeTitle::getId) .collect(Collectors.toList()); templateImgsService.removeBatchByIds(imgIds); templateConstomizeTitleService.removeBatchByIds(titleIds); baseMapper.deleteById(id); return Result.ok("删除成功"); } @@ -101,6 +186,19 @@ public Result detail(String id) { GoodsCustomizeTemplateVO vo = baseMapper.getById(id); Assert.notNull(vo, "记录不存在"); //查询相关模板信息 List<TemplateImgs> templateImgsList = new LambdaQueryChainWrapper<>(templateImgsService.getBaseMapper()) .eq(TemplateImgs::getTemplateId, id) .eq(TemplateImgs::getDeleteFlag, Boolean.FALSE) .list(); List<TemplateConstomizeTitle> templateConstomizeTitleList = new LambdaQueryChainWrapper<>(templateConstomizeTitleService.getBaseMapper()) .eq(TemplateConstomizeTitle::getTemplateId, id) .eq(TemplateConstomizeTitle::getDeleteFlag, Boolean.FALSE) .list(); vo.setListImages(templateImgsList); vo.setTitles(templateConstomizeTitleList); return Result.ok().data(vo); } @@ -116,4 +214,16 @@ .collect(Collectors.toList()); return Result.ok().data(vos); } @Override public Result changeStatus(String id) { GoodsCustomizeTemplate goodsCustomizeTemplate = baseMapper.selectById(id); if (EnableStatusEnums.ENABLE.name().equals(goodsCustomizeTemplate.getStatus())){ goodsCustomizeTemplate.setStatus(EnableStatusEnums.DISABLE.name()); }else{ goodsCustomizeTemplate.setStatus(EnableStatusEnums.ENABLE.name()); } baseMapper.updateById(goodsCustomizeTemplate); return Result.ok(); } } framework/src/main/resources/mapper/lmk/GoodsCustomizeTemplateMapper.xml
@@ -9,12 +9,6 @@ <result column="status" property="status" /> </resultMap> <select id="getById" resultMap="BaseResultMap"> SELECT LGCT.template_name, @@ -36,6 +30,12 @@ lmk_goods_customize_template LGCT WHERE LGCT.delete_flag = 0 <if test="query.templateName != null and query.templateName !=''"> AND LGCT.template_name LIKE CONCAT('%',#{query.templateName},'%') </if> <if test="query.status != null and query.status !=''"> AND LGCT.status = #{query.status} </if> </select> </mapper> framework/src/main/resources/mapper/lmk/VideoMapper.xml
@@ -336,6 +336,7 @@ AND LV.video_type = #{query.videoType} AND LM.id IS NOT NULL ORDER BY recommend DESC, create_time DESC </select> <select id="recommendVideoByVideoId" resultMap="WxResultMap"> seller-api/src/main/java/cn/lili/controller/template/GoodsCustomizeTemplateController.java
New file @@ -0,0 +1,55 @@ package cn.lili.controller.template; import cn.lili.base.Result; import cn.lili.modules.lmk.domain.entity.GoodsCustomizeTemplate; import cn.lili.modules.lmk.domain.form.GoodsCustomizeTemplateForm; import cn.lili.modules.lmk.domain.query.GoodsCustomizeTemplateQuery; import cn.lili.modules.lmk.service.GoodsCustomizeTemplateService; import lombok.RequiredArgsConstructor; import org.springframework.security.core.parameters.P; import org.springframework.web.bind.annotation.*; /** * lmk-shop-java * 定制商品模板 * @author : zxl * @date : 2025-10-10 11:46 **/ @RestController @RequiredArgsConstructor @RequestMapping("/store/lmk/goodsCustomizeTemplate") public class GoodsCustomizeTemplateController { private final GoodsCustomizeTemplateService goodsCustomizeTemplateService; @GetMapping() public Result getPage(GoodsCustomizeTemplateQuery query){ return goodsCustomizeTemplateService.page(query); } @GetMapping("/{id}") public Result getById(@PathVariable String id){ return goodsCustomizeTemplateService.detail(id); } @PostMapping() public Result add(@RequestBody GoodsCustomizeTemplateForm form){ return goodsCustomizeTemplateService.add(form); } @PutMapping() public Result edit(@RequestBody GoodsCustomizeTemplateForm form){ return goodsCustomizeTemplateService.update(form); } @PutMapping("/changeStatus/{id}") public Result changeStatus(@PathVariable String id){ return goodsCustomizeTemplateService.changeStatus(id); } @DeleteMapping("/{id}") public Result delete(@PathVariable String id){ return goodsCustomizeTemplateService.removeById(id); } }