Commit 1b87b8a42f9d3ad6caead0e54031c696134b6bdf

Authored by 芋道源码
Committed by Gitee
2 parents 7226f9b9 31a28cb4

!822 接入拼团

Merge pull request !822 from 疯狂的世界/develop
Showing 13 changed files with 75 additions and 39 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java
@@ -79,7 +79,7 @@ public class AppProductBrowseHistoryController { @@ -79,7 +79,7 @@ public class AppProductBrowseHistoryController {
79 Map<Long, ProductSpuDO> spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId); 79 Map<Long, ProductSpuDO> spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId);
80 return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class, 80 return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class,
81 vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())) 81 vo -> Optional.ofNullable(spuMap.get(vo.getSpuId()))
82 - .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl())))); 82 + .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice()))));
83 } 83 }
84 84
85 } 85 }
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java
@@ -16,7 +16,7 @@ import java.util.Arrays; @@ -16,7 +16,7 @@ import java.util.Arrays;
16 public enum DecoratePageEnum implements IntArrayValuable { 16 public enum DecoratePageEnum implements IntArrayValuable {
17 17
18 INDEX(1, "首页"), 18 INDEX(1, "首页"),
19 - MY(2, "个人中心"), 19 + MY(2, "我的"),
20 ; 20 ;
21 21
22 private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray(); 22 private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray();
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java
@@ -63,7 +63,7 @@ public class CombinationActivityController { @@ -63,7 +63,7 @@ public class CombinationActivityController {
63 @Operation(summary = "关闭拼团活动") 63 @Operation(summary = "关闭拼团活动")
64 @Parameter(name = "id", description = "编号", required = true) 64 @Parameter(name = "id", description = "编号", required = true)
65 @PreAuthorize("@ss.hasPermission('promotion:combination-activity:close')") 65 @PreAuthorize("@ss.hasPermission('promotion:combination-activity:close')")
66 - public CommonResult<Boolean> closeSeckillActivity(@RequestParam("id") Long id) { 66 + public CommonResult<Boolean> closeCombinationActivity(@RequestParam("id") Long id) {
67 combinationActivityService.closeCombinationActivityById(id); 67 combinationActivityService.closeCombinationActivityById(id);
68 return success(true); 68 return success(true);
69 } 69 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java
@@ -24,6 +24,6 @@ public class DiyPageBaseVO { @@ -24,6 +24,6 @@ public class DiyPageBaseVO {
24 private String remark; 24 private String remark;
25 25
26 @Schema(description = "预览图") 26 @Schema(description = "预览图")
27 - private List<String> previewImageUrls; 27 + private List<String> previewPicUrls;
28 28
29 } 29 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java
@@ -21,6 +21,6 @@ public class DiyTemplateBaseVO { @@ -21,6 +21,6 @@ public class DiyTemplateBaseVO {
21 private String remark; 21 private String remark;
22 22
23 @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]") 23 @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]")
24 - private List<String> previewImageUrls; 24 + private List<String> previewPicUrls;
25 25
26 } 26 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyPageController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.promotion.controller.app.diy;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  5 +import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyPagePropertyRespVO;
  6 +import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO;
  7 +import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService;
  8 +import io.swagger.v3.oas.annotations.Operation;
  9 +import io.swagger.v3.oas.annotations.Parameter;
  10 +import io.swagger.v3.oas.annotations.tags.Tag;
  11 +import jakarta.annotation.Resource;
  12 +import org.springframework.validation.annotation.Validated;
  13 +import org.springframework.web.bind.annotation.GetMapping;
  14 +import org.springframework.web.bind.annotation.RequestMapping;
  15 +import org.springframework.web.bind.annotation.RequestParam;
  16 +import org.springframework.web.bind.annotation.RestController;
  17 +
  18 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  19 +
  20 +@Tag(name = "用户 APP - 装修页面")
  21 +@RestController
  22 +@RequestMapping("/promotion/diy-page")
  23 +@Validated
  24 +public class AppDiyPageController {
  25 + @Resource
  26 + private DiyPageService diyPageService;
  27 +
  28 + @GetMapping("/get")
  29 + @Operation(summary = "获得装修页面")
  30 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  31 + public CommonResult<AppDiyPagePropertyRespVO> getDiyPage(@RequestParam("id") Long id) {
  32 + DiyPageDO diyPage = diyPageService.getDiyPage(id);
  33 + return success(BeanUtils.toBean(diyPage, AppDiyPagePropertyRespVO.class));
  34 + }
  35 +
  36 +}
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePro @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePro
5 import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; 5 import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert;
6 import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; 6 import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO;
7 import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; 7 import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO;
  8 +import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
8 import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; 9 import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService;
9 import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; 10 import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService;
10 import io.swagger.v3.oas.annotations.Operation; 11 import io.swagger.v3.oas.annotations.Operation;
@@ -55,9 +56,8 @@ public class AppDiyTemplateController { @@ -55,9 +56,8 @@ public class AppDiyTemplateController {
55 } 56 }
56 // 查询模板下的页面 57 // 查询模板下的页面
57 List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId()); 58 List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId());
58 - // TODO @疯狂:首页、我的,要不枚举到 DiyPageDO 例如说 NAME_USER,NAME_HOME 类似这种哈;  
59 - String home = findFirst(pages, page -> "首页".equals(page.getName()), DiyPageDO::getProperty);  
60 - String user = findFirst(pages, page -> "我的".equals(page.getName()), DiyPageDO::getProperty); 59 + String home = findFirst(pages, page -> DecoratePageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty);
  60 + String user = findFirst(pages, page -> DecoratePageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty);
61 // 拼接返回 61 // 拼接返回
62 return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user); 62 return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user);
63 } 63 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java
1 package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; 1 package cn.iocoder.yudao.module.promotion.controller.app.diy.vo;
2 2
  3 +import com.fasterxml.jackson.annotation.JsonRawValue;
