From d839710432a1ee48d1386680a52b6da2924c7c9c Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Mon, 4 Jul 2022 14:44:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E8=9E=8D=E5=90=88=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/db/V3.0__fuse_add_table.sql | 33 +++ .../fuse/controller/FuseController.java | 90 ++++++++ .../modules/fuse/dao/TbFuseAttrDao.java | 23 ++ .../io/renren/modules/fuse/dao/TbFuseDao.java | 15 ++ .../modules/fuse/dao/TbFuseResourceDao.java | 24 +++ .../modules/fuse/dto/TbFuseAttrDTO.java | 26 +++ .../io/renren/modules/fuse/dto/TbFuseDTO.java | 52 +++++ .../modules/fuse/dto/TbFuseResourceDTO.java | 26 +++ .../modules/fuse/entity/TbFuseAttrEntity.java | 36 ++++ .../modules/fuse/entity/TbFuseEntity.java | 81 +++++++ .../fuse/entity/TbFuseResourceEntity.java | 36 ++++ .../modules/fuse/service/TbFuseService.java | 24 +++ .../fuse/service/impl/TbFuseServiceImpl.java | 200 ++++++++++++++++++ .../resources/db/V3.0__fuse_add_table.sql | 33 +++ .../resources/mapper/fuse/TbFuseAttrDao.xml | 20 ++ .../main/resources/mapper/fuse/TbFuseDao.xml | 6 + .../mapper/fuse/TbFuseResourceDao.xml | 20 ++ 17 files changed, 745 insertions(+) create mode 100644 config/db/V3.0__fuse_add_table.sql create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseAttrDao.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseResourceDao.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseAttrDTO.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseAttrEntity.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java create mode 100644 renren-admin/src/main/resources/db/V3.0__fuse_add_table.sql create mode 100644 renren-admin/src/main/resources/mapper/fuse/TbFuseAttrDao.xml create mode 100644 renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml create mode 100644 renren-admin/src/main/resources/mapper/fuse/TbFuseResourceDao.xml diff --git a/config/db/V3.0__fuse_add_table.sql b/config/db/V3.0__fuse_add_table.sql new file mode 100644 index 00000000..8b9b18e0 --- /dev/null +++ b/config/db/V3.0__fuse_add_table.sql @@ -0,0 +1,33 @@ +CREATE TABLE `tb_fuse` ( + `id` bigint(20) NOT NULL COMMENT '主键', + `name` varchar(128) DEFAULT NULL COMMENT '融合服务名称', + `description` varchar(128) DEFAULT NULL COMMENT '融合服务描述', + `application_area` varchar(128) DEFAULT NULL COMMENT '应用领域', + `dept_id` bigint(20) DEFAULT NULL COMMENT '所属部门', + `dept_user` varchar(128) DEFAULT NULL COMMENT '部门联系人', + `mobile` varchar(20) DEFAULT NULL COMMENT '部门联系人电话', + `provider` varchar(128) DEFAULT NULL COMMENT '服务商', + `provider_user` varchar(128) DEFAULT NULL COMMENT '服务商联系人', + `provider_mobile` varchar(20) DEFAULT NULL COMMENT '服务商联系人电话', + `creator` bigint(20) DEFAULT NULL COMMENT '创建人', + `create_date` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint(20) DEFAULT NULL COMMENT '修改人', + `update_date` datetime DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='融合服务表'; + +CREATE TABLE `tb_fuse_resource` ( + `id` bigint(20) NOT NULL COMMENT '主键', + `fuse_id` bigint(20) NOT NULL COMMENT '融合id', + `resource_id` bigint(20) NOT NULL COMMENT '资源id', + `sequence` varchar(10) DEFAULT NULL COMMENT '顺序', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='资源融合关系表'; + +CREATE TABLE `tb_fuse_attr` ( + `id` bigint(20) NOT NULL COMMENT '主键', + `fuse_id` bigint(20) DEFAULT NULL COMMENT '融合id', + `attr_type` varchar(128) DEFAULT NULL COMMENT '属性类型', + `attr_value` varchar(128) DEFAULT NULL COMMENT '属性值', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='融合资源属性表'; \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java b/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java new file mode 100644 index 00000000..3262ae29 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java @@ -0,0 +1,90 @@ +package io.renren.modules.fuse.controller; + +import io.renren.common.annotation.LogOperation; +import io.renren.common.constant.Constant; +import io.renren.common.page.PageData; +import io.renren.common.utils.Result; +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.fuse.dto.TbFuseDTO; +import io.renren.modules.fuse.service.TbFuseService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.Map; + +/** + * 融合服务 + * + * @Auther:lizhicheng2@hisense.com + * @date:2022/6/30 + * @des + */ +@RestController +@RequestMapping("fuse") +@Api(tags="融合服务") +public class FuseController { + + @Autowired + private TbFuseService tbFuseService; + + @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 = "name", value = "融合服务名称", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "description", value = "融合服务描述", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "applicationArea", value = "应用领域", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType="int"), + @ApiImplicitParam(name = "deptUser", value = "部门联系人", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "mobile", value = "部门联系人电话", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "provider", value = "服务商", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "providerUser", value = "服务商联系人", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "providerMobile", value = "服务商联系人电话", paramType = "query", dataType="String") + }) + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = tbFuseService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + @ApiOperation("信息") + public Result get(@PathVariable("id") Long id){ + return new Result().ok(tbFuseService.getFuseById(id)); + } + + @PostMapping + @ApiOperation("保存") + @LogOperation("保存") + public Result save(@RequestBody TbFuseDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + return new Result().ok(tbFuseService.addFuse(dto)); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") + public Result update(@RequestBody TbFuseDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + return new Result().ok(tbFuseService.updateFuse(dto)); + } + + @DeleteMapping + @ApiOperation("删除") + @LogOperation("删除") + public Result delete(@RequestBody Long id){ + return new Result().ok(tbFuseService.deleteFuse(id)); + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseAttrDao.java b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseAttrDao.java new file mode 100644 index 00000000..1db852f1 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseAttrDao.java @@ -0,0 +1,23 @@ +package io.renren.modules.fuse.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.fuse.dto.TbFuseAttrDTO; +import io.renren.modules.fuse.entity.TbFuseAttrEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Auther:lizhicheng2@hisense.com + * @date:2022/7/3 + * @des + */ +@Mapper +public interface TbFuseAttrDao extends BaseDao { + + int insertBatch(List list); + + int deleteByFuseId(@Param(value = "fuseId") Long fuseId); + +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java new file mode 100644 index 00000000..4c594e4f --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java @@ -0,0 +1,15 @@ +package io.renren.modules.fuse.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.fuse.entity.TbFuseEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Auther:lizhicheng2@hisense.com + * @date:2022/6/30 + * @des + */ +@Mapper +public interface TbFuseDao extends BaseDao { + +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseResourceDao.java b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseResourceDao.java new file mode 100644 index 00000000..5f0fa664 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseResourceDao.java @@ -0,0 +1,24 @@ +package io.renren.modules.fuse.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.fuse.dto.TbFuseResourceDTO; +import io.renren.modules.fuse.entity.TbFuseResourceEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Auther:lizhicheng2@hisense.com + * @date:2022/6/30 + * @des + */ +@Mapper +public interface TbFuseResourceDao extends BaseDao { + + int insertBatch(List list); + + int deleteByFuseId(@Param(value = "fuseId") Long fuseId); + + +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseAttrDTO.java b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseAttrDTO.java new file mode 100644 index 00000000..62c2e54a --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseAttrDTO.java @@ -0,0 +1,26 @@ +package io.renren.modules.fuse.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Auther:lizhicheng2@hisense.com + * @date:2022/7/3 + * @des + */ +@Data +@ApiModel(value = "融合资源属性表") +public class TbFuseAttrDTO { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + private Long id; + @ApiModelProperty(value = "融合服务id") + private Long fuseId; + @ApiModelProperty(value = "属性类型") + private String attrType; + @ApiModelProperty(value = "属性值") + private String attrValue; + +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java new file mode 100644 index 00000000..b9b5352f --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java @@ -0,0 +1,52 @@ +package io.renren.modules.fuse.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @Auther:lizhicheng2@hisense.com + * @date:2022/6/30 + * @des + */ +@Data +@ApiModel(value = "融合服务表") +public class TbFuseDTO { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + private Long id; + @ApiModelProperty(value = "融合服务名称") + private String name; + @ApiModelProperty(value = "融合服务描述") + private String description; + @ApiModelProperty(value = "应用领域") + private String applicationArea; + @ApiModelProperty(value = "所属部门") + private Long deptId; + @ApiModelProperty(value = "部门联系人") + private String deptUser; + @ApiModelProperty(value = "部门联系人电话") + private String mobile; + @ApiModelProperty(value = "服务商") + private String provider; + @ApiModelProperty(value = "服务商联系人") + private String providerUser; + @ApiModelProperty(value = "服务商联系人电话") + private String providerMobile; + @ApiModelProperty(value = "创建人") + private Long creator; + @ApiModelProperty(value = "创建时间") + private Date createDate; + @ApiModelProperty(value = "修改人") + private Long updater; + @ApiModelProperty(value = "更新时间") + private Date updateDate; + @ApiModelProperty(value = "资源融合关系") + private List fuseResourceList; + @ApiModelProperty(value = "融合资源属性") + private List fuseAttrList; +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java new file mode 100644 index 00000000..fc3b986b --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java @@ -0,0 +1,26 @@ +package io.renren.modules.fuse.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Auther:lizhicheng2@hisense.com + * @date:2022/7/3 + * @des + */ +@Data +@ApiModel(value = "资源融合关系表") +public class TbFuseResourceDTO { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + private Long id; + @ApiModelProperty(value = "融合服务id") + private Long fuseId; + @ApiModelProperty(value = "资源id") + private Long resourceId; + @ApiModelProperty(value = "资源挂载顺序") + private String sequence; + +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseAttrEntity.java b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseAttrEntity.java new file mode 100644 index 00000000..c8f28cbc --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseAttrEntity.java @@ -0,0 +1,36 @@ +package io.renren.modules.fuse.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 融合资源属性表 + * + * @Auther:lizhicheng2@hisense.com + * @date:2022/7/3 + * @des + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("tb_fuse_attr") +public class TbFuseAttrEntity { + private static final long serialVersionUID = 1L; + + @TableId + private Long id; + /** + * 融合服务id + */ + private Long fuseId; + /** + * 属性类型 + */ + private String attrType; + /** + * 属性值 + */ + private String attrValue; + +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java new file mode 100644 index 00000000..5948af97 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java @@ -0,0 +1,81 @@ +package io.renren.modules.fuse.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.renren.common.entity.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 融合服务表 + * + * @Auther:lizhicheng2@hisense.com + * @date:2022/6/30 + * @des + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_fuse") +public class TbFuseEntity extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 融合服务名称 + */ + private String name; + /** + * 融合服务描述 + */ + private String description; + /** + * 应用领域 + */ + private String applicationArea; + /** + * 所属部门 + */ + private Long deptId; + /** + * 部门联系人 + */ + private String deptUser; + /** + * 部门联系人电话 + */ + private String mobile; + /** + * 服务商 + */ + private String provider; + /** + * 服务商联系人 + */ + private String providerUser; + /** + * 服务商联系人电话 + */ + private String providerMobile; + /** + * 创建人 + */ + @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; +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java new file mode 100644 index 00000000..f1b1a932 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java @@ -0,0 +1,36 @@ +package io.renren.modules.fuse.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.renren.common.entity.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 资源融合关系表 + * + * @Auther:lizhicheng2@hisense.com + * @date:2022/6/30 + * @des + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_fuse_resource") +public class TbFuseResourceEntity { + private static final long serialVersionUID = 1L; + + @TableId + private Long id; + /** + * 融合服务id + */ + private Long fuseId; + /** + * 资源id + */ + private Long resourceId; + /** + * 顺序 + */ + private String sequence; +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java b/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java new file mode 100644 index 00000000..d731cc86 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java @@ -0,0 +1,24 @@ +package io.renren.modules.fuse.service; + +import io.renren.common.service.CrudService; +import io.renren.modules.fuse.dto.TbFuseDTO; +import io.renren.modules.fuse.entity.TbFuseEntity; + +import java.util.Map; + +/** + * @Auther:lizhicheng2@hisense.com + * @date:2022/6/30 + * @des + */ +public interface TbFuseService extends CrudService { + + TbFuseDTO getFuseById(Long id); + + Integer addFuse(TbFuseDTO dto); + + Integer updateFuse(TbFuseDTO dto); + + Integer deleteFuse(Long id); + +} diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java new file mode 100644 index 00000000..848d2165 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java @@ -0,0 +1,200 @@ +package io.renren.modules.fuse.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import io.renren.common.page.PageData; +import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.modules.fuse.dao.TbFuseAttrDao; +import io.renren.modules.fuse.dao.TbFuseDao; +import io.renren.modules.fuse.dao.TbFuseResourceDao; +import io.renren.modules.fuse.dto.TbFuseAttrDTO; +import io.renren.modules.fuse.dto.TbFuseDTO; +import io.renren.modules.fuse.dto.TbFuseResourceDTO; +import io.renren.modules.fuse.entity.TbFuseAttrEntity; +import io.renren.modules.fuse.entity.TbFuseEntity; +import io.renren.modules.fuse.entity.TbFuseResourceEntity; +import io.renren.modules.fuse.service.TbFuseService; +import io.renren.modules.resource.service.impl.ResourceServiceImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Auther:lizhicheng2@hisense.com + * @date:2022/6/30 + * @des + */ +@Service +public class TbFuseServiceImpl extends CrudServiceImpl implements TbFuseService { + + private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class); + + @Autowired + private TbFuseDao fuseDao; + @Autowired + private TbFuseResourceDao fuseResourceDao; + @Autowired + private TbFuseAttrDao fuseAttrDao; + + @Override + public QueryWrapper getWrapper(Map params) { + QueryWrapper wrapper = new QueryWrapper<>(); + params.keySet().stream().filter(index -> null != params.get(index)).forEach(index -> { + switch (index) { + case "name": + wrapper.like(StringUtils.isNotBlank(params.get("name").toString()), "name", params.get("name").toString()); + break; + case "description": + wrapper.like(StringUtils.isNotBlank(params.get("description").toString()), "description", params.get("description").toString()); + break; + case "applicationArea": + wrapper.like(StringUtils.isNotBlank(params.get("applicationArea").toString()), "application_area", params.get("applicationArea").toString()); + break; + case "deptId": + wrapper.eq(StringUtils.isNotBlank(params.get("deptId").toString()), "dept_id", params.get("deptId").toString()); + break; + case "deptUser": + wrapper.like(StringUtils.isNotBlank(params.get("deptUser").toString()), "dept_user", params.get("deptUser").toString()); + break; + case "mobile": + wrapper.like(StringUtils.isNotBlank(params.get("mobile").toString()), "mobile", params.get("mobile").toString()); + break; + case "provider": + wrapper.like(StringUtils.isNotBlank(params.get("provider").toString()), "provider", params.get("provider").toString()); + break; + case "providerUser": + wrapper.like(StringUtils.isNotBlank(params.get("providerUser").toString()), "provider_user", params.get("providerUser").toString()); + break; + case "providerMobile": + wrapper.like(StringUtils.isNotBlank(params.get("providerMobile").toString()), "provider_mobile", params.get("providerMobile").toString()); + break; + case "creator": + wrapper.eq(StringUtils.isNotBlank(params.get("creator").toString()), "creator", params.get("creator").toString()); + break; + case "createDate": + wrapper.eq(StringUtils.isNotBlank(params.get("createDate").toString()), "create_date", params.get("createDate").toString()); + break; + case "updater": + wrapper.eq(StringUtils.isNotBlank(params.get("updater").toString()), "updater", params.get("updater").toString()); + break; + case "updateDate": + wrapper.eq(StringUtils.isNotBlank(params.get("updateDate").toString()), "update_date", params.get("updateDate").toString()); + break; + } + }); + return wrapper; + } + + @Override + public PageData page(Map params){ + IPage page = baseDao.selectPage( + getPage(params, null, false), + getWrapper(params) + ); + List result=page.getRecords().stream().map(entity->{ + TbFuseDTO dto=new TbFuseDTO(); + BeanUtils.copyProperties(entity, dto); + dto.setFuseResourceList(getFuseResourceByFuseId(dto.getId())); + dto.setFuseAttrList(getAttrByFuseId(dto.getId())); + return dto; + }).collect(Collectors.toList()); + return new PageData(result, page.getTotal()); + } + + @Override + public TbFuseDTO getFuseById(Long id) { + TbFuseEntity fuseEntity = fuseDao.selectById(id); + TbFuseDTO fuseDTO = new TbFuseDTO(); + BeanUtils.copyProperties(fuseEntity, fuseDTO); + fuseDTO.setFuseAttrList(getAttrByFuseId(id)); + fuseDTO.setFuseResourceList(getFuseResourceByFuseId(id)); + return fuseDTO; + } + + private List getAttrByFuseId(Long fuseId) { + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("fuse_id", fuseId); + List list = fuseAttrDao.selectList(wrapper); + return list.stream().map(attr -> { + TbFuseAttrDTO dto = new TbFuseAttrDTO(); + BeanUtils.copyProperties(attr, dto); + return dto; + }).collect(Collectors.toList()); + } + + private List getFuseResourceByFuseId(Long fuseId) { + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("fuse_id", fuseId); + List list = fuseResourceDao.selectList(wrapper); + return list.stream().map(attr -> { + TbFuseResourceDTO dto = new TbFuseResourceDTO(); + BeanUtils.copyProperties(attr, dto); + return dto; + }).collect(Collectors.toList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Integer addFuse(TbFuseDTO dto) { + TbFuseEntity fuseEntity = new TbFuseEntity(); + BeanUtils.copyProperties(dto, fuseEntity); + int result=fuseDao.insert(fuseEntity); + dto.getFuseResourceList().forEach(fuseResourceDTO->{ + fuseResourceDTO.setId(IdWorker.getId(fuseResourceDTO)); + fuseResourceDTO.setFuseId(fuseEntity.getId()); + TbFuseResourceEntity entity=new TbFuseResourceEntity(); + BeanUtils.copyProperties(fuseResourceDTO, entity); + fuseResourceDao.insert(entity); + }); + dto.getFuseAttrList().forEach(fuseAttrDTO -> { + fuseAttrDTO.setId(IdWorker.getId(fuseAttrDTO)); + fuseAttrDTO.setFuseId(fuseEntity.getId()); + TbFuseAttrEntity entity=new TbFuseAttrEntity(); + BeanUtils.copyProperties(fuseAttrDTO, entity); + fuseAttrDao.insert(entity); + }); + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Integer updateFuse(TbFuseDTO dto) { + TbFuseEntity fuseEntity = new TbFuseEntity(); + BeanUtils.copyProperties(dto, fuseEntity); + fuseResourceDao.deleteByFuseId(fuseEntity.getId()); + dto.getFuseResourceList().forEach(fuseResourceDTO->{ + fuseResourceDTO.setId(IdWorker.getId(fuseResourceDTO)); + fuseResourceDTO.setFuseId(fuseEntity.getId()); + TbFuseResourceEntity entity=new TbFuseResourceEntity(); + BeanUtils.copyProperties(fuseResourceDTO, entity); + fuseResourceDao.insert(entity); + }); + fuseAttrDao.deleteByFuseId(fuseEntity.getId()); + dto.getFuseAttrList().forEach(fuseAttrDTO -> { + fuseAttrDTO.setId(IdWorker.getId(fuseAttrDTO)); + fuseAttrDTO.setFuseId(fuseEntity.getId()); + TbFuseAttrEntity entity=new TbFuseAttrEntity(); + BeanUtils.copyProperties(fuseAttrDTO, entity); + fuseAttrDao.insert(entity); + }); + return fuseDao.updateById(fuseEntity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Integer deleteFuse(Long id) { + fuseResourceDao.deleteByFuseId(id); + fuseAttrDao.deleteByFuseId(id); + return fuseDao.deleteById(id); + } + +} diff --git a/renren-admin/src/main/resources/db/V3.0__fuse_add_table.sql b/renren-admin/src/main/resources/db/V3.0__fuse_add_table.sql new file mode 100644 index 00000000..8b9b18e0 --- /dev/null +++ b/renren-admin/src/main/resources/db/V3.0__fuse_add_table.sql @@ -0,0 +1,33 @@ +CREATE TABLE `tb_fuse` ( + `id` bigint(20) NOT NULL COMMENT '主键', + `name` varchar(128) DEFAULT NULL COMMENT '融合服务名称', + `description` varchar(128) DEFAULT NULL COMMENT '融合服务描述', + `application_area` varchar(128) DEFAULT NULL COMMENT '应用领域', + `dept_id` bigint(20) DEFAULT NULL COMMENT '所属部门', + `dept_user` varchar(128) DEFAULT NULL COMMENT '部门联系人', + `mobile` varchar(20) DEFAULT NULL COMMENT '部门联系人电话', + `provider` varchar(128) DEFAULT NULL COMMENT '服务商', + `provider_user` varchar(128) DEFAULT NULL COMMENT '服务商联系人', + `provider_mobile` varchar(20) DEFAULT NULL COMMENT '服务商联系人电话', + `creator` bigint(20) DEFAULT NULL COMMENT '创建人', + `create_date` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint(20) DEFAULT NULL COMMENT '修改人', + `update_date` datetime DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='融合服务表'; + +CREATE TABLE `tb_fuse_resource` ( + `id` bigint(20) NOT NULL COMMENT '主键', + `fuse_id` bigint(20) NOT NULL COMMENT '融合id', + `resource_id` bigint(20) NOT NULL COMMENT '资源id', + `sequence` varchar(10) DEFAULT NULL COMMENT '顺序', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='资源融合关系表'; + +CREATE TABLE `tb_fuse_attr` ( + `id` bigint(20) NOT NULL COMMENT '主键', + `fuse_id` bigint(20) DEFAULT NULL COMMENT '融合id', + `attr_type` varchar(128) DEFAULT NULL COMMENT '属性类型', + `attr_value` varchar(128) DEFAULT NULL COMMENT '属性值', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='融合资源属性表'; \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/fuse/TbFuseAttrDao.xml b/renren-admin/src/main/resources/mapper/fuse/TbFuseAttrDao.xml new file mode 100644 index 00000000..c3b16f92 --- /dev/null +++ b/renren-admin/src/main/resources/mapper/fuse/TbFuseAttrDao.xml @@ -0,0 +1,20 @@ + + + + + + + insert into tb_fuse_attr(id, fuse_id, attr_type, attr_value) + values + + (#{item.id}, #{item.fuseId}, #{attrType}, #{attrType}) + + + + + delete + from tb_fuse_attr + where fuse_id = #{fuseId}; + + + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml b/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml new file mode 100644 index 00000000..f776af9a --- /dev/null +++ b/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/fuse/TbFuseResourceDao.xml b/renren-admin/src/main/resources/mapper/fuse/TbFuseResourceDao.xml new file mode 100644 index 00000000..c648e021 --- /dev/null +++ b/renren-admin/src/main/resources/mapper/fuse/TbFuseResourceDao.xml @@ -0,0 +1,20 @@ + + + + + + + insert into tb_fuse_resource(id, fuse_id, resource_id, sequence) + values + + (#{item.id}, #{item.fuseId}, #{item.resourceId}, #{item.sequence}) + + + + + delete + from tb_fuse_resource + where fuse_id = #{fuseId}; + + + \ No newline at end of file