diff --git a/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectContribController.java b/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectContribController.java index e5b396ef..4ef98c37 100644 --- a/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectContribController.java +++ b/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectContribController.java @@ -46,9 +46,11 @@ public class TbProjectContribController { @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.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "resourceName", value = "应用名称", paramType = "query", dataType="String") }) - @RequiresPermissions("project:tbprojectcontrib:page") +// @RequiresPermissions("project:tbprojectcontrib:page") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = tbProjectContribService.page(params); @@ -57,7 +59,7 @@ public class TbProjectContribController { @GetMapping("{id}") @ApiOperation("信息") - @RequiresPermissions("project:tbprojectcontrib:info") +// @RequiresPermissions("project:tbprojectcontrib:info") public Result get(@PathVariable("id") Long id){ TbProjectContribDTO data = tbProjectContribService.get(id); @@ -67,7 +69,7 @@ public class TbProjectContribController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - @RequiresPermissions("project:tbprojectcontrib:save") +// @RequiresPermissions("project:tbprojectcontrib:save") public Result save(@RequestBody TbProjectContribDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); @@ -80,7 +82,7 @@ public class TbProjectContribController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - @RequiresPermissions("project:tbprojectcontrib:update") +// @RequiresPermissions("project:tbprojectcontrib:update") public Result update(@RequestBody TbProjectContribDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -93,7 +95,7 @@ public class TbProjectContribController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - @RequiresPermissions("project:tbprojectcontrib:delete") +// @RequiresPermissions("project:tbprojectcontrib:delete") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -106,7 +108,7 @@ public class TbProjectContribController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @RequiresPermissions("project:tbprojectcontrib:export") +// @RequiresPermissions("project:tbprojectcontrib:export") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = tbProjectContribService.list(params); diff --git a/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectController.java b/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectController.java index ba5812d0..17392c76 100644 --- a/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectController.java +++ b/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectController.java @@ -46,9 +46,13 @@ public class TbProjectController { @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.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "applyDep", value = "申请单位", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "respDep", value = "责任处室", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "applyTime", value = "申请日期", paramType = "query", dataType="String") }) - @RequiresPermissions("project:tbproject:page") +// @RequiresPermissions("project:tbproject:page") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = tbProjectService.page(params); @@ -57,7 +61,7 @@ public class TbProjectController { @GetMapping("{id}") @ApiOperation("信息") - @RequiresPermissions("project:tbproject:info") +// @RequiresPermissions("project:tbproject:info") public Result get(@PathVariable("id") Long id){ TbProjectDTO data = tbProjectService.get(id); @@ -67,7 +71,7 @@ public class TbProjectController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - @RequiresPermissions("project:tbproject:save") +// @RequiresPermissions("project:tbproject:save") public Result save(@RequestBody TbProjectDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); @@ -80,7 +84,7 @@ public class TbProjectController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - @RequiresPermissions("project:tbproject:update") +// @RequiresPermissions("project:tbproject:update") public Result update(@RequestBody TbProjectDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -93,7 +97,7 @@ public class TbProjectController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - @RequiresPermissions("project:tbproject:delete") +// @RequiresPermissions("project:tbproject:delete") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -106,7 +110,7 @@ public class TbProjectController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @RequiresPermissions("project:tbproject:export") +// @RequiresPermissions("project:tbproject:export") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = tbProjectService.list(params); diff --git a/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectUseController.java b/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectUseController.java index c943f87b..112317cc 100644 --- a/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectUseController.java +++ b/renren-admin/src/main/java/io/renren/modules/project/controller/TbProjectUseController.java @@ -46,9 +46,11 @@ public class TbProjectUseController { @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.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "resourceName", value = "应用名称", paramType = "query", dataType="String") }) - @RequiresPermissions("project:tbprojectuse:page") +// @RequiresPermissions("project:tbprojectuse:page") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = tbProjectUseService.page(params); @@ -57,7 +59,7 @@ public class TbProjectUseController { @GetMapping("{id}") @ApiOperation("信息") - @RequiresPermissions("project:tbprojectuse:info") +// @RequiresPermissions("project:tbprojectuse:info") public Result get(@PathVariable("id") Long id){ TbProjectUseDTO data = tbProjectUseService.get(id); @@ -67,7 +69,7 @@ public class TbProjectUseController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - @RequiresPermissions("project:tbprojectuse:save") +// @RequiresPermissions("project:tbprojectuse:save") public Result save(@RequestBody TbProjectUseDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); @@ -80,7 +82,7 @@ public class TbProjectUseController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - @RequiresPermissions("project:tbprojectuse:update") +// @RequiresPermissions("project:tbprojectuse:update") public Result update(@RequestBody TbProjectUseDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -93,7 +95,7 @@ public class TbProjectUseController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - @RequiresPermissions("project:tbprojectuse:delete") +// @RequiresPermissions("project:tbprojectuse:delete") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -106,7 +108,7 @@ public class TbProjectUseController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @RequiresPermissions("project:tbprojectuse:export") +// @RequiresPermissions("project:tbprojectuse:export") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = tbProjectUseService.list(params); diff --git a/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectContribServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectContribServiceImpl.java index 7047662d..310700f1 100644 --- a/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectContribServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectContribServiceImpl.java @@ -26,6 +26,12 @@ public class TbProjectContribServiceImpl extends CrudServiceImpl getWrapper(Map params){ QueryWrapper wrapper = new QueryWrapper<>(); + if(params.containsKey("projectName") && StringUtils.isNotBlank(params.get("projectName").toString())){ + wrapper.like("project_name",params.get("projectName")); + } + if(params.containsKey("resourceName") && StringUtils.isNotBlank(params.get("resourceName").toString())){ + wrapper.like("resource_name",params.get("resourceName")); + } return wrapper; } diff --git a/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectServiceImpl.java index 064adc22..085f06a1 100644 --- a/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectServiceImpl.java @@ -26,6 +26,18 @@ public class TbProjectServiceImpl extends CrudServiceImpl getWrapper(Map params){ QueryWrapper wrapper = new QueryWrapper<>(); + if(params.containsKey("projectName") && StringUtils.isNotBlank(params.get("projectName").toString())){ + wrapper.like("project_name",params.get("projectName")); + } + if(params.containsKey("applyDep") && StringUtils.isNotBlank(params.get("applyDep").toString())){ + wrapper.like("apply_dep",params.get("applyDep")); + } + if(params.containsKey("respDep") && StringUtils.isNotBlank(params.get("respDep").toString())){ + wrapper.like("resp_dep",params.get("respDep")); + } + if(params.containsKey("applyTime") && StringUtils.isNotBlank(params.get("applyTime").toString())){ + wrapper.apply("DATE_FORMAT(apply_time,'%Y-%m-%d') = {0}",params.get("applyTime").toString()); + } return wrapper; } diff --git a/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectUseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectUseServiceImpl.java index 24c6f6bb..5b5f59ce 100644 --- a/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectUseServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/project/service/impl/TbProjectUseServiceImpl.java @@ -26,6 +26,12 @@ public class TbProjectUseServiceImpl extends CrudServiceImpl getWrapper(Map params){ QueryWrapper wrapper = new QueryWrapper<>(); + if(params.containsKey("projectName") && StringUtils.isNotBlank(params.get("projectName").toString())){ + wrapper.like("project_name",params.get("projectName")); + } + if(params.containsKey("resourceName") && StringUtils.isNotBlank(params.get("resourceName").toString())){ + wrapper.like("resource_name",params.get("resourceName")); + } return wrapper; } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/TbDataResourceRelController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/TbDataResourceRelController.java new file mode 100644 index 00000000..5b2b05ac --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/TbDataResourceRelController.java @@ -0,0 +1,146 @@ +package io.renren.modules.resource.controller; + +import com.alibaba.fastjson.JSONObject; +import io.renren.common.annotation.LogOperation; +import io.renren.common.constant.Constant; +import io.renren.common.page.PageData; +import io.renren.common.utils.ExcelUtils; +import io.renren.common.utils.Result; +import io.renren.common.validator.AssertUtils; +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.resource.dto.TbDataResourceRelDTO; +import io.renren.modules.resource.excel.TbDataResourceRelExcel; +import io.renren.modules.resource.service.TbDataResourceRelService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** +* 组件-应用资源关系表 +* +* @author Mark sunlightcs@gmail.com +* @since 3.0 2022-06-21 +*/ +@RestController +@RequestMapping("/dataResourceRel") +@Api(tags="组件-应用资源关系表") +public class TbDataResourceRelController { + @Autowired + private TbDataResourceRelService tbDataResourceRelService; + + @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") + }) +// @RequiresPermissions("dataResourceRel:tbdataresourcerel:page") + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = tbDataResourceRelService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("/select/{id}") + @ApiOperation("信息") +// @RequiresPermissions("dataResourceRel:tbdataresourcerel:info") + public Result get(@PathVariable("id") Long id){ + TbDataResourceRelDTO data = tbDataResourceRelService.get(id); + + return new Result().ok(data); + } + + @PostMapping("/insert") + @ApiOperation("保存") + @LogOperation("保存") +// @RequiresPermissions("dataResourceRel:tbdataresourcerel:save") + public Result save(@RequestBody TbDataResourceRelDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + tbDataResourceRelService.save(dto); + + return new Result(); + } + + @PutMapping("/ubdate") + @ApiOperation("修改") + @LogOperation("修改") +// @RequiresPermissions("dataResourceRel:tbdataresourcerel:update") + public Result update(@RequestBody TbDataResourceRelDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + tbDataResourceRelService.update(dto); + + return new Result(); + } + + @DeleteMapping("/delete") + @ApiOperation("删除") + @LogOperation("删除") +// @RequiresPermissions("dataResourceRel:tbdataresourcerel:delete") + public Result delete(@RequestBody Long[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + tbDataResourceRelService.delete(ids); + + return new Result(); + } + + @GetMapping("/export") + @ApiOperation("导出") + @LogOperation("导出") +// @RequiresPermissions("dataResourceRel:tbdataresourcerel:export") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = tbDataResourceRelService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, "组件-应用资源关系表", list, TbDataResourceRelExcel.class); + } + + @GetMapping("/queryApplicationRelByResourceId") + @ApiOperation("根据资源id查询应用关联情况") + @LogOperation("根据资源id查询应用关联情况") + public Result queryApplicationRelByResourceId(@RequestParam("referenceId") Long referenceId, + @RequestParam(value = "keyName",required = false) String keyName){ + Object data = tbDataResourceRelService.queryApplicationRelByResourceId(referenceId,keyName); + + return new Result().ok(data); + } + + @GetMapping("/queryResourceRelByKeyId") + @ApiOperation("根据应用id和资源类型查询资源管理情况") + @LogOperation("根据应用id和资源类型查询资源管理情况") + public Result queryResourceRelByKeyId(@RequestParam("keyId") Long keyId, + @RequestParam("type") String type, + @RequestParam(value = "referenceName" ,required = false) String referenceName){ + Object data = tbDataResourceRelService.queryResourceRelByKeyId(keyId,type,referenceName); + + return new Result().ok(data); + } + + @PostMapping("/saveDataResourceRel") + @ApiOperation("保存应用与组件的关联关系") + @LogOperation("保存应用与组件的关联关系") + public Result saveDataResourceRel(@RequestBody JSONObject param){ + Object data = tbDataResourceRelService.saveDataResourceRel(param); + + return new Result().ok(data); + } +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dao/TbDataResourceRelDao.java b/renren-admin/src/main/java/io/renren/modules/resource/dao/TbDataResourceRelDao.java new file mode 100644 index 00000000..f68d3530 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/dao/TbDataResourceRelDao.java @@ -0,0 +1,36 @@ +package io.renren.modules.resource.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.resource.entity.TbDataResourceRelEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** +* 组件-应用资源关系表 +* +* @author Mark sunlightcs@gmail.com +* @since 3.0 2022-06-21 +*/ +@Mapper +public interface TbDataResourceRelDao extends BaseDao { + + List getAlreadLinkedApplication(@Param("referenceId") Long referenceId,@Param("keyName") String keyName); + + List getNotLinkedApplication(@Param("referenceId")Long referenceId,@Param("keyName") String keyName); + + List getAlreadLinkedResource(@Param("keyId")Long keyId,@Param("type") String type,@Param("referenceName") String referenceName); + + List getNotLinkedResource(@Param("keyId")Long keyId,@Param("type") String type,@Param("referenceName") String referenceName); + + void deleteAllByKeyId(@Param("keyId")Long id, @Param("userId") Long userId,@Param("updateDate") Date updateDate); + + void deleteAllByreferenceId(@Param("referenceId")Long id, @Param("userId")Long userId,@Param("updateDate")Date updateDate); + + List getAlreadLinkedProject(@Param("keyId")Long keyId,@Param("projectName") String projectName); + + List getNotLinkedProject(@Param("keyId")Long keyId,@Param("projectName") String projectName); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dto/TbDataResourceRelDTO.java b/renren-admin/src/main/java/io/renren/modules/resource/dto/TbDataResourceRelDTO.java new file mode 100644 index 00000000..9afca57a --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/dto/TbDataResourceRelDTO.java @@ -0,0 +1,44 @@ +package io.renren.modules.resource.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* 组件-应用资源关系表 +* +* @author Mark sunlightcs@gmail.com +* @since 3.0 2022-06-21 +*/ +@Data +@ApiModel(value = "组件-应用资源关系表") +public class TbDataResourceRelDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "应用资源id") + private Long keyId; + @ApiModelProperty(value = "关联id") + private Long referenceId; + @ApiModelProperty(value = "删除标志:0:正常;1:已删除;2:待审核;3:审核中;9其他") + private Integer delFlag; + @ApiModelProperty(value = "创建人") + private Long creator; + @ApiModelProperty(value = "创建时间") + private Date createDate; + @ApiModelProperty(value = "修改人") + private Long updater; + @ApiModelProperty(value = "修改时间") + private Date updateDate; + @ApiModelProperty(value = "id") + private Long id; + + //新增展示字段 + @ApiModelProperty(value = "应用资源名称") + private String keyName; + @ApiModelProperty(value = "关联资源名称") + private String referenceName; + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/entity/TbDataResourceRelEntity.java b/renren-admin/src/main/java/io/renren/modules/resource/entity/TbDataResourceRelEntity.java new file mode 100644 index 00000000..a948fc39 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/entity/TbDataResourceRelEntity.java @@ -0,0 +1,62 @@ +package io.renren.modules.resource.entity; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.baomidou.mybatisplus.annotation.*; +import java.util.Date; + +/** + * 组件-应用资源关系表 + * + * @author Mark sunlightcs@gmail.com + * @since 3.0 2022-06-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_data_resource_rel") +public class TbDataResourceRelEntity { + private static final long serialVersionUID = 1L; + + /** + * 应用资源id + */ + private Long keyId; + /** + * 关联id + */ + private Long referenceId; + /** + * 删除标志: +0:正常; +1:已删除; +2:待审核; +3:审核中; +9其他 + */ + private Integer delFlag; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + private Long creator; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createDate; + /** + * 修改人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updater; + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; + /** + * id + */ + @TableId + private Long id; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/excel/TbDataResourceRelExcel.java b/renren-admin/src/main/java/io/renren/modules/resource/excel/TbDataResourceRelExcel.java new file mode 100644 index 00000000..c8a5e672 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/excel/TbDataResourceRelExcel.java @@ -0,0 +1,37 @@ +package io.renren.modules.resource.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; +import java.util.Date; + +/** + * 组件-应用资源关系表 + * + * @author Mark sunlightcs@gmail.com + * @since 3.0 2022-06-21 + */ +@Data +@ContentRowHeight(20) +@HeadRowHeight(20) +@ColumnWidth(25) +public class TbDataResourceRelExcel { + @ExcelProperty(value = "应用资源id", index = 0) + private Long keyId; + @ExcelProperty(value = "关联id", index = 1) + private Long referenceId; + @ExcelProperty(value = "删除标志:0:正常;1:已删除;2:待审核;3:审核中;9其他", index = 2) + private Integer delFlag; + @ExcelProperty(value = "创建人", index = 3) + private Long creator; + @ExcelProperty(value = "创建时间", index = 4) + private Date createDate; + @ExcelProperty(value = "修改人", index = 5) + private Long updater; + @ExcelProperty(value = "修改时间", index = 6) + private Date updateDate; + @ExcelProperty(value = "id", index = 7) + private Long id; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/TbDataResourceRelService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/TbDataResourceRelService.java new file mode 100644 index 00000000..5b5a7f6b --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/TbDataResourceRelService.java @@ -0,0 +1,23 @@ +package io.renren.modules.resource.service; + +import com.alibaba.fastjson.JSONObject; +import io.renren.common.service.CrudService; +import io.renren.modules.resource.dto.TbDataResourceRelDTO; +import io.renren.modules.resource.entity.TbDataResourceRelEntity; + +import java.util.List; + +/** + * 组件-应用资源关系表 + * + * @author Mark sunlightcs@gmail.com + * @since 3.0 2022-06-21 + */ +public interface TbDataResourceRelService extends CrudService { + + Object queryApplicationRelByResourceId(Long referenceId, String keyName); + + Object queryResourceRelByKeyId(Long keyId, String type, String referenceName); + + Object saveDataResourceRel(JSONObject param); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/TbDataResourceRelServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/TbDataResourceRelServiceImpl.java new file mode 100644 index 00000000..1b2d0408 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/TbDataResourceRelServiceImpl.java @@ -0,0 +1,129 @@ +package io.renren.modules.resource.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +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.resource.dao.TbDataResourceRelDao; +import io.renren.modules.resource.dto.TbDataResourceRelDTO; +import io.renren.modules.resource.entity.TbDataResourceRelEntity; +import io.renren.modules.resource.service.TbDataResourceRelService; +import io.renren.modules.security.user.SecurityUser; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 组件-应用资源关系表 + * + * @author Mark sunlightcs@gmail.com + * @since 3.0 2022-06-21 + */ +@Service +public class TbDataResourceRelServiceImpl extends CrudServiceImpl implements TbDataResourceRelService { + + @Autowired + private TbDataResourceRelDao tbDataResourceRelDao; + + + @Override + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + + return wrapper; + } + + + @Override + public Object queryApplicationRelByResourceId(Long referenceId, String keyName) { + Map result = new HashMap<>(); + //查询已关联的应用 + List alreadLinked = tbDataResourceRelDao.getAlreadLinkedApplication(referenceId,keyName); + + //查询未关联的应用 + List notLinked = tbDataResourceRelDao.getNotLinkedApplication(referenceId,keyName); + + result.put("alreadLinked",alreadLinked); + result.put("notLinked",notLinked); + return result; + } + + @Override + public Object queryResourceRelByKeyId(Long keyId, String type, String referenceName) { + Map result = new HashMap<>(); + //查询已关联的应用 + List alreadLinked = new ArrayList<>(); + //查询未关联的应用 + List notLinked = new ArrayList<>(); + switch (type){ + case "项目": + alreadLinked = tbDataResourceRelDao.getAlreadLinkedProject(keyId,referenceName); + notLinked = tbDataResourceRelDao.getNotLinkedProject(keyId,referenceName); + break; + default: + alreadLinked = tbDataResourceRelDao.getAlreadLinkedResource(keyId,type,referenceName); + notLinked = tbDataResourceRelDao.getNotLinkedResource(keyId,type,referenceName); + break; + } + + result.put("alreadLinked",alreadLinked); + result.put("notLinked",notLinked); + return result; + } + + @Override + @Transactional + public Object saveDataResourceRel(JSONObject param) { + //关联类型:1:应用资源关联其他资源;2:其他资源关联应用资源 + String linkType = param.getString("linkType"); + Long id = param.getLong("id"); + List referenceIds = JSONArray.parseArray(param.getString("referenceIds"),Long.class); + + Long userId = SecurityUser.getUser().getId(); + switch (linkType){ + case "1": + //应用资源关联其他资源 + //id为应用资源id,即表中的key_id;referenceIds中为表中的reference_id + //先删除所有已关联的内容 + tbDataResourceRelDao.deleteAllByKeyId(id,userId,new Date()); + //新增关联关系 + if(CollectionUtils.isNotEmpty(referenceIds)){ + List resourceRels = new ArrayList<>(); + for(Long referenceId:referenceIds){ + TbDataResourceRelEntity resourceRel = new TbDataResourceRelEntity(); + resourceRel.setKeyId(id); + resourceRel.setReferenceId(referenceId); + + tbDataResourceRelDao.insert(resourceRel); + } + } + break; + case "2": + //其他资源关联应用资源 + //id为其他资源id,即表中的reference_id,referenceIds中为表中的key_id + //先删除所有已关联的内容 + tbDataResourceRelDao.deleteAllByreferenceId(id,userId,new Date()); + //新增关联关系 + if(CollectionUtils.isNotEmpty(referenceIds)){ + List resourceRels = new ArrayList<>(); + for(Long referenceId:referenceIds){ + TbDataResourceRelEntity resourceRel = new TbDataResourceRelEntity(); + resourceRel.setKeyId(referenceId); + resourceRel.setReferenceId(id); + + tbDataResourceRelDao.insert(resourceRel); + } + } + break; + default: + return "关联类型参数错误,请检查关联类型参数"; + } + return null; + } +} \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resource/TbDataResourceRelDao.xml b/renren-admin/src/main/resources/mapper/resource/TbDataResourceRelDao.xml new file mode 100644 index 00000000..c0a5fa22 --- /dev/null +++ b/renren-admin/src/main/resources/mapper/resource/TbDataResourceRelDao.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + update tb_data_resource_rel set del_flag = 1,updater = #{userId},update_date = #{updateDate} + where key_id = #{keyId} and del_flag = 0 + + + + update tb_data_resource_rel set del_flag = 1,updater = #{userId},update_date = #{updateDate} + where reference_id = #{referenceId} and del_flag = 0 + + + + + + \ No newline at end of file