3 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 5 import lombok.Data;
5 import lombok.ToString; 6 import lombok.ToString;
@@ -16,6 +17,7 @@ public class AppDiyPagePropertyRespVO { @@ -16,6 +17,7 @@ public class AppDiyPagePropertyRespVO {
16 private String name; 17 private String name;
17 18
18 @Schema(description = "页面属性", example = "[]") 19 @Schema(description = "页面属性", example = "[]")
  20 + @JsonRawValue
19 private String property; 21 private String property;
20 22
21 } 23 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java
@@ -44,12 +44,11 @@ public class DiyPageDO extends BaseDO { @@ -44,12 +44,11 @@ public class DiyPageDO extends BaseDO {
44 * 备注 44 * 备注
45 */ 45 */
46 private String remark; 46 private String remark;
47 - // TODO @疯狂:这个字段要不改成 previewPicUrls,和别的模块一样用 pic 作为图片哇?  
48 /** 47 /**
49 * 预览图,多个逗号分隔 48 * 预览图,多个逗号分隔
50 */ 49 */
51 @TableField(typeHandler = StringListTypeHandler.class) 50 @TableField(typeHandler = StringListTypeHandler.class)
52 - private List<String> previewImageUrls; 51 + private List<String> previewPicUrls;
53 /** 52 /**
54 * 页面属性,JSON 格式 53 * 页面属性,JSON 格式
55 */ 54 */
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java
@@ -50,12 +50,12 @@ public class DiyTemplateDO extends BaseDO { @@ -50,12 +50,12 @@ public class DiyTemplateDO extends BaseDO {
50 * 备注 50 * 备注
51 */ 51 */
52 private String remark; 52 private String remark;
53 - // TODO @疯狂:这个字段要不改成 previewPicUrls,和别的模块一样用 pic 作为图片哇? 53 +
54 /** 54 /**
55 * 预览图 55 * 预览图
56 */ 56 */
57 @TableField(typeHandler = StringListTypeHandler.class) 57 @TableField(typeHandler = StringListTypeHandler.class)
58 - private List<String> previewImageUrls; 58 + private List<String> previewPicUrls;
59 /** 59 /**
60 * uni-app 底部导航属性,JSON 格式 60 * uni-app 底部导航属性,JSON 格式
61 */ 61 */
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java
@@ -11,11 +11,11 @@ import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; @@ -11,11 +11,11 @@ import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert;
11 import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; 11 import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert;
12 import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; 12 import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO;
13 import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; 13 import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper;
  14 +import jakarta.annotation.Resource;
14 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
15 import org.springframework.transaction.annotation.Transactional; 16 import org.springframework.transaction.annotation.Transactional;
16 import org.springframework.validation.annotation.Validated; 17 import org.springframework.validation.annotation.Validated;
17 18
18 -import jakarta.annotation.Resource;  
19 import java.time.LocalDateTime; 19 import java.time.LocalDateTime;
20 20
21 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 21 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -36,7 +36,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { @@ -36,7 +36,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
36 @Resource 36 @Resource
37 private DiyPageService diyPageService; 37 private DiyPageService diyPageService;
38 38
39 - // TODO @疯狂:事务; 39 + @Transactional(rollbackFor = Exception.class)
40 @Override 40 @Override
41 public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { 41 public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) {
42 // 校验名称唯一 42 // 校验名称唯一
@@ -121,8 +121,8 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { @@ -121,8 +121,8 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
121 return diyTemplateMapper.selectPage(pageReqVO); 121 return diyTemplateMapper.selectPage(pageReqVO);
122 } 122 }
123 123
  124 + @Transactional(rollbackFor = Exception.class)
124 @Override 125 @Override
125 - // TODO @疯狂:事务;  
126 public void useDiyTemplate(Long id) { 126 public void useDiyTemplate(Long id) {
127 // 校验存在 127 // 校验存在
128 validateDiyTemplateExists(id); 128 validateDiyTemplateExists(id);
@@ -134,10 +134,23 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { @@ -134,10 +134,23 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
134 if (used.getId().equals(id)) { 134 if (used.getId().equals(id)) {
135 return; 135 return;
136 } 136 }
137 - this.updateUsed(used.getId(), false, null); 137 + this.updateTemplateUsed(used.getId(), false, null);
138 } 138 }
139 // 更新为已使用 139 // 更新为已使用
140 - this.updateUsed(id, true, LocalDateTime.now()); 140 + this.updateTemplateUsed(id, true, LocalDateTime.now());
  141 + }
  142 +
  143 + /**
  144 + * 更新模板是否使用
  145 + *
  146 + * @param id 模板编号
  147 + * @param used 是否使用
  148 + * @param usedTime 使用时间
  149 + */
  150 + private void updateTemplateUsed(Long id, Boolean used, LocalDateTime usedTime) {
  151 + DiyTemplateDO updateObj = new DiyTemplateDO().setId(id)
  152 + .setUsed(used).setUsedTime(usedTime);
  153 + diyTemplateMapper.updateById(updateObj);
141 } 154 }
142 155
143 @Override 156 @Override
@@ -155,18 +168,4 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { @@ -155,18 +168,4 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
155 return diyTemplateMapper.selectByUsed(true); 168 return diyTemplateMapper.selectByUsed(true);
156 } 169 }
157 170
158 - // TODO @疯狂:挪到 useDiyTemplate 下面,改名 updateTemplateUsed 会不会好点哈;  
159 - /**  
160 - * 更新模板是否使用  
161 - *  
162 - * @param id 模板编号  
163 - * @param used 是否使用  
164 - * @param usedTime 使用时间  
165 - */  
166 - private void updateUsed(Long id, Boolean used, LocalDateTime usedTime) {  
167 - DiyTemplateDO updateObj = new DiyTemplateDO().setId(id)  
168 - .setUsed(used).setUsedTime(usedTime);  
169 - diyTemplateMapper.updateById(updateObj);  
170 - }  
171 -  
172 } 171 }
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImplTest.java
@@ -109,7 +109,7 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest { @@ -109,7 +109,7 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest {
109 o.setUsed(null); 109 o.setUsed(null);
110 o.setUsedTime(null); 110 o.setUsedTime(null);
111 o.setRemark(null); 111 o.setRemark(null);
112 - o.setPreviewImageUrls(null); 112 + o.setPreviewPicUrls(null);
113 o.setProperty(null); 113 o.setProperty(null);
114 o.setCreateTime(null); 114 o.setCreateTime(null);
115 }); 115 });
@@ -122,8 +122,8 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest { @@ -122,8 +122,8 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest {
122 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); 122 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null)));
123 // 测试 remark 不匹配 123 // 测试 remark 不匹配
124 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null))); 124 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null)));
125 - // 测试 previewImageUrls 不匹配  
126 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewImageUrls(null))); 125 + // 测试 previewPicUrls 不匹配
  126 + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewPicUrls(null)));
