Skip to content

Commit

Permalink
用户评论景区
Browse files Browse the repository at this point in the history
  • Loading branch information
niziming committed Jul 12, 2022
1 parent 2a1977b commit 7ab7137
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +33,8 @@
* @author 十渊
* @since 2022-07-12
*/
@Transactional(rollbackFor = Exception.class)
@Slf4j
@RequestMapping("busComments")
@RestController
@Api(tags = "业务-评论表")
Expand All @@ -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({
Expand All @@ -44,17 +65,31 @@ public ResResult<IPage<BusCommentsVO>> getByPage(@Validated BusCommentsDTO busCo
return ResResult.succ(page);
}

// @PostMapping("list")
// @ApiOperation("业务评论表list查询")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "orderByColumn", value = "排序字段"),
// @ApiImplicitParam(name = "isDesc", value = "是否降序")
// })
// public ResResult<List<BusCommentsVO>> list(@Validated @RequestBody BusCommentsDTO busComments) {
// // TODO 分页查询
// IPage<BusCommentsVO> 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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<IPage<RelaScenicSpotCommentsVO>> getByPage(@Validated RelaScenicSpotCommentsDTO relaScenicSpotComments) {
// TODO 分页查询
IPage<RelaScenicSpotCommentsVO> page = relaScenicSpotCommentsService.selectByPage(getPage(), relaScenicSpotComments);
Expand Down Expand Up @@ -60,9 +78,9 @@ public ResResult<RelaScenicSpotCommentsVO> 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("新增成功");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RelaScenicSpotCommentsVO>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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="关联用户评论表")
Expand All @@ -21,6 +27,6 @@ public class RelaUserComments extends ObjectConvert<RelaUserCommentsVO>{
@ApiModelProperty(value = "用户id")
private Long userId;
@ApiModelProperty(value = "评论id")
private String commentsId;
private Long commentsId;
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class RelaUserCommentsDTO extends ObjectConvert<RelaUserComments>{
@ApiModelProperty(value = "用户id")
private Long userId;
@ApiModelProperty(value = "评论id")
private String commentsId;
private Long commentsId;
}

Original file line number Diff line number Diff line change
@@ -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;
}

Original file line number Diff line number Diff line change
@@ -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;


}

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public class RelaUserCommentsVO {
@ApiModelProperty(value = "用户id")
private Long userId;
@ApiModelProperty(value = "评论id")
private String commentsId;
private Long commentsId;
}

0 comments on commit 7ab7137

Please sign in to comment.