From 7ab7137332ef98dd61d3fab3d90b1d4b2ec1f488 Mon Sep 17 00:00:00 2001 From: Jermaine Date: Tue, 12 Jul 2022 16:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AF=84=E8=AE=BA=E6=99=AF?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zm/trip/restful/BaseUserController.java | 4 +- .../trip/restful/BusCommentsController.java | 57 +++++++++++++++---- .../RelaScenicSpotCommentsController.java | 26 +++++++-- .../restful/RelaUserCommentsController.java | 4 +- .../main/resources/trip_web-202207071536.sql | 2 +- .../target/classes/trip_web-202207071536.sql | 2 +- .../trip/entity/RelaScenicSpotComments.java | 6 ++ .../cn/zm/trip/entity/RelaUserComments.java | 8 ++- .../trip/entity/dto/RelaUserCommentsDTO.java | 2 +- .../entity/dto/ScenicSpotCommentsDTO.java | 22 +++++++ .../entity/dto/ScenicSpotCommentsUserDTO.java | 31 ++++++++++ .../zm/trip/entity/vo/RelaUserCommentsVO.java | 2 +- 12 files changed, 142 insertions(+), 24 deletions(-) create mode 100644 trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/ScenicSpotCommentsDTO.java create mode 100644 trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/ScenicSpotCommentsUserDTO.java diff --git a/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/BaseUserController.java b/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/BaseUserController.java index f0fb81d..4678202 100644 --- a/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/BaseUserController.java +++ b/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/BaseUserController.java @@ -24,14 +24,14 @@ */ @RequestMapping("baseUser") @RestController -@Api(tags = "基础用户") +@Api(tags = "基础-用户") public class BaseUserController extends BaseController { @Resource private IBaseUserService baseUserService; @GetMapping - @ApiOperation("基础-用户page查询") + @ApiOperation("基础用户page查询") // @ApiImplicitParams({ // @ApiImplicitParam(name = "page", value = "当前页数", defaultValue = "1"), // @ApiImplicitParam(name = "size", value = "每页个数", defaultValue = "10"), diff --git a/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/BusCommentsController.java b/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/BusCommentsController.java index 52ca2b9..f9393aa 100644 --- a/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/BusCommentsController.java +++ b/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/BusCommentsController.java @@ -2,9 +2,20 @@ import cn.zm.common.base.ResResult; import cn.zm.mybatis.base.BaseController; +import cn.zm.trip.entity.BusComments; +import cn.zm.trip.entity.RelaScenicSpotComments; +import cn.zm.trip.entity.RelaUserComments; +import cn.zm.trip.entity.dto.BaseScenicSpotDTO; import cn.zm.trip.entity.dto.BusCommentsDTO; +import cn.zm.trip.entity.dto.ScenicSpotCommentsDTO; +import cn.zm.trip.entity.dto.ScenicSpotCommentsUserDTO; import cn.zm.trip.entity.vo.BusCommentsVO; import cn.zm.trip.service.IBusCommentsService; +import cn.zm.trip.service.IRelaScenicSpotCommentsService; +import cn.zm.trip.service.IRelaUserCommentsService; +import cn.zm.trip.service.IViewScenicSpotCommentsUserService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.ApiImplicitParam; @@ -22,6 +33,8 @@ * @author 十渊 * @since 2022-07-12 */ +@Transactional(rollbackFor = Exception.class) +@Slf4j @RequestMapping("busComments") @RestController @Api(tags = "业务-评论表") @@ -30,6 +43,14 @@ public class BusCommentsController extends BaseController { @Resource private IBusCommentsService busCommentsService; + @Resource + private IRelaScenicSpotCommentsService relaScenicSpotCommentsService; + + + @Resource + private IRelaUserCommentsService relaUserCommentsService; + + @GetMapping @ApiOperation("业务评论表page查询") // @ApiImplicitParams({ @@ -44,17 +65,31 @@ public ResResult> getByPage(@Validated BusCommentsDTO busCo return ResResult.succ(page); } - // @PostMapping("list") - // @ApiOperation("业务评论表list查询") - // @ApiImplicitParams({ - // @ApiImplicitParam(name = "orderByColumn", value = "排序字段"), - // @ApiImplicitParam(name = "isDesc", value = "是否降序") - // }) - // public ResResult> list(@Validated @RequestBody BusCommentsDTO busComments) { - // // TODO 分页查询 - // IPage page = busCommentsService.list(getPage(), busComments); - // return ResResult.succ(page); - // } + @PostMapping("/scenic/spot") + @ApiOperation("业务-用户评论景点") + public ResResult scenicSpotCommentsSave(@RequestBody @Validated ScenicSpotCommentsUserDTO dto) { + // TODO 新增 + BusComments comments = dto.getCommentsDTO().convert(); + BaseScenicSpotDTO scenicSpotDTO = dto.getScenicSpotDTO(); + log.info("评论景点-评论存库"); + busCommentsService.save(comments); + + log.info("评论景点-景点评论关联存库"); + relaScenicSpotCommentsService.save(RelaScenicSpotComments.builder() + .scenicSpotId(scenicSpotDTO.getId()) + .commentsId(comments.getId()) + .build()); + log.info("评论景点-用户评论关联存库"); + + relaUserCommentsService.save( + RelaUserComments.builder() + .commentsId(comments.getId()) + .userId(dto.getUserDTO().getId()) + .build() + ); + + return ResResult.succ("新增成功"); + } @GetMapping("{id}") @ApiOperation("业务评论表查询(id)") diff --git a/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/RelaScenicSpotCommentsController.java b/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/RelaScenicSpotCommentsController.java index 8cf947a..737d205 100644 --- a/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/RelaScenicSpotCommentsController.java +++ b/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/RelaScenicSpotCommentsController.java @@ -2,9 +2,19 @@ import cn.zm.common.base.ResResult; import cn.zm.mybatis.base.BaseController; +import cn.zm.trip.entity.BaseScenicSpot; +import cn.zm.trip.entity.BusComments; +import cn.zm.trip.entity.RelaScenicSpotComments; +import cn.zm.trip.entity.dto.BaseScenicSpotDTO; +import cn.zm.trip.entity.dto.BusCommentsDTO; import cn.zm.trip.entity.dto.RelaScenicSpotCommentsDTO; +import cn.zm.trip.entity.dto.ScenicSpotCommentsDTO; import cn.zm.trip.entity.vo.RelaScenicSpotCommentsVO; +import cn.zm.trip.service.IBaseScenicSpotService; +import cn.zm.trip.service.IBusCommentsService; import cn.zm.trip.service.IRelaScenicSpotCommentsService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.ApiImplicitParam; @@ -22,16 +32,24 @@ * @author 十渊 * @since 2022-07-12 */ +@Slf4j +@Transactional(rollbackFor = Exception.class) @RequestMapping("relaScenicSpotComments") @RestController -@Api(tags = "关联景区评论关联表") +@Api(tags = "关联-关联景区评论关联表") public class RelaScenicSpotCommentsController extends BaseController { @Resource private IRelaScenicSpotCommentsService relaScenicSpotCommentsService; + @Resource + private IBaseScenicSpotService baseScenicSpotService; + + @Resource + private IBusCommentsService busCommentsService; + @GetMapping - @ApiOperation("关联-景区评论关联表page查询") + @ApiOperation("关联景区评论关联表page查询") public ResResult> getByPage(@Validated RelaScenicSpotCommentsDTO relaScenicSpotComments) { // TODO 分页查询 IPage page = relaScenicSpotCommentsService.selectByPage(getPage(), relaScenicSpotComments); @@ -60,9 +78,9 @@ public ResResult get(@PathVariable String id) { @PostMapping @ApiOperation("关联景区评论关联表新增") - public ResResult add(@RequestBody @Validated RelaScenicSpotCommentsDTO relaScenicSpotComments) { + public ResResult add(@RequestBody @Validated RelaScenicSpotCommentsDTO dto) { // TODO 新增 - relaScenicSpotCommentsService.save(relaScenicSpotComments.convert()); + relaScenicSpotCommentsService.save(dto.convert()); return ResResult.succ("新增成功"); } diff --git a/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/RelaUserCommentsController.java b/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/RelaUserCommentsController.java index 1c567a7..ab9be42 100644 --- a/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/RelaUserCommentsController.java +++ b/trip-web-server/trip-web-api/src/main/java/cn/zm/trip/restful/RelaUserCommentsController.java @@ -24,14 +24,14 @@ */ @RequestMapping("relaUserComments") @RestController -@Api(tags = "关联用户评论表") +@Api(tags = "关联-用户评论表") public class RelaUserCommentsController extends BaseController { @Resource private IRelaUserCommentsService relaUserCommentsService; @GetMapping - @ApiOperation("关联-用户评论表page查询") + @ApiOperation("关联用户评论表page查询") // @ApiImplicitParams({ // @ApiImplicitParam(name = "page", value = "当前页数", defaultValue = "1"), // @ApiImplicitParam(name = "size", value = "每页个数", defaultValue = "10"), diff --git a/trip-web-server/trip-web-api/src/main/resources/trip_web-202207071536.sql b/trip-web-server/trip-web-api/src/main/resources/trip_web-202207071536.sql index 8c48418..7974418 100644 --- a/trip-web-server/trip-web-api/src/main/resources/trip_web-202207071536.sql +++ b/trip-web-server/trip-web-api/src/main/resources/trip_web-202207071536.sql @@ -130,7 +130,7 @@ DROP TABLE IF EXISTS `rela_user_comments`; CREATE TABLE `rela_user_comments` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `user_id` bigint(20) DEFAULT NULL COMMENT '用户id', - `comments_id` text COMMENT '评论id', + `comments_id` bigint(20) COMMENT '评论id', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='关联用户评论表'; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/trip-web-server/trip-web-api/target/classes/trip_web-202207071536.sql b/trip-web-server/trip-web-api/target/classes/trip_web-202207071536.sql index 8c48418..7974418 100644 --- a/trip-web-server/trip-web-api/target/classes/trip_web-202207071536.sql +++ b/trip-web-server/trip-web-api/target/classes/trip_web-202207071536.sql @@ -130,7 +130,7 @@ DROP TABLE IF EXISTS `rela_user_comments`; CREATE TABLE `rela_user_comments` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `user_id` bigint(20) DEFAULT NULL COMMENT '用户id', - `comments_id` text COMMENT '评论id', + `comments_id` bigint(20) COMMENT '评论id', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='关联用户评论表'; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/RelaScenicSpotComments.java b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/RelaScenicSpotComments.java index a1aecc1..c60266f 100644 --- a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/RelaScenicSpotComments.java +++ b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/RelaScenicSpotComments.java @@ -7,11 +7,17 @@ import cn.zm.mybatis.utils.ObjectConvert; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import lombok.experimental.Accessors; @Data @Accessors(chain = true) +@Builder +@AllArgsConstructor +@NoArgsConstructor @TableName("rela_scenic_spot_comments") @ApiModel(value="RelaScenicSpotComments对象", description="关联景区评论关联表") public class RelaScenicSpotComments extends ObjectConvert{ diff --git a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/RelaUserComments.java b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/RelaUserComments.java index 148ed54..d20d8ce 100644 --- a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/RelaUserComments.java +++ b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/RelaUserComments.java @@ -7,10 +7,16 @@ import cn.zm.mybatis.utils.ObjectConvert; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import lombok.experimental.Accessors; @Data +@Builder +@AllArgsConstructor +@NoArgsConstructor @Accessors(chain = true) @TableName("rela_user_comments") @ApiModel(value="RelaUserComments对象", description="关联用户评论表") @@ -21,6 +27,6 @@ public class RelaUserComments extends ObjectConvert{ @ApiModelProperty(value = "用户id") private Long userId; @ApiModelProperty(value = "评论id") - private String commentsId; + private Long commentsId; } diff --git a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/RelaUserCommentsDTO.java b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/RelaUserCommentsDTO.java index 4ce9b9e..f0dd72e 100644 --- a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/RelaUserCommentsDTO.java +++ b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/RelaUserCommentsDTO.java @@ -21,6 +21,6 @@ public class RelaUserCommentsDTO extends ObjectConvert{ @ApiModelProperty(value = "用户id") private Long userId; @ApiModelProperty(value = "评论id") - private String commentsId; + private Long commentsId; } diff --git a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/ScenicSpotCommentsDTO.java b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/ScenicSpotCommentsDTO.java new file mode 100644 index 0000000..38b184c --- /dev/null +++ b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/ScenicSpotCommentsDTO.java @@ -0,0 +1,22 @@ +package cn.zm.trip.entity.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.Valid; + +@Data +@Accessors(chain = true) +@ApiModel(value="ScenicSpotCommentsDTO对象", description="业务-景区评论关联实体") +public class ScenicSpotCommentsDTO { + @ApiModelProperty(value = "基础-景点") + @Valid + private BaseScenicSpotDTO scenicSpotDTO; + + @Valid + @ApiModelProperty(value = "业务-评论") + private BusCommentsDTO commentsDTO; +} + diff --git a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/ScenicSpotCommentsUserDTO.java b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/ScenicSpotCommentsUserDTO.java new file mode 100644 index 0000000..1aaddcc --- /dev/null +++ b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/dto/ScenicSpotCommentsUserDTO.java @@ -0,0 +1,31 @@ +package cn.zm.trip.entity.dto; + +import cn.zm.mybatis.utils.ObjectConvert; +import cn.zm.trip.entity.ViewScenicSpotCommentsUser; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.Valid; + +@Data +@Accessors(chain = true) +@ApiModel(value="ScenicSpotCommentsUserDTO对象") +public class ScenicSpotCommentsUserDTO { + @ApiModelProperty(value = "基础-用户") + @Valid + private BaseUserDTO userDTO; + + @ApiModelProperty(value = "基础-景点") + @Valid + private BaseScenicSpotDTO scenicSpotDTO; + + @Valid + @ApiModelProperty(value = "业务-评论") + private BusCommentsDTO commentsDTO; + + +} + diff --git a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/vo/RelaUserCommentsVO.java b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/vo/RelaUserCommentsVO.java index 348bbfc..4f24b61 100644 --- a/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/vo/RelaUserCommentsVO.java +++ b/trip-web-server/trip-web-entity/src/main/java/cn/zm/trip/entity/vo/RelaUserCommentsVO.java @@ -20,6 +20,6 @@ public class RelaUserCommentsVO { @ApiModelProperty(value = "用户id") private Long userId; @ApiModelProperty(value = "评论id") - private String commentsId; + private Long commentsId; }