127 // 测试 property 不匹配 127 // 测试 property 不匹配
128 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); 128 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null)));
129 // 测试 createTime 不匹配 129 // 测试 createTime 不匹配
@@ -152,7 +152,7 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest { @@ -152,7 +152,7 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest {
152 o.setUsed(null); 152 o.setUsed(null);
153 o.setUsedTime(null); 153 o.setUsedTime(null);
154 o.setRemark(null); 154 o.setRemark(null);
155 - o.setPreviewImageUrls(null); 155 + o.setPreviewPicUrls(null);
156 o.setProperty(null); 156 o.setProperty(null);
157 o.setCreateTime(null); 157 o.setCreateTime(null);
158 }); 158 });
@@ -165,8 +165,8 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest { @@ -165,8 +165,8 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest {
165 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); 165 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null)));
166 // 测试 remark 不匹配 166 // 测试 remark 不匹配
167 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null))); 167 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null)));
168 - // 测试 previewImageUrls 不匹配  
169 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewImageUrls(null))); 168 + // 测试 previewPicUrls 不匹配
  169 + diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewPicUrls(null)));
170 // 测试 property 不匹配 170 // 测试 property 不匹配
171 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); 171 diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null)));
172 // 测试 createTime 不匹配 172 // 测试 createTime 不匹配
yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql
@@ -228,7 +228,7 @@ CREATE TABLE IF NOT EXISTS &quot;promotion_diy_template&quot; @@ -228,7 +228,7 @@ CREATE TABLE IF NOT EXISTS &quot;promotion_diy_template&quot;
228 "used" bit NOT NULL, 228 "used" bit NOT NULL,
229 "used_time" varchar, 229 "used_time" varchar,
230 "remark" varchar, 230 "remark" varchar,
231 - "preview_image_urls" varchar, 231 + "preview_pic_urls" varchar,
232 "property" varchar NOT NULL, 232 "property" varchar NOT NULL,
233 "creator" varchar DEFAULT '', 233 "creator" varchar DEFAULT '',
234 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 234 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -244,7 +244,7 @@ CREATE TABLE IF NOT EXISTS &quot;promotion_diy_page&quot; @@ -244,7 +244,7 @@ CREATE TABLE IF NOT EXISTS &quot;promotion_diy_page&quot;
244 "template_id" bigint NOT NULL, 244 "template_id" bigint NOT NULL,
245 "name" varchar NOT NULL, 245 "name" varchar NOT NULL,
246 "remark" varchar, 246 "remark" varchar,
247 - "preview_image_urls" varchar, 247 + "preview_pic_urls" varchar,
248 "property" varchar, 248 "property" varchar,
249 "creator" varchar DEFAULT '', 249 "creator" varchar DEFAULT '',
250 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 250 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,