!822 接入拼团

Merge pull request !822 from 疯狂的世界/develop
This commit is contained in:
芋道源码 2024-01-13 03:20:25 +00:00 committed by Gitee
commit 1b87b8a42f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
13 changed files with 75 additions and 39 deletions

View File

@ -79,7 +79,7 @@ public class AppProductBrowseHistoryController {
Map<Long, ProductSpuDO> spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId); Map<Long, ProductSpuDO> spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId);
return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class, return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class,
vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())) vo -> Optional.ofNullable(spuMap.get(vo.getSpuId()))
.ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl())))); .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice()))));
} }
} }

View File

@ -16,7 +16,7 @@ import java.util.Arrays;
public enum DecoratePageEnum implements IntArrayValuable { public enum DecoratePageEnum implements IntArrayValuable {
INDEX(1, "首页"), INDEX(1, "首页"),
MY(2, "个人中心"), MY(2, "我的"),
; ;
private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray(); private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray();

View File

@ -63,7 +63,7 @@ public class CombinationActivityController {
@Operation(summary = "关闭拼团活动") @Operation(summary = "关闭拼团活动")
@Parameter(name = "id", description = "编号", required = true) @Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('promotion:combination-activity:close')") @PreAuthorize("@ss.hasPermission('promotion:combination-activity:close')")
public CommonResult<Boolean> closeSeckillActivity(@RequestParam("id") Long id) { public CommonResult<Boolean> closeCombinationActivity(@RequestParam("id") Long id) {
combinationActivityService.closeCombinationActivityById(id); combinationActivityService.closeCombinationActivityById(id);
return success(true); return success(true);
} }

View File

@ -24,6 +24,6 @@ public class DiyPageBaseVO {
private String remark; private String remark;
@Schema(description = "预览图") @Schema(description = "预览图")
private List<String> previewImageUrls; private List<String> previewPicUrls;
} }

View File

@ -21,6 +21,6 @@ public class DiyTemplateBaseVO {
private String remark; private String remark;
@Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]") @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]")
private List<String> previewImageUrls; private List<String> previewPicUrls;
} }

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.promotion.controller.app.diy;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyPagePropertyRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO;
import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "用户 APP - 装修页面")
@RestController
@RequestMapping("/promotion/diy-page")
@Validated
public class AppDiyPageController {
@Resource
private DiyPageService diyPageService;
@GetMapping("/get")
@Operation(summary = "获得装修页面")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<AppDiyPagePropertyRespVO> getDiyPage(@RequestParam("id") Long id) {
DiyPageDO diyPage = diyPageService.getDiyPage(id);
return success(BeanUtils.toBean(diyPage, AppDiyPagePropertyRespVO.class));
}
}

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePro
import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService;
import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -55,9 +56,8 @@ public class AppDiyTemplateController {
} }
// 查询模板下的页面 // 查询模板下的页面
List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId()); List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId());
// TODO @疯狂首页我的要不枚举到 DiyPageDO 例如说 NAME_USERNAME_HOME 类似这种哈 String home = findFirst(pages, page -> DecoratePageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty);
String home = findFirst(pages, page -> "首页".equals(page.getName()), DiyPageDO::getProperty); String user = findFirst(pages, page -> DecoratePageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty);
String user = findFirst(pages, page -> "我的".equals(page.getName()), DiyPageDO::getProperty);
// 拼接返回 // 拼接返回
return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user); return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user);
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; package cn.iocoder.yudao.module.promotion.controller.app.diy.vo;
import com.fasterxml.jackson.annotation.JsonRawValue;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@ -16,6 +17,7 @@ public class AppDiyPagePropertyRespVO {
private String name; private String name;
@Schema(description = "页面属性", example = "[]") @Schema(description = "页面属性", example = "[]")
@JsonRawValue
private String property; private String property;
} }

View File

@ -44,12 +44,11 @@ public class DiyPageDO extends BaseDO {
* 备注 * 备注
*/ */
private String remark; private String remark;
// TODO @疯狂这个字段要不改成 previewPicUrls和别的模块一样用 pic 作为图片哇
/** /**
* 预览图多个逗号分隔 * 预览图多个逗号分隔
*/ */
@TableField(typeHandler = StringListTypeHandler.class) @TableField(typeHandler = StringListTypeHandler.class)
private List<String> previewImageUrls; private List<String> previewPicUrls;
/** /**
* 页面属性JSON 格式 * 页面属性JSON 格式
*/ */

View File

@ -50,12 +50,12 @@ public class DiyTemplateDO extends BaseDO {
* 备注 * 备注
*/ */
private String remark; private String remark;
// TODO @疯狂这个字段要不改成 previewPicUrls和别的模块一样用 pic 作为图片哇
/** /**
* 预览图 * 预览图
*/ */
@TableField(typeHandler = StringListTypeHandler.class) @TableField(typeHandler = StringListTypeHandler.class)
private List<String> previewImageUrls; private List<String> previewPicUrls;
/** /**
* uni-app 底部导航属性JSON 格式 * uni-app 底部导航属性JSON 格式
*/ */

View File

@ -11,11 +11,11 @@ import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert;
import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -36,7 +36,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
@Resource @Resource
private DiyPageService diyPageService; private DiyPageService diyPageService;
// TODO @疯狂事务 @Transactional(rollbackFor = Exception.class)
@Override @Override
public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) {
// 校验名称唯一 // 校验名称唯一
@ -121,8 +121,8 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
return diyTemplateMapper.selectPage(pageReqVO); return diyTemplateMapper.selectPage(pageReqVO);
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
// TODO @疯狂事务
public void useDiyTemplate(Long id) { public void useDiyTemplate(Long id) {
// 校验存在 // 校验存在
validateDiyTemplateExists(id); validateDiyTemplateExists(id);
@ -134,10 +134,23 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
if (used.getId().equals(id)) { if (used.getId().equals(id)) {
return; return;
} }
this.updateUsed(used.getId(), false, null); this.updateTemplateUsed(used.getId(), false, null);
} }
// 更新为已使用 // 更新为已使用
this.updateUsed(id, true, LocalDateTime.now()); this.updateTemplateUsed(id, true, LocalDateTime.now());
}
/**
* 更新模板是否使用
*
* @param id 模板编号
* @param used 是否使用
* @param usedTime 使用时间
*/
private void updateTemplateUsed(Long id, Boolean used, LocalDateTime usedTime) {
DiyTemplateDO updateObj = new DiyTemplateDO().setId(id)
.setUsed(used).setUsedTime(usedTime);
diyTemplateMapper.updateById(updateObj);
} }
@Override @Override
@ -155,18 +168,4 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
return diyTemplateMapper.selectByUsed(true); return diyTemplateMapper.selectByUsed(true);
} }
// TODO @疯狂挪到 useDiyTemplate 下面改名 updateTemplateUsed 会不会好点哈
/**
* 更新模板是否使用
*
* @param id 模板编号
* @param used 是否使用
* @param usedTime 使用时间
*/
private void updateUsed(Long id, Boolean used, LocalDateTime usedTime) {
DiyTemplateDO updateObj = new DiyTemplateDO().setId(id)
.setUsed(used).setUsedTime(usedTime);
diyTemplateMapper.updateById(updateObj);
}
} }

View File

@ -109,7 +109,7 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest {
o.setUsed(null); o.setUsed(null);
o.setUsedTime(null); o.setUsedTime(null);
o.setRemark(null); o.setRemark(null);
o.setPreviewImageUrls(null); o.setPreviewPicUrls(null);
o.setProperty(null); o.setProperty(null);
o.setCreateTime(null); o.setCreateTime(null);
}); });
@ -122,8 +122,8 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest {
diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null)));
// 测试 remark 不匹配 // 测试 remark 不匹配
diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null))); diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null)));
// 测试 previewImageUrls 不匹配 // 测试 previewPicUrls 不匹配
diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewImageUrls(null))); diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewPicUrls(null)));
// 测试 property 不匹配 // 测试 property 不匹配
diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null)));
// 测试 createTime 不匹配 // 测试 createTime 不匹配
@ -152,7 +152,7 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest {
o.setUsed(null); o.setUsed(null);
o.setUsedTime(null); o.setUsedTime(null);
o.setRemark(null); o.setRemark(null);
o.setPreviewImageUrls(null); o.setPreviewPicUrls(null);
o.setProperty(null); o.setProperty(null);
o.setCreateTime(null); o.setCreateTime(null);
}); });
@ -165,8 +165,8 @@ public class DiyTemplateServiceImplTest extends BaseDbUnitTest {
diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null)));
// 测试 remark 不匹配 // 测试 remark 不匹配
diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null))); diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null)));
// 测试 previewImageUrls 不匹配 // 测试 previewPicUrls 不匹配
diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewImageUrls(null))); diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewPicUrls(null)));
// 测试 property 不匹配 // 测试 property 不匹配
diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null)));
// 测试 createTime 不匹配 // 测试 createTime 不匹配

View File

@ -228,7 +228,7 @@ CREATE TABLE IF NOT EXISTS "promotion_diy_template"
"used" bit NOT NULL, "used" bit NOT NULL,
"used_time" varchar, "used_time" varchar,
"remark" varchar, "remark" varchar,
"preview_image_urls" varchar, "preview_pic_urls" varchar,
"property" varchar NOT NULL, "property" varchar NOT NULL,
"creator" varchar DEFAULT '', "creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
@ -244,7 +244,7 @@ CREATE TABLE IF NOT EXISTS "promotion_diy_page"
"template_id" bigint NOT NULL, "template_id" bigint NOT NULL,
"name" varchar NOT NULL, "name" varchar NOT NULL,
"remark" varchar, "remark" varchar,
"preview_image_urls" varchar, "preview_pic_urls" varchar,
"property" varchar, "property" varchar,
"creator" varchar DEFAULT '', "creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,