From d1d2e5ed65cfa15d2a0379e3b8bc08839d2b3f6e Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 26 Apr 2022 10:13:49 +0800 Subject: [PATCH] ... --- .../controller/TDemandCommentController.java | 54 +++++++++++-------- .../impl/TDemandCommentServiceImpl.java | 10 ++-- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/demandComment/controller/TDemandCommentController.java b/renren-admin/src/main/java/io/renren/modules/demandComment/controller/TDemandCommentController.java index dd40d96f..291ffc90 100644 --- a/renren-admin/src/main/java/io/renren/modules/demandComment/controller/TDemandCommentController.java +++ b/renren-admin/src/main/java/io/renren/modules/demandComment/controller/TDemandCommentController.java @@ -10,6 +10,8 @@ import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.demanData.dto.TDemandDataDTO; +import io.renren.modules.demanData.service.TDemandDataService; import io.renren.modules.demandComment.dto.TDemandCommentDTO; import io.renren.modules.demandComment.excel.TDemandCommentExcel; import io.renren.modules.demandComment.service.TDemandCommentService; @@ -28,28 +30,31 @@ import java.util.Map; /** -* 需求评论 -* -* @author wangliwen wangliwen2@hisense.com -* @since 1.0 2022-04-26 -*/ + * 需求评论 + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2022-04-26 + */ @RestController @RequestMapping("demandComment/tdemandcomment") -@Api(tags="需求评论") +@Api(tags = "需求评论") public class TDemandCommentController { @Autowired private TDemandCommentService tDemandCommentService; + @Autowired + private TDemandDataService tDemandDataService; @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "targetId", value = "评论主题id", paramType = "query", dataType = "Long") }) - @RequiresPermissions("demandComment:tdemandcomment:page") - public Result> page(@ApiIgnore @RequestParam Map params){ +// @RequiresPermissions("demandComment:tdemandcomment:page") + public Result> page(@ApiIgnore @RequestParam Map params) { PageData page = tDemandCommentService.page(params); return new Result>().ok(page); @@ -57,8 +62,8 @@ public class TDemandCommentController { @GetMapping("{id}") @ApiOperation("信息") - @RequiresPermissions("demandComment:tdemandcomment:info") - public Result get(@PathVariable("id") Long id){ +// @RequiresPermissions("demandComment:tdemandcomment:info") + public Result get(@PathVariable("id") Long id) { TDemandCommentDTO data = tDemandCommentService.get(id); return new Result().ok(data); @@ -67,11 +72,18 @@ public class TDemandCommentController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - @RequiresPermissions("demandComment:tdemandcomment:save") - public Result save(@RequestBody TDemandCommentDTO dto){ +// @RequiresPermissions("demandComment:tdemandcomment:save") + public Result save(@RequestBody TDemandCommentDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - + TDemandDataDTO dto1 = + tDemandDataService.get(dto.getTargetId()); + if (dto1 == null) { + return new Result().error("该评论主题不存在!"); + } + if (dto1.getFlag() != 3) { + return new Result().error("该评论主题未审批通过!"); + } tDemandCommentService.save(dto); return new Result(); @@ -80,8 +92,8 @@ public class TDemandCommentController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - @RequiresPermissions("demandComment:tdemandcomment:update") - public Result update(@RequestBody TDemandCommentDTO dto){ +// @RequiresPermissions("demandComment:tdemandcomment:update") + public Result update(@RequestBody TDemandCommentDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -93,8 +105,8 @@ public class TDemandCommentController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - @RequiresPermissions("demandComment:tdemandcomment:delete") - public Result delete(@RequestBody Long[] ids){ +// @RequiresPermissions("demandComment:tdemandcomment:delete") + public Result delete(@RequestBody Long[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); diff --git a/renren-admin/src/main/java/io/renren/modules/demandComment/service/impl/TDemandCommentServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/demandComment/service/impl/TDemandCommentServiceImpl.java index 4bdfe690..6812d950 100644 --- a/renren-admin/src/main/java/io/renren/modules/demandComment/service/impl/TDemandCommentServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/demandComment/service/impl/TDemandCommentServiceImpl.java @@ -2,13 +2,10 @@ package io.renren.modules.demandComment.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.renren.common.service.impl.CrudServiceImpl; -import io.renren.common.constant.Constant; import io.renren.modules.demandComment.dao.TDemandCommentDao; import io.renren.modules.demandComment.dto.TDemandCommentDTO; import io.renren.modules.demandComment.entity.TDemandCommentEntity; import io.renren.modules.demandComment.service.TDemandCommentService; -import io.renren.modules.security.user.SecurityUser; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.Map; @@ -23,10 +20,11 @@ import java.util.Map; public class TDemandCommentServiceImpl extends CrudServiceImpl implements TDemandCommentService { @Override - public QueryWrapper getWrapper(Map params){ + public QueryWrapper getWrapper(Map params) { QueryWrapper wrapper = new QueryWrapper<>(); - - + if (params.containsKey("targetId")) { + wrapper.eq("target_id", params.get("targetId")); + } return wrapper; }