diff --git a/src/main/java/com/lz/modules/performance/controller/IndicatorLibraryController.java b/src/main/java/com/lz/modules/performance/controller/IndicatorLibraryController.java index 5e74be16..2cdb0dec 100644 --- a/src/main/java/com/lz/modules/performance/controller/IndicatorLibraryController.java +++ b/src/main/java/com/lz/modules/performance/controller/IndicatorLibraryController.java @@ -7,9 +7,14 @@ import com.lz.common.utils.PageUtils; import com.lz.common.utils.R; import com.lz.common.utils.StringUtil; import com.lz.modules.performance.dto.IndicatorLibraryDto; +import com.lz.modules.performance.dto.IndicatorLibraryMoveDto; import com.lz.modules.performance.entity.IndicatorLibrary; import com.lz.modules.performance.req.IndicatorLibraryReq; import com.lz.modules.performance.service.IndicatorLibraryService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -17,8 +22,10 @@ import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.Map; +@Slf4j @RestController @RequestMapping("/indicatorLibrary") +@Api(value = "指标相关接口", tags = { "指标相关接口" }) public class IndicatorLibraryController { @@ -27,6 +34,7 @@ public class IndicatorLibraryController { @PostMapping("/list") + @ApiOperation("获取指标列表") public R list(@RequestBody IndicatorLibraryReq req) { PageUtils page = indicatorLibraryService.selectIndicatorLibrarysByReq(req); return R.ok().put("data",page); @@ -34,7 +42,8 @@ public class IndicatorLibraryController { @GetMapping("/getById") - public R getById(@Param("id")Long id) { + @ApiOperation("获取指标") + public R getById(@RequestParam @ApiParam(value = "获取指标id",name = "id")Long id) { IndicatorLibrary indicatorLibrary = indicatorLibraryService.selectIndicatorLibraryById(id); IndicatorLibraryDto dto = new IndicatorLibraryDto(); BeanUtil.copyProperties(indicatorLibrary,dto); @@ -44,7 +53,8 @@ public class IndicatorLibraryController { @PostMapping("/saveOrUpdate") - public R save(@RequestBody IndicatorLibraryDto dto) { + @ApiOperation("保存/修改指标") + public R save(@RequestBody IndicatorLibraryDto dto) { IndicatorLibrary indicatorLibrary = new IndicatorLibrary(); BeanUtil.copyProperties(dto,indicatorLibrary); boolean success = indicatorLibraryService.saveOrUpdate(indicatorLibrary); @@ -56,8 +66,27 @@ public class IndicatorLibraryController { @GetMapping("/delete") - public R delete(@RequestParam String ids) { - indicatorLibraryService.deleteIndicatorLibrarysByIds(ids); + @ApiOperation("删除指标") + public R delete(@RequestParam @ApiParam(value = "指标删除id,逗号隔开",name = "ids") String ids) { + try { + indicatorLibraryService.deleteIndicatorLibrarysByIds(ids); + } catch (Exception e) { + log.error("删除指标异常",e); + return R.error(); + } return R.ok(); } + + + @PostMapping("/move") + @ApiOperation("移动指标") + public R move(@RequestBody IndicatorLibraryMoveDto dto) { + try { + indicatorLibraryService.updateIndicatorLibrarysMove(dto); + } catch (Exception e) { + log.error("移动指标异常",e); + return R.error(); + } + return R.ok(); + } } diff --git a/src/main/java/com/lz/modules/performance/controller/IndicatorTypeController.java b/src/main/java/com/lz/modules/performance/controller/IndicatorTypeController.java index 9cb1d485..5c67bab6 100644 --- a/src/main/java/com/lz/modules/performance/controller/IndicatorTypeController.java +++ b/src/main/java/com/lz/modules/performance/controller/IndicatorTypeController.java @@ -4,17 +4,22 @@ package com.lz.modules.performance.controller; import cn.hutool.core.bean.BeanUtil; import com.lz.common.utils.PageUtils; import com.lz.common.utils.R; +import com.lz.common.utils.StringUtil; import com.lz.modules.performance.dto.IndicatorTypeDto; import com.lz.modules.performance.entity.IndicatorType; import com.lz.modules.performance.req.IndicatorReq; import com.lz.modules.performance.service.IndicatorTypeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/indicatorType") +@Api(value = "指标分类相关接口", tags = { "指标分类相关接口" }) public class IndicatorTypeController { @@ -22,7 +27,8 @@ public class IndicatorTypeController { private IndicatorTypeService indicatorTypeService; - @RequestMapping("/list") + @PostMapping("/list") + @ApiOperation("获取分类/类型列表") public R list(@RequestBody IndicatorReq req) { PageUtils page = indicatorTypeService.selectIndicatorTypesByReq(req); return R.ok().put("data", page); @@ -30,8 +36,18 @@ public class IndicatorTypeController { - @RequestMapping("/saveOrUpdate") + @ApiOperation("保存/修改分类") + @PostMapping("/saveOrUpdate") public R save(@RequestBody IndicatorTypeDto dto) { + if(dto.getId()==null){ + if(StringUtil.isBlank(dto.getName())){ + return R.error("分类名称不能为空"); + } + IndicatorType indicatorType = indicatorTypeService.selectIndicatorTypeByName(dto.getName()); + if(indicatorType!=null){ + return R.error("分类名称重复"); + } + } IndicatorType indicatorType = new IndicatorType(); BeanUtil.copyProperties(dto,indicatorType); boolean success = indicatorTypeService.saveOrUpdate(indicatorType); diff --git a/src/main/java/com/lz/modules/performance/dao/IndicatorLibraryMapper.java b/src/main/java/com/lz/modules/performance/dao/IndicatorLibraryMapper.java index bfd2d7d8..a3729213 100644 --- a/src/main/java/com/lz/modules/performance/dao/IndicatorLibraryMapper.java +++ b/src/main/java/com/lz/modules/performance/dao/IndicatorLibraryMapper.java @@ -39,4 +39,6 @@ public interface IndicatorLibraryMapper extends BaseMapper { void deleteIndicatorLibrarysByIds(@Param("ids") List ids); + void updateIndicatorLibrarysMove(@Param("ids")List ids,@Param("indicatorType")Long indicatorType); + } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/dao/IndicatorTypeMapper.java b/src/main/java/com/lz/modules/performance/dao/IndicatorTypeMapper.java index cec45492..b4f7aec4 100644 --- a/src/main/java/com/lz/modules/performance/dao/IndicatorTypeMapper.java +++ b/src/main/java/com/lz/modules/performance/dao/IndicatorTypeMapper.java @@ -38,6 +38,7 @@ public interface IndicatorTypeMapper extends BaseMapper { List selectIndicatorTypesByReq(@Param("page") IPage page, @Param("req")IndicatorReq req); + IndicatorType selectIndicatorTypeByName(@Param("name") String name); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryDto.java b/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryDto.java index 3755afa9..6f7f0171 100644 --- a/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryDto.java +++ b/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryDto.java @@ -2,7 +2,9 @@ package com.lz.modules.performance.dto; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import java.math.BigDecimal; @@ -11,6 +13,8 @@ import java.math.BigDecimal; * @Desc: * @Date: 2021/1/12 14:41 */ +@Data +@ApiModel("指标保存/修改实体") public class IndicatorLibraryDto { // @TableId(value = "id", type = IdType.AUTO) diff --git a/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryMoveDto.java b/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryMoveDto.java new file mode 100644 index 00000000..4b446658 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryMoveDto.java @@ -0,0 +1,21 @@ +package com.lz.modules.performance.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: djc + * @Desc: + * @Date: 2021/1/13 11:38 + */ +@Data +@ApiModel("移动指标实体") +public class IndicatorLibraryMoveDto { + @ApiModelProperty(value = "移动的id,逗号隔开",name = "ids") + private String ids; + + @ApiModelProperty(value = "要移动的目标分类",name = "indicatorType") + private Long indicatorType; + +} diff --git a/src/main/java/com/lz/modules/performance/dto/IndicatorTypeDto.java b/src/main/java/com/lz/modules/performance/dto/IndicatorTypeDto.java index a4dc3542..3dbca138 100644 --- a/src/main/java/com/lz/modules/performance/dto/IndicatorTypeDto.java +++ b/src/main/java/com/lz/modules/performance/dto/IndicatorTypeDto.java @@ -1,5 +1,6 @@ package com.lz.modules.performance.dto; +import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,6 +10,7 @@ import lombok.Data; * @Date: 2021/1/12 10:21 */ @Data +@ApiModel("保存/修改分类实体") public class IndicatorTypeDto { @ApiModelProperty(value = "id", name = "id") @@ -16,6 +18,9 @@ public class IndicatorTypeDto { //指标名称 @ApiModelProperty(value = "指标分类名称", name = "name") private String name; + //指标名称 + @ApiModelProperty(value = "类型0: 指标分类 1:指标类型", name = "type") + private Integer type; //排序 @ApiModelProperty(value = "排序(非必须)", name = "orderBy") private Integer orderBy; diff --git a/src/main/java/com/lz/modules/performance/req/IndicatorLibraryReq.java b/src/main/java/com/lz/modules/performance/req/IndicatorLibraryReq.java index 2169e519..85d27fe3 100644 --- a/src/main/java/com/lz/modules/performance/req/IndicatorLibraryReq.java +++ b/src/main/java/com/lz/modules/performance/req/IndicatorLibraryReq.java @@ -2,6 +2,7 @@ package com.lz.modules.performance.req; import com.fasterxml.jackson.databind.ser.Serializers; import com.lz.modules.equipment.entity.model.BasePage; +import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -11,6 +12,7 @@ import lombok.Data; * @Date: 2021/1/12 14:50 */ @Data +@ApiModel("获取指标列表实体") public class IndicatorLibraryReq extends BasePage{ //指标名称 @ApiModelProperty(value = "指标名称", name = "name") diff --git a/src/main/java/com/lz/modules/performance/req/IndicatorReq.java b/src/main/java/com/lz/modules/performance/req/IndicatorReq.java index a53b6e3b..7cf8abf5 100644 --- a/src/main/java/com/lz/modules/performance/req/IndicatorReq.java +++ b/src/main/java/com/lz/modules/performance/req/IndicatorReq.java @@ -1,6 +1,7 @@ package com.lz.modules.performance.req; import com.lz.modules.equipment.entity.model.BasePage; +import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -10,6 +11,7 @@ import lombok.Data; * @Date: 2021/1/12 11:39 */ @Data +@ApiModel("获取分类/类型实体") public class IndicatorReq extends BasePage{ //指标名称 @ApiModelProperty(value = "指标分类名称", name = "name") diff --git a/src/main/java/com/lz/modules/performance/service/IndicatorLibraryService.java b/src/main/java/com/lz/modules/performance/service/IndicatorLibraryService.java index 0f49f82d..a4e61b5b 100644 --- a/src/main/java/com/lz/modules/performance/service/IndicatorLibraryService.java +++ b/src/main/java/com/lz/modules/performance/service/IndicatorLibraryService.java @@ -2,6 +2,7 @@ package com.lz.modules.performance.service; import com.baomidou.mybatisplus.extension.service.IService; import com.lz.common.utils.PageUtils; +import com.lz.modules.performance.dto.IndicatorLibraryMoveDto; import com.lz.modules.performance.entity.IndicatorLibrary; import com.lz.modules.performance.req.IndicatorLibraryReq; @@ -35,5 +36,7 @@ public interface IndicatorLibraryService extends IService { void deleteIndicatorLibrarysByIds(String ids); + void updateIndicatorLibrarysMove(IndicatorLibraryMoveDto dto); + } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/service/IndicatorTypeService.java b/src/main/java/com/lz/modules/performance/service/IndicatorTypeService.java index 84705fb3..f652ec99 100644 --- a/src/main/java/com/lz/modules/performance/service/IndicatorTypeService.java +++ b/src/main/java/com/lz/modules/performance/service/IndicatorTypeService.java @@ -33,5 +33,7 @@ public interface IndicatorTypeService extends IService { PageUtils selectIndicatorTypesByReq(IndicatorReq req); + IndicatorType selectIndicatorTypeByName(String name); + } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/service/impl/IndicatorLibraryServiceImpl.java b/src/main/java/com/lz/modules/performance/service/impl/IndicatorLibraryServiceImpl.java index 34f811bc..040009bf 100644 --- a/src/main/java/com/lz/modules/performance/service/impl/IndicatorLibraryServiceImpl.java +++ b/src/main/java/com/lz/modules/performance/service/impl/IndicatorLibraryServiceImpl.java @@ -1,9 +1,11 @@ package com.lz.modules.performance.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; import com.lz.common.utils.PageUtils; import com.lz.common.utils.StringUtil; import com.lz.modules.performance.dao.IndicatorLibraryMapper; +import com.lz.modules.performance.dto.IndicatorLibraryMoveDto; import com.lz.modules.performance.entity.IndicatorLibrary; import com.lz.modules.performance.req.IndicatorLibraryReq; import com.lz.modules.performance.service.IndicatorLibraryService; @@ -12,6 +14,7 @@ import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Arrays; import java.util.List; /** @@ -83,4 +86,16 @@ public class IndicatorLibraryServiceImpl extends ServiceImpl select id ,name,type,indicator_type, weight, key_result, sort from lz_indicator_library - where name LIKE CONCAT('%',#{req.name},'%') and indicator_type = #{req.indicatorType} and is_delete = 0 order by sort + where is_delete = 0 + + and name LIKE CONCAT('%',#{req.name},'%') + + + and indicator_type = #{req.indicatorType} + + order by sort @@ -105,6 +112,15 @@ ) + + update lz_indicator_library set indicator_type = #{indicatorType} where is_delete = 0 AND + id in + ( + + #{id} + + ) + diff --git a/src/main/resources/mapper/performance/IndicatorTypeMapper.xml b/src/main/resources/mapper/performance/IndicatorTypeMapper.xml index ec89a785..ec5fa83f 100644 --- a/src/main/resources/mapper/performance/IndicatorTypeMapper.xml +++ b/src/main/resources/mapper/performance/IndicatorTypeMapper.xml @@ -80,7 +80,18 @@ + +