Commit 1b87b8a42f9d3ad6caead0e54031c696134b6bdf
Committed by
Gitee
!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 | 79 | Map<Long, ProductSpuDO> spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId); |
| 80 | 80 | return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class, |
| 81 | 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 | 16 | public enum DecoratePageEnum implements IntArrayValuable { |
| 17 | 17 | |
| 18 | 18 | INDEX(1, "首页"), |
| 19 | - MY(2, "个人中心"), | |
| 19 | + MY(2, "我的"), | |
| 20 | 20 | ; |
| 21 | 21 | |
| 22 | 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 | 63 | @Operation(summary = "关闭拼团活动") |
| 64 | 64 | @Parameter(name = "id", description = "编号", required = true) |
| 65 | 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 | 67 | combinationActivityService.closeCombinationActivityById(id); |
| 68 | 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
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java
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 | 5 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; |
| 6 | 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; |
| 7 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; |
| 8 | +import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; | |
| 8 | 9 | import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; |
| 9 | 10 | import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; |
| 10 | 11 | import io.swagger.v3.oas.annotations.Operation; |
| ... | ... | @@ -55,9 +56,8 @@ public class AppDiyTemplateController { |
| 55 | 56 | } |
| 56 | 57 | // 查询模板下的页面 |
| 57 | 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 | 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 | 1 | package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; |
| 2 | 2 | |
| 3 | +import com.fasterxml.jackson.annotation.JsonRawValue; | |
| 3 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 5 | import lombok.Data; |
| 5 | 6 | import lombok.ToString; |
| ... | ... | @@ -16,6 +17,7 @@ public class AppDiyPagePropertyRespVO { |
| 16 | 17 | private String name; |
| 17 | 18 | |
| 18 | 19 | @Schema(description = "页面属性", example = "[]") |
| 20 | + @JsonRawValue | |
| 19 | 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 | 44 | * 备注 |
| 45 | 45 | */ |
| 46 | 46 | private String remark; |
| 47 | - // TODO @疯狂:这个字段要不改成 previewPicUrls,和别的模块一样用 pic 作为图片哇? | |
| 48 | 47 | /** |
| 49 | 48 | * 预览图,多个逗号分隔 |
| 50 | 49 | */ |
| 51 | 50 | @TableField(typeHandler = StringListTypeHandler.class) |
| 52 | - private List<String> previewImageUrls; | |
| 51 | + private List<String> previewPicUrls; | |
| 53 | 52 | /** |
| 54 | 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 | 50 | * 备注 |
| 51 | 51 | */ |
| 52 | 52 | private String remark; |
| 53 | - // TODO @疯狂:这个字段要不改成 previewPicUrls,和别的模块一样用 pic 作为图片哇? | |
| 53 | + | |
| 54 | 54 | /** |
| 55 | 55 | * 预览图 |
| 56 | 56 | */ |
| 57 | 57 | @TableField(typeHandler = StringListTypeHandler.class) |
| 58 | - private List<String> previewImageUrls; | |
| 58 | + private List<String> previewPicUrls; | |
| 59 | 59 | /** |
| 60 | 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 | import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; |
| 12 | 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; |
| 13 | 13 | import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; |
| 14 | +import jakarta.annotation.Resource; | |
| 14 | 15 | import org.springframework.stereotype.Service; |
| 15 | 16 | import org.springframework.transaction.annotation.Transactional; |
| 16 | 17 | import org.springframework.validation.annotation.Validated; |
| 17 | 18 | |
| 18 | -import jakarta.annotation.Resource; | |
| 19 | 19 | import java.time.LocalDateTime; |
| 20 | 20 | |
| 21 | 21 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -36,7 +36,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { |
| 36 | 36 | @Resource |
| 37 | 37 | private DiyPageService diyPageService; |
| 38 | 38 | |
| 39 | - // TODO @疯狂:事务; | |
| 39 | + @Transactional(rollbackFor = Exception.class) | |
| 40 | 40 | @Override |
| 41 | 41 | public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { |
| 42 | 42 | // 校验名称唯一 |
| ... | ... | @@ -121,8 +121,8 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { |
| 121 | 121 | return diyTemplateMapper.selectPage(pageReqVO); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | + @Transactional(rollbackFor = Exception.class) | |
| 124 | 125 | @Override |
| 125 | - // TODO @疯狂:事务; | |
| 126 | 126 | public void useDiyTemplate(Long id) { |
| 127 | 127 | // 校验存在 |
| 128 | 128 | validateDiyTemplateExists(id); |
| ... | ... | @@ -134,10 +134,23 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { |
| 134 | 134 | if (used.getId().equals(id)) { |
| 135 | 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 | 156 | @Override |
| ... | ... | @@ -155,18 +168,4 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { |
| 155 | 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 | 109 | o.setUsed(null); |
| 110 | 110 | o.setUsedTime(null); |
| 111 | 111 | o.setRemark(null); |
| 112 | - o.setPreviewImageUrls(null); | |
| 112 | + o.setPreviewPicUrls(null); | |
| 113 | 113 | o.setProperty(null); |
| 114 | 114 | o.setCreateTime(null); |
| 115 | 115 | }); |
| ... | ... | @@ -122,8 +122,8 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest { |
| 122 | 122 | diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); |
| 123 | 123 | // 测试 remark 不匹配 |
| 124 | 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 | 127 | // 测试 property 不匹配 |
| 128 | 128 | diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); |
| 129 | 129 | // 测试 createTime 不匹配 |
| ... | ... | @@ -152,7 +152,7 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest { |
| 152 | 152 | o.setUsed(null); |
| 153 | 153 | o.setUsedTime(null); |
| 154 | 154 | o.setRemark(null); |
| 155 | - o.setPreviewImageUrls(null); | |
| 155 | + o.setPreviewPicUrls(null); | |
| 156 | 156 | o.setProperty(null); |
| 157 | 157 | o.setCreateTime(null); |
| 158 | 158 | }); |
| ... | ... | @@ -165,8 +165,8 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest { |
| 165 | 165 | diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); |
| 166 | 166 | // 测试 remark 不匹配 |
| 167 | 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 | 170 | // 测试 property 不匹配 |
| 171 | 171 | diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); |
| 172 | 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 "promotion_diy_template" |
| 228 | 228 | "used" bit NOT NULL, |
| 229 | 229 | "used_time" varchar, |
| 230 | 230 | "remark" varchar, |
| 231 | - "preview_image_urls" varchar, | |
| 231 | + "preview_pic_urls" varchar, | |
| 232 | 232 | "property" varchar NOT NULL, |
| 233 | 233 | "creator" varchar DEFAULT '', |
| 234 | 234 | "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| ... | ... | @@ -244,7 +244,7 @@ CREATE TABLE IF NOT EXISTS "promotion_diy_page" |
| 244 | 244 | "template_id" bigint NOT NULL, |
| 245 | 245 | "name" varchar NOT NULL, |
| 246 | 246 | "remark" varchar, |
| 247 | - "preview_image_urls" varchar, | |
| 247 | + "preview_pic_urls" varchar, | |
| 248 | 248 | "property" varchar, |
| 249 | 249 | "creator" varchar DEFAULT '', |
| 250 | 250 | "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ... | ... |