diff --git a/yudao-admin-vue3/.env b/yudao-admin-vue3/.env index c18e52e..5109f33 100644 --- a/yudao-admin-vue3/.env +++ b/yudao-admin-vue3/.env @@ -14,7 +14,7 @@ VITE_APP_TENANT_ENABLE=true VITE_APP_CAPTCHA_ENABLE=true # 文档地址的开关 -VITE_APP_DOCALERT_ENABLE=true +VITE_APP_DOCALERT_ENABLE=false # 百度统计 VITE_APP_BAIDU_CODE = a1ff8825baa73c3a78eb96aa40325abc diff --git a/yudao-admin-vue3/src/api/mall/promotion/circle/index.ts b/yudao-admin-vue3/src/api/mall/promotion/circle/index.ts new file mode 100644 index 0000000..63106f4 --- /dev/null +++ b/yudao-admin-vue3/src/api/mall/promotion/circle/index.ts @@ -0,0 +1,46 @@ +import request from '@/config/axios' + +// 商城动态 VO +export interface CircleVO { + id: number // 编号 + userId: number // 用户编号 + content: string // 发表内容 + picUrl: string // 图片地址 + likeCount: number // 点赞量 + lookCount: number // 访问量 + commentCount: number // 评论数量 + version: number // 更新版本号 +} + +// 商城动态 API +export const CircleApi = { + // 查询商城动态分页 + getCirclePage: async (params: any) => { + return await request.get({ url: `/promotion/circle/page`, params }) + }, + + // 查询商城动态详情 + getCircle: async (id: number) => { + return await request.get({ url: `/promotion/circle/get?id=` + id }) + }, + + // 新增商城动态 + createCircle: async (data: CircleVO) => { + return await request.post({ url: `/promotion/circle/create`, data }) + }, + + // 修改商城动态 + updateCircle: async (data: CircleVO) => { + return await request.put({ url: `/promotion/circle/update`, data }) + }, + + // 删除商城动态 + deleteCircle: async (id: number) => { + return await request.delete({ url: `/promotion/circle/delete?id=` + id }) + }, + + // 导出商城动态 Excel + exportCircle: async (params) => { + return await request.download({ url: `/promotion/circle/export-excel`, params }) + } +} \ No newline at end of file diff --git a/yudao-admin-vue3/src/api/mall/promotion/circlereview/index.ts b/yudao-admin-vue3/src/api/mall/promotion/circlereview/index.ts new file mode 100644 index 0000000..1a9329d --- /dev/null +++ b/yudao-admin-vue3/src/api/mall/promotion/circlereview/index.ts @@ -0,0 +1,48 @@ +import request from '@/config/axios' + +// 动态的评论 VO +export interface CircleReviewVO { + id: number // 编号 + userId: number // 用户id + circleId: number // 动态id + type: number // 评论类型 + content: string // 评论内容 + picUrl: string // 图片地址 + likeCount: number // 点赞量 + replyId: number // 被回复的评论ID + replyUserId: number // 被回复的用户ID + version: number // 版本号 +} + +// 动态的评论 API +export const CircleReviewApi = { + // 查询动态的评论分页 + getCircleReviewPage: async (params: any) => { + return await request.get({ url: `/promotion/circle-review/page`, params }) + }, + + // 查询动态的评论详情 + getCircleReview: async (id: number) => { + return await request.get({ url: `/promotion/circle-review/get?id=` + id }) + }, + + // 新增动态的评论 + createCircleReview: async (data: CircleReviewVO) => { + return await request.post({ url: `/promotion/circle-review/create`, data }) + }, + + // 修改动态的评论 + updateCircleReview: async (data: CircleReviewVO) => { + return await request.put({ url: `/promotion/circle-review/update`, data }) + }, + + // 删除动态的评论 + deleteCircleReview: async (id: number) => { + return await request.delete({ url: `/promotion/circle-review/delete?id=` + id }) + }, + + // 导出动态的评论 Excel + exportCircleReview: async (params) => { + return await request.download({ url: `/promotion/circle-review/export-excel`, params }) + } +} \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/mall/promotion/circle/CircleForm.vue b/yudao-admin-vue3/src/views/mall/promotion/circle/CircleForm.vue new file mode 100644 index 0000000..2941115 --- /dev/null +++ b/yudao-admin-vue3/src/views/mall/promotion/circle/CircleForm.vue @@ -0,0 +1,121 @@ + + \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/mall/promotion/circle/index.vue b/yudao-admin-vue3/src/views/mall/promotion/circle/index.vue new file mode 100644 index 0000000..eff1806 --- /dev/null +++ b/yudao-admin-vue3/src/views/mall/promotion/circle/index.vue @@ -0,0 +1,235 @@ + + + \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/mall/promotion/circlereview/CircleReviewForm.vue b/yudao-admin-vue3/src/views/mall/promotion/circlereview/CircleReviewForm.vue new file mode 100644 index 0000000..88e56e9 --- /dev/null +++ b/yudao-admin-vue3/src/views/mall/promotion/circlereview/CircleReviewForm.vue @@ -0,0 +1,139 @@ + + \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/mall/promotion/circlereview/index.vue b/yudao-admin-vue3/src/views/mall/promotion/circlereview/index.vue new file mode 100644 index 0000000..863b0cb --- /dev/null +++ b/yudao-admin-vue3/src/views/mall/promotion/circlereview/index.vue @@ -0,0 +1,268 @@ + + + \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/mall/promotion/intelligent/index.vue b/yudao-admin-vue3/src/views/mall/promotion/intelligent/index.vue index bbb13bc..2d35176 100644 --- a/yudao-admin-vue3/src/views/mall/promotion/intelligent/index.vue +++ b/yudao-admin-vue3/src/views/mall/promotion/intelligent/index.vue @@ -203,7 +203,7 @@ }, //推广按钮操作 handelExtend(id) { - this.extendLink = 'http://101.43.112.107/form/extendLink/form?id=' + id + this.extendLink = 'http://zysc.fjptzykj.com/form/extendLink/form?id=' + id this.extendOpen = true; this.extendTitle = "推广链接"; }, @@ -278,4 +278,4 @@ border: none; /* border-bottom:1px solid blue; */ } - \ No newline at end of file + diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java index 8cebd6e..52b260a 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java @@ -131,4 +131,8 @@ public interface ErrorCodeConstants { // ========== 客服消息 1-013-020-000 ========== ErrorCode KEFU_MESSAGE_NOT_EXISTS = new ErrorCode(1_013_020_000, "客服消息不存在"); + ErrorCode CIRCLE_NOT_EXISTS = new ErrorCode(1_013_021_000, "商城动态不存在"); + + ErrorCode CIRCLE_REVIEW_NOT_EXISTS = new ErrorCode(1_013_022_000, "动态的评论不存在"); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/CircleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/CircleController.java new file mode 100644 index 0000000..ba783e8 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/CircleController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.circle; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.promotion.controller.admin.circle.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circle.CircleDO; +import cn.iocoder.yudao.module.promotion.service.circle.CircleService; + +@Tag(name = "管理后台 - 商城动态") +@RestController +@RequestMapping("/promotion/circle") +@Validated +public class CircleController { + + @Resource + private CircleService circleService; + + @PostMapping("/create") + @Operation(summary = "创建商城动态") + @PreAuthorize("@ss.hasPermission('promotion:circle:create')") + public CommonResult createCircle(@Valid @RequestBody CircleSaveReqVO createReqVO) { + return success(circleService.createCircle(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新商城动态") + @PreAuthorize("@ss.hasPermission('promotion:circle:update')") + public CommonResult updateCircle(@Valid @RequestBody CircleSaveReqVO updateReqVO) { + circleService.updateCircle(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除商城动态") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('promotion:circle:delete')") + public CommonResult deleteCircle(@RequestParam("id") Long id) { + circleService.deleteCircle(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得商城动态") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('promotion:circle:query')") + public CommonResult getCircle(@RequestParam("id") Long id) { + CircleDO circle = circleService.getCircle(id); + return success(BeanUtils.toBean(circle, CircleRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得商城动态分页") + @PreAuthorize("@ss.hasPermission('promotion:circle:query')") + public CommonResult> getCirclePage(@Valid CirclePageReqVO pageReqVO) { + PageResult pageResult = circleService.getCirclePage(pageReqVO); + return success(BeanUtils.toBean(pageResult, CircleRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出商城动态 Excel") + @PreAuthorize("@ss.hasPermission('promotion:circle:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportCircleExcel(@Valid CirclePageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = circleService.getCirclePage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "商城动态.xls", "数据", CircleRespVO.class, + BeanUtils.toBean(list, CircleRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CirclePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CirclePageReqVO.java new file mode 100644 index 0000000..79e4ca4 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CirclePageReqVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.circle.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 商城动态分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CirclePageReqVO extends PageParam { + + @Schema(description = "用户编号", example = "20140") + private Long userId; + + @Schema(description = "发表内容") + private String content; + + @Schema(description = "图片地址", example = "https://www.iocoder.cn") + private String picUrl; + + @Schema(description = "点赞量", example = "22573") + private Long likeCount; + + @Schema(description = "访问量", example = "14008") + private Long lookCount; + + @Schema(description = "评论数量", example = "8684") + private Long commentCount; + + @Schema(description = "更新版本号") + private Integer version; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CircleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CircleRespVO.java new file mode 100644 index 0000000..85936ed --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CircleRespVO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.circle.vo; + +import cn.iocoder.yudao.module.promotion.dal.dataobject.circle.CircleDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circlereview.CircleReviewDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 商城动态 Response VO") +@Data +@ExcelIgnoreUnannotated +public class CircleRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5886") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "用户编号", example = "20140") + @ExcelProperty("用户编号") + private Long userId; + + @Schema(description = "发表内容") + @ExcelProperty("发表内容") + private String content; + + @Schema(description = "图片地址", example = "https://www.iocoder.cn") + @ExcelProperty("图片地址") + private String picUrl; + + @Schema(description = "点赞量", example = "22573") + @ExcelProperty("点赞量") + private Long likeCount; + + @Schema(description = "访问量", example = "14008") + @ExcelProperty("访问量") + private Long lookCount; + + @Schema(description = "评论数量", example = "8684") + @ExcelProperty("评论数量") + private Long commentCount; + + @Schema(description = "更新版本号") + @ExcelProperty("更新版本号") + private Integer version; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "评论信息") + private List circleList; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CircleSaveReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CircleSaveReqVO.java new file mode 100644 index 0000000..ab5539c --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circle/vo/CircleSaveReqVO.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.circle.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 商城动态新增/修改 Request VO") +@Data +public class CircleSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5886") + private Long id; + + @Schema(description = "用户编号", example = "20140") + private Long userId; + + @Schema(description = "发表内容") + private String content; + + @Schema(description = "图片地址", example = "https://www.iocoder.cn") + private String picUrl; + + @Schema(description = "点赞量", example = "22573") + private Long likeCount; + + @Schema(description = "访问量", example = "14008") + private Long lookCount; + + @Schema(description = "评论数量", example = "8684") + private Long commentCount; + + @Schema(description = "更新版本号") + private Integer version; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/CircleReviewController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/CircleReviewController.java new file mode 100644 index 0000000..0519cca --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/CircleReviewController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.circlereview; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circlereview.CircleReviewDO; +import cn.iocoder.yudao.module.promotion.service.circlereview.CircleReviewService; + +@Tag(name = "管理后台 - 动态的评论") +@RestController +@RequestMapping("/promotion/circle-review") +@Validated +public class CircleReviewController { + + @Resource + private CircleReviewService circleReviewService; + + @PostMapping("/create") + @Operation(summary = "创建动态的评论") + @PreAuthorize("@ss.hasPermission('promotion:circle-review:create')") + public CommonResult createCircleReview(@Valid @RequestBody CircleReviewSaveReqVO createReqVO) { + return success(circleReviewService.createCircleReview(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新动态的评论") + @PreAuthorize("@ss.hasPermission('promotion:circle-review:update')") + public CommonResult updateCircleReview(@Valid @RequestBody CircleReviewSaveReqVO updateReqVO) { + circleReviewService.updateCircleReview(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除动态的评论") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('promotion:circle-review:delete')") + public CommonResult deleteCircleReview(@RequestParam("id") Long id) { + circleReviewService.deleteCircleReview(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得动态的评论") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('promotion:circle-review:query')") + public CommonResult getCircleReview(@RequestParam("id") Long id) { + CircleReviewDO circleReview = circleReviewService.getCircleReview(id); + return success(BeanUtils.toBean(circleReview, CircleReviewRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得动态的评论分页") + @PreAuthorize("@ss.hasPermission('promotion:circle-review:query')") + public CommonResult> getCircleReviewPage(@Valid CircleReviewPageReqVO pageReqVO) { + PageResult pageResult = circleReviewService.getCircleReviewPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, CircleReviewRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出动态的评论 Excel") + @PreAuthorize("@ss.hasPermission('promotion:circle-review:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportCircleReviewExcel(@Valid CircleReviewPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = circleReviewService.getCircleReviewPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "动态的评论.xls", "数据", CircleReviewRespVO.class, + BeanUtils.toBean(list, CircleReviewRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewPageReqVO.java new file mode 100644 index 0000000..d9da523 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewPageReqVO.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 动态的评论分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CircleReviewPageReqVO extends PageParam { + + @Schema(description = "用户id", example = "10725") + private Long userId; + + @Schema(description = "动态id", example = "17391") + private Long circleId; + + @Schema(description = "评论类型", example = "2") + private Integer type; + + @Schema(description = "评论内容") + private String content; + + @Schema(description = "图片地址", example = "https://www.iocoder.cn") + private String picUrl; + + @Schema(description = "点赞量", example = "10166") + private Long likeCount; + + @Schema(description = "被回复的评论ID", example = "8913") + private Long replyId; + + @Schema(description = "被回复的用户ID", example = "32646") + private Long replyUserId; + + @Schema(description = "版本号") + private Integer version; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewRespVO.java new file mode 100644 index 0000000..e24885e --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewRespVO.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 动态的评论 Response VO") +@Data +@ExcelIgnoreUnannotated +public class CircleReviewRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12446") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "用户id", example = "10725") + @ExcelProperty("用户id") + private Long userId; + + @Schema(description = "动态id", example = "17391") + @ExcelProperty("动态id") + private Long circleId; + + @Schema(description = "评论类型", example = "2") + @ExcelProperty(value = "评论类型", converter = DictConvert.class) + @DictFormat("circle_review_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer type; + + @Schema(description = "评论内容") + @ExcelProperty("评论内容") + private String content; + + @Schema(description = "图片地址", example = "https://www.iocoder.cn") + @ExcelProperty("图片地址") + private String picUrl; + + @Schema(description = "点赞量", example = "10166") + @ExcelProperty("点赞量") + private Long likeCount; + + @Schema(description = "被回复的评论ID", example = "8913") + @ExcelProperty("被回复的评论ID") + private Long replyId; + + @Schema(description = "被回复的用户ID", example = "32646") + @ExcelProperty("被回复的用户ID") + private Long replyUserId; + + @Schema(description = "版本号") + @ExcelProperty("版本号") + private Integer version; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "备注") + private String remark; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewSaveReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewSaveReqVO.java new file mode 100644 index 0000000..d0c3936 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/circlereview/vo/CircleReviewSaveReqVO.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 动态的评论新增/修改 Request VO") +@Data +public class CircleReviewSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12446") + private Long id; + + @Schema(description = "用户id", example = "10725") + private Long userId; + + @Schema(description = "动态id", example = "17391") + private Long circleId; + + @Schema(description = "评论类型", example = "2") + private Integer type; + + @Schema(description = "评论内容") + private String content; + + @Schema(description = "图片地址", example = "https://www.iocoder.cn") + private String picUrl; + + @Schema(description = "点赞量", example = "10166") + private Long likeCount; + + @Schema(description = "被回复的评论ID", example = "8913") + private Long replyId; + + @Schema(description = "被回复的用户ID", example = "32646") + private Long replyUserId; + + @Schema(description = "版本号") + private Integer version; + + @Schema(description = "备注") + private String remark; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/circle/AppCircleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/circle/AppCircleController.java new file mode 100644 index 0000000..1faf0a5 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/circle/AppCircleController.java @@ -0,0 +1,106 @@ +package cn.iocoder.yudao.module.promotion.controller.app.circle; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; +import cn.iocoder.yudao.module.promotion.controller.admin.circle.vo.CirclePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.circle.vo.CircleRespVO; +import cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo.CircleReviewSaveReqVO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circle.CircleDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circlereview.CircleReviewDO; +import cn.iocoder.yudao.module.promotion.service.circle.CircleService; +import cn.iocoder.yudao.module.promotion.service.circlereview.CircleReviewService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; + +@Tag(name = "用户 APP - 商城动态") // 用于提供跨多个活动的 HTTP 接口 +@RestController +@RequestMapping("/promotion/circle") +@Validated +public class AppCircleController { + @Resource + private CircleService circleService; + @Resource + private CircleReviewService circleReviewService; + @Resource + private MemberUserApi memberUserApi; + + public String utilMethod(Long userId,Long reviewId){ + String nickname = memberUserApi.getUser(userId).getNickname(); + if (reviewId != null){ + String reviewNickname = memberUserApi.getUser(reviewId).getNickname(); + return nickname + "回复了" +reviewNickname; + } + return nickname; + } + + @GetMapping("/page") + @Operation(summary = "获得商城动态列表") + @PreAuthenticated + public CommonResult> getCirclePage(@Valid CirclePageReqVO pageReqVO) { + PageResult pageResult = circleService.getCirclePage(pageReqVO); + PageResult result = BeanUtils.toBean(pageResult, CircleRespVO.class); + for (CircleRespVO circleRespVO : result.getList()) { + List listCircleReviewByCircleId = circleReviewService.getListCircleReviewByCircleId(circleRespVO.getId()); + for (CircleReviewDO reviewDO : listCircleReviewByCircleId) { + reviewDO.setRemark(utilMethod(reviewDO.getUserId(),reviewDO.getReplyUserId())); + } + circleRespVO.setCircleList(listCircleReviewByCircleId); + } + return success(result); + } + + @GetMapping("/doBrowse") + @Operation(summary = "浏览量叠加") + @PreAuthenticated + public CommonResult doBrowse(@RequestParam("id") Long lookId){ + circleService.addLookCount(lookId); + return success(true); + } + + @GetMapping("/doLike") + @Operation(summary = "点赞/取消点赞") + @PreAuthenticated + public CommonResult doLike(@RequestParam("id") Long lookId){ + circleService.updateLikeCount(lookId); + return success(true); + } + + @PostMapping("/doReview") + @Operation(summary = "评论/回复") + @PreAuthenticated + public CommonResult doReview(@RequestBody CircleReviewSaveReqVO createReqVO){ + createReqVO.setUserId(getLoginUserId()); + circleReviewService.createCircleReview(createReqVO); + return success(true); + } + + @GetMapping("/doReviewDelete") + @Operation(summary = "删除评论") + @PreAuthenticated + public CommonResult doReviewDelete(@RequestParam("id") Long lookId){ + circleReviewService.deleteCircleReview(lookId); + return success(true); + } + + @GetMapping("/doCircleDelete") + @Operation(summary = "删除动态") + @PreAuthenticated + public CommonResult doCircleDelete(@RequestParam("id") Long lookId){ + circleService.deleteCircle(lookId); + return success(true); + } + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/circle/CircleDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/circle/CircleDO.java new file mode 100644 index 0000000..db137cc --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/circle/CircleDO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.promotion.dal.dataobject.circle; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 商城动态 DO + * + * @author 管理员 + */ +@TableName("promotion_circle") +@KeySequence("promotion_circle_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CircleDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 用户编号 + */ + private Long userId; + /** + * 发表内容 + */ + private String content; + /** + * 图片地址 + */ + private String picUrl; + /** + * 点赞量 + */ + private Long likeCount; + /** + * 访问量 + */ + private Long lookCount; + /** + * 评论数量 + */ + private Long commentCount; + /** + * 更新版本号 + */ + private Integer version; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/circlereview/CircleReviewDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/circlereview/CircleReviewDO.java new file mode 100644 index 0000000..5bccabf --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/circlereview/CircleReviewDO.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.promotion.dal.dataobject.circlereview; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 动态的评论 DO + * + * @author 管理员 + */ +@TableName("promotion_circle_review") +@KeySequence("promotion_circle_review_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CircleReviewDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 用户id + */ + private Long userId; + /** + * 动态id + */ + private Long circleId; + /** + * 评论类型 + * + * 枚举 {@link TODO circle_review_type 对应的类} + */ + private Integer type; + /** + * 评论内容 + */ + private String content; + /** + * 图片地址 + */ + private String picUrl; + /** + * 点赞量 + */ + private Long likeCount; + /** + * 被回复的评论ID + */ + private Long replyId; + /** + * 被回复的用户ID + */ + private Long replyUserId; + /** + * 版本号 + */ + private Integer version; + + /** + * 备注 + */ + private String remark; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/circle/CircleMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/circle/CircleMapper.java new file mode 100644 index 0000000..a9f68ec --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/circle/CircleMapper.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.module.promotion.dal.mysql.circle; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circle.CircleDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.promotion.controller.admin.circle.vo.*; + +/** + * 商城动态 Mapper + * + * @author 管理员 + */ +@Mapper +public interface CircleMapper extends BaseMapperX { + + default PageResult selectPage(CirclePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(CircleDO::getUserId, reqVO.getUserId()) + .eqIfPresent(CircleDO::getContent, reqVO.getContent()) + .eqIfPresent(CircleDO::getPicUrl, reqVO.getPicUrl()) + .eqIfPresent(CircleDO::getLikeCount, reqVO.getLikeCount()) + .eqIfPresent(CircleDO::getLookCount, reqVO.getLookCount()) + .eqIfPresent(CircleDO::getCommentCount, reqVO.getCommentCount()) + .eqIfPresent(CircleDO::getVersion, reqVO.getVersion()) + .betweenIfPresent(CircleDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CircleDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/circlereview/CircleReviewMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/circlereview/CircleReviewMapper.java new file mode 100644 index 0000000..9cf97af --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/circlereview/CircleReviewMapper.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.promotion.dal.mysql.circlereview; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circlereview.CircleReviewDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo.*; + +/** + * 动态的评论 Mapper + * + * @author 管理员 + */ +@Mapper +public interface CircleReviewMapper extends BaseMapperX { + + default PageResult selectPage(CircleReviewPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(CircleReviewDO::getUserId, reqVO.getUserId()) + .eqIfPresent(CircleReviewDO::getCircleId, reqVO.getCircleId()) + .eqIfPresent(CircleReviewDO::getType, reqVO.getType()) + .eqIfPresent(CircleReviewDO::getContent, reqVO.getContent()) + .eqIfPresent(CircleReviewDO::getPicUrl, reqVO.getPicUrl()) + .eqIfPresent(CircleReviewDO::getLikeCount, reqVO.getLikeCount()) + .eqIfPresent(CircleReviewDO::getReplyId, reqVO.getReplyId()) + .eqIfPresent(CircleReviewDO::getReplyUserId, reqVO.getReplyUserId()) + .eqIfPresent(CircleReviewDO::getVersion, reqVO.getVersion()) + .eqIfPresent(CircleReviewDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(CircleReviewDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CircleReviewDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circle/CircleService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circle/CircleService.java new file mode 100644 index 0000000..16bb754 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circle/CircleService.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.promotion.service.circle; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.promotion.controller.admin.circle.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circle.CircleDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 商城动态 Service 接口 + * + * @author 管理员 + */ +public interface CircleService { + + /** + * 创建商城动态 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCircle(@Valid CircleSaveReqVO createReqVO); + + /** + * 更新商城动态 + * + * @param updateReqVO 更新信息 + */ + void updateCircle(@Valid CircleSaveReqVO updateReqVO); + + //浏览量叠加 + void addLookCount(Long circleId); + + //点赞/取消点赞 + void updateLikeCount(Long circleId); + + /** + * 删除商城动态 + * + * @param id 编号 + */ + void deleteCircle(Long id); + + /** + * 获得商城动态 + * + * @param id 编号 + * @return 商城动态 + */ + CircleDO getCircle(Long id); + + /** + * 获得商城动态分页 + * + * @param pageReqVO 分页查询 + * @return 商城动态分页 + */ + PageResult getCirclePage(CirclePageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circle/CircleServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circle/CircleServiceImpl.java new file mode 100644 index 0000000..06f2686 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circle/CircleServiceImpl.java @@ -0,0 +1,88 @@ +package cn.iocoder.yudao.module.promotion.service.circle; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.promotion.controller.admin.circle.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circle.CircleDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.promotion.dal.mysql.circle.CircleMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; + +/** + * 商城动态 Service 实现类 + * + * @author 管理员 + */ +@Service +@Validated +public class CircleServiceImpl implements CircleService { + + @Resource + private CircleMapper circleMapper; + + @Override + public Long createCircle(CircleSaveReqVO createReqVO) { + // 插入 + CircleDO circle = BeanUtils.toBean(createReqVO, CircleDO.class); + circleMapper.insert(circle); + // 返回 + return circle.getId(); + } + + @Override + public void updateCircle(CircleSaveReqVO updateReqVO) { + // 校验存在 + validateCircleExists(updateReqVO.getId()); + // 更新 + CircleDO updateObj = BeanUtils.toBean(updateReqVO, CircleDO.class); + circleMapper.updateById(updateObj); + } + + @Override + public void addLookCount(Long circleId) { + CircleDO circleDO = circleMapper.selectOne("id", circleId); + circleDO.setLookCount(circleDO.getLookCount() + 1); + circleMapper.updateById(circleDO); + } + + @Override + public void updateLikeCount(Long circleId) { + CircleDO circleDO = circleMapper.selectOne("id", circleId); + circleDO.setLookCount(circleDO.getLikeCount() + 1); + circleMapper.updateById(circleDO); + } + + @Override + public void deleteCircle(Long id) { + // 校验存在 + validateCircleExists(id); + // 删除 + circleMapper.deleteById(id); + } + + private void validateCircleExists(Long id) { + if (circleMapper.selectById(id) == null) { + throw exception(CIRCLE_NOT_EXISTS); + } + } + + @Override + public CircleDO getCircle(Long id) { + return circleMapper.selectById(id); + } + + @Override + public PageResult getCirclePage(CirclePageReqVO pageReqVO) { + return circleMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circlereview/CircleReviewService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circlereview/CircleReviewService.java new file mode 100644 index 0000000..0ac6dbb --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circlereview/CircleReviewService.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.promotion.service.circlereview; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circlereview.CircleReviewDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 动态的评论 Service 接口 + * + * @author 管理员 + */ +public interface CircleReviewService { + + /** + * 创建动态的评论 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCircleReview(@Valid CircleReviewSaveReqVO createReqVO); + + /** + * 更新动态的评论 + * + * @param updateReqVO 更新信息 + */ + void updateCircleReview(@Valid CircleReviewSaveReqVO updateReqVO); + + /** + * 删除动态的评论 + * + * @param id 编号 + */ + void deleteCircleReview(Long id); + + /** + * 获得动态的评论 + * + * @param id 编号 + * @return 动态的评论 + */ + CircleReviewDO getCircleReview(Long id); + + List getListCircleReviewByCircleId(Long circleId); + + /** + * 获得动态的评论分页 + * + * @param pageReqVO 分页查询 + * @return 动态的评论分页 + */ + PageResult getCircleReviewPage(CircleReviewPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circlereview/CircleReviewServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circlereview/CircleReviewServiceImpl.java new file mode 100644 index 0000000..ac34c49 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/circlereview/CircleReviewServiceImpl.java @@ -0,0 +1,79 @@ +package cn.iocoder.yudao.module.promotion.service.circlereview; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.circlereview.CircleReviewDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.promotion.dal.mysql.circlereview.CircleReviewMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; + +/** + * 动态的评论 Service 实现类 + * + * @author 管理员 + */ +@Service +@Validated +public class CircleReviewServiceImpl implements CircleReviewService { + + @Resource + private CircleReviewMapper circleReviewMapper; + + @Override + public Long createCircleReview(CircleReviewSaveReqVO createReqVO) { + // 插入 + CircleReviewDO circleReview = BeanUtils.toBean(createReqVO, CircleReviewDO.class); + circleReviewMapper.insert(circleReview); + // 返回 + return circleReview.getId(); + } + + @Override + public void updateCircleReview(CircleReviewSaveReqVO updateReqVO) { + // 校验存在 + validateCircleReviewExists(updateReqVO.getId()); + // 更新 + CircleReviewDO updateObj = BeanUtils.toBean(updateReqVO, CircleReviewDO.class); + circleReviewMapper.updateById(updateObj); + } + + @Override + public void deleteCircleReview(Long id) { + // 校验存在 + validateCircleReviewExists(id); + // 删除 + circleReviewMapper.deleteById(id); + } + + private void validateCircleReviewExists(Long id) { + if (circleReviewMapper.selectById(id) == null) { + throw exception(CIRCLE_REVIEW_NOT_EXISTS); + } + } + + @Override + public CircleReviewDO getCircleReview(Long id) { + return circleReviewMapper.selectById(id); + } + + @Override + public List getListCircleReviewByCircleId(Long circleId) { + return circleReviewMapper.selectList("circle_id", circleId); + } + + @Override + public PageResult getCircleReviewPage(CircleReviewPageReqVO pageReqVO) { + return circleReviewMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java index b7884c7..2305ccd 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java @@ -44,7 +44,8 @@ public class RewardActivityServiceImpl implements RewardActivityService { // 插入 RewardActivityDO rewardActivity = RewardActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getEndTime())); + .setStatus(PromotionUtils.calculateRewardActivityStatus(createReqVO.getStartTime(), + createReqVO.getEndTime())); rewardActivityMapper.insert(rewardActivity); // 返回 return rewardActivity.getId(); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java index 2ad362f..84903cb 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java @@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.promotion.util; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; +import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; /** * 活动工具类 @@ -22,4 +24,17 @@ public class PromotionUtils { return LocalDateTimeUtils.beforeNow(endTime) ? CommonStatusEnum.DISABLE.getStatus() : CommonStatusEnum.ENABLE.getStatus(); } + public static Integer calculateRewardActivityStatus(LocalDateTime starTime, LocalDateTime endTime) { + if (LocalDateTimeUtils.afterNow(starTime)){ + return PromotionActivityStatusEnum.WAIT.getStatus(); + } + if (LocalDateTimeUtils.beforeNow(starTime) && LocalDateTimeUtils.afterNow(endTime)){ + return PromotionActivityStatusEnum.RUN.getStatus(); + } + if (LocalDateTimeUtils.beforeNow(endTime)){ + return PromotionActivityStatusEnum.END.getStatus(); + } + return PromotionActivityStatusEnum.CLOSE.getStatus(); + } + }