Commit d6b59743a396addbbb591f524f479447f2c0e0a3
1 parent
680718c7
营销:接入 APP 装修页面
Showing
3 changed files
with
56 additions
and
19 deletions
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/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/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 | } |