新增功能:融合服务
This commit is contained in:
parent
6d1dc16896
commit
d839710432
|
@ -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='融合资源属性表';
|
|
@ -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<PageData<TbFuseDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
PageData<TbFuseDTO> page = tbFuseService.page(params);
|
||||
return new Result<PageData<TbFuseDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("信息")
|
||||
public Result<TbFuseDTO> get(@PathVariable("id") Long id){
|
||||
return new Result<TbFuseDTO>().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));
|
||||
}
|
||||
}
|
|
@ -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<TbFuseAttrEntity> {
|
||||
|
||||
int insertBatch(List<TbFuseAttrDTO> list);
|
||||
|
||||
int deleteByFuseId(@Param(value = "fuseId") Long fuseId);
|
||||
|
||||
}
|
|
@ -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<TbFuseEntity> {
|
||||
|
||||
}
|
|
@ -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<TbFuseResourceEntity> {
|
||||
|
||||
int insertBatch(List<TbFuseResourceDTO> list);
|
||||
|
||||
int deleteByFuseId(@Param(value = "fuseId") Long fuseId);
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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<TbFuseResourceDTO> fuseResourceList;
|
||||
@ApiModelProperty(value = "融合资源属性")
|
||||
private List<TbFuseAttrDTO> fuseAttrList;
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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<TbFuseEntity, TbFuseDTO> {
|
||||
|
||||
TbFuseDTO getFuseById(Long id);
|
||||
|
||||
Integer addFuse(TbFuseDTO dto);
|
||||
|
||||
Integer updateFuse(TbFuseDTO dto);
|
||||
|
||||
Integer deleteFuse(Long id);
|
||||
|
||||
}
|
|
@ -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<TbFuseDao, TbFuseEntity, TbFuseDTO> 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<TbFuseEntity> getWrapper(Map<String, Object> params) {
|
||||
QueryWrapper<TbFuseEntity> 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<TbFuseDTO> page(Map<String, Object> params){
|
||||
IPage<TbFuseEntity> page = baseDao.selectPage(
|
||||
getPage(params, null, false),
|
||||
getWrapper(params)
|
||||
);
|
||||
List<TbFuseDTO> 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<TbFuseAttrDTO> getAttrByFuseId(Long fuseId) {
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("fuse_id", fuseId);
|
||||
List<TbFuseAttrEntity> list = fuseAttrDao.selectList(wrapper);
|
||||
return list.stream().map(attr -> {
|
||||
TbFuseAttrDTO dto = new TbFuseAttrDTO();
|
||||
BeanUtils.copyProperties(attr, dto);
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<TbFuseResourceDTO> getFuseResourceByFuseId(Long fuseId) {
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("fuse_id", fuseId);
|
||||
List<TbFuseResourceEntity> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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='融合资源属性表';
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.renren.modules.fuse.dao.TbFuseAttrDao">
|
||||
|
||||
<insert id="insertBatch">
|
||||
insert into tb_fuse_attr(id, fuse_id, attr_type, attr_value)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id}, #{item.fuseId}, #{attrType}, #{attrType})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByFuseId">
|
||||
delete
|
||||
from tb_fuse_attr
|
||||
where fuse_id = #{fuseId};
|
||||
</delete>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.renren.modules.fuse.dao.TbFuseDao">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.renren.modules.fuse.dao.TbFuseResourceDao">
|
||||
|
||||
<insert id="insertBatch">
|
||||
insert into tb_fuse_resource(id, fuse_id, resource_id, sequence)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id}, #{item.fuseId}, #{item.resourceId}, #{item.sequence})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByFuseId">
|
||||
delete
|
||||
from tb_fuse_resource
|
||||
where fuse_id = #{fuseId};
|
||||
</delete>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue