diff --git a/muyu-common/muyu-common-system/src/main/java/com/muyu/common/system/domain/SysDept.java b/muyu-common/muyu-common-system/src/main/java/com/muyu/common/system/domain/SysDept.java index 9569d64..7d12bfc 100644 --- a/muyu-common/muyu-common-system/src/main/java/com/muyu/common/system/domain/SysDept.java +++ b/muyu-common/muyu-common-system/src/main/java/com/muyu/common/system/domain/SysDept.java @@ -84,11 +84,24 @@ public class SysDept extends BaseEntity { */ private String parentName; + /** + * 是否授权 + */ + private Boolean isAuth=false; + /** * 子部门 */ private List children = new ArrayList(); + public Boolean getAuth() { + return isAuth; + } + + public void setAuth(Boolean auth) { + isAuth = auth; + } + public Long getDeptId () { return deptId; } diff --git a/muyu-common/muyu-common-system/src/main/java/com/muyu/common/system/domain/SysUser.java b/muyu-common/muyu-common-system/src/main/java/com/muyu/common/system/domain/SysUser.java index 6be7436..998e9f2 100644 --- a/muyu-common/muyu-common-system/src/main/java/com/muyu/common/system/domain/SysUser.java +++ b/muyu-common/muyu-common-system/src/main/java/com/muyu/common/system/domain/SysUser.java @@ -96,6 +96,11 @@ public class SysUser extends BaseEntity { */ private String delFlag; + /** + * 是否授权 + */ + private Boolean isAuth = false; + /** * 最后登录IP */ @@ -122,6 +127,8 @@ public class SysUser extends BaseEntity { */ private List roles; + + /** * 角色组 */ @@ -137,6 +144,14 @@ public class SysUser extends BaseEntity { */ private Long roleId; + public Boolean getAuth() { + return isAuth; + } + + public void setAuth(Boolean auth) { + isAuth = auth; + } + public SysUser (Long userId) { this.userId = userId; } diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/AssetAccreditController.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/AssetAccreditController.java new file mode 100644 index 0000000..9fc79fa --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/AssetAccreditController.java @@ -0,0 +1,118 @@ +package com.muyu.etl.controller; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.etl.domain.SourceAccredit; +import com.muyu.etl.domain.req.AssetAccreditReq; +import com.muyu.etl.domain.req.SourceAccreditReq; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.muyu.common.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.etl.domain.AssetAccredit; +import com.muyu.etl.service.IAssetAccreditService; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.core.web.page.TableDataInfo; + +/** + * 【请填写功能名称】Controller + * + * @author ruoyi + * @date 2024-04-25 + */ +@RestController +@RequestMapping("/assetAccredit") +public class AssetAccreditController extends BaseController +{ + @Autowired + private IAssetAccreditService assetAccreditService; + + /** + * 查询【请填写功能名称】列表 + */ + @GetMapping("/list") + public Result> list(AssetAccredit assetAccredit) + { + startPage(); + List list = assetAccreditService.selectAssetAccreditList(assetAccredit); + return getDataTable(list); + } + + /** + * 导出【请填写功能名称】列表 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, AssetAccredit assetAccredit) + { + List list = assetAccreditService.selectAssetAccreditList(assetAccredit); + ExcelUtil util = new ExcelUtil(AssetAccredit.class); + util.exportExcel(response, list, "【请填写功能名称】数据"); + } + + /** + * 获取【请填写功能名称】详细信息 + */ + @GetMapping(value = "/{id}") + public Result getInfo(@PathVariable("id") Long id) + { + return success(assetAccreditService.selectAssetAccreditById(id)); + } + + + /** + * 根据表id获取授权信息 + */ + @GetMapping(value = "/GetAssetAccreditByDataAssetId") + public Result getAssetAccreditByDataAssetId(@RequestParam("id") Long id) + { + return assetAccreditService.getAssetAccreditByDataAssetId(id); + } + + /** + * 新增【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) + @PostMapping + public Result add(@RequestBody AssetAccreditReq assetAccreditReq) + { + return assetAccreditService.insertAssetAccredit(assetAccreditReq); + } + + /** + * 授权删除 + */ + @Log(title = "授权删除", businessType = BusinessType.INSERT) + @PostMapping("/DeleteAssetAccreditByAssetIds") + public Result deleteSourceAccreditBySourceIds(@RequestBody AssetAccreditReq assetAccreditReq) + { + return assetAccreditService.deleteAssetAccreditByAssetIds(assetAccreditReq); + } + + /** + * 修改【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) + @PutMapping + public Result edit(@RequestBody AssetAccredit assetAccredit) + { + return toAjax(assetAccreditService.updateAssetAccredit(assetAccredit)); + } + + /** + * 删除【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public Result remove(@PathVariable Long[] ids) + { + return toAjax(assetAccreditService.deleteAssetAccreditByIds(ids)); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/SourceAccreditController.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/SourceAccreditController.java new file mode 100644 index 0000000..1994965 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/SourceAccreditController.java @@ -0,0 +1,118 @@ +package com.muyu.etl.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.muyu.etl.domain.req.SourceAccreditReq; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.muyu.common.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.etl.domain.SourceAccredit; +import com.muyu.etl.service.ISourceAccreditService; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.core.web.page.TableDataInfo; + +/** + * 【请填写功能名称】Controller + * + * @author ruoyi + * @date 2024-04-25 + */ +@RestController +@RequestMapping("/sourceAccredit") +public class SourceAccreditController extends BaseController +{ + @Autowired + private ISourceAccreditService sourceAccreditService; + + /** + * 查询【请填写功能名称】列表 + */ + @RequiresPermissions("system:accredit:list") + @GetMapping("/list") + public Result> list(SourceAccredit sourceAccredit) + { + startPage(); + List list = sourceAccreditService.selectSourceAccreditList(sourceAccredit); + return getDataTable(list); + } + + /** + * 导出【请填写功能名称】列表 + */ + @RequiresPermissions("system:accredit:export") + @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SourceAccredit sourceAccredit) + { + List list = sourceAccreditService.selectSourceAccreditList(sourceAccredit); + ExcelUtil util = new ExcelUtil(SourceAccredit.class); + util.exportExcel(response, list, "【请填写功能名称】数据"); + } + + /** + * 获取【请填写功能名称】详细信息 + */ + @RequiresPermissions("system:accredit:query") + @GetMapping(value = "/{id}") + public Result getInfo(@PathVariable("id") Long id) + { + return success(sourceAccreditService.selectSourceAccreditById(id)); + } + + /** + * 根据数据源id获取授权信息 + */ + @GetMapping(value = "/GetSourceAccreditByDataSourceId") + public Result getSourceAccreditByDataSourceId(@RequestParam("id") Long id) + { + return sourceAccreditService.getSourceAccreditByDataSourceId(id); + } + + /** + * 新增【请填写功能名称】 + */ + @RequiresPermissions("system:accredit:add") + @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) + @PostMapping + public Result add(@RequestBody SourceAccreditReq sourceAccreditReq) + { + return sourceAccreditService.insertSourceAccredit(sourceAccreditReq); + } + + /** + * 授权删除 + */ + @Log(title = "授权删除", businessType = BusinessType.INSERT) + @PostMapping("/DeleteSourceAccreditBySourceIds") + public Result deleteSourceAccreditBySourceIds(@RequestBody SourceAccreditReq sourceAccreditReq) + { + return sourceAccreditService.deleteSourceAccreditBySourceIds(sourceAccreditReq); + } + + /** + * 修改【请填写功能名称】 + */ + @RequiresPermissions("system:accredit:edit") + @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) + @PutMapping + public Result edit(@RequestBody SourceAccredit sourceAccredit) + { + return toAjax(sourceAccreditService.updateSourceAccredit(sourceAccredit)); + } + + /** + * 删除【请填写功能名称】 + */ + @RequiresPermissions("system:accredit:remove") + @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public Result remove(@PathVariable Long[] ids) + { + return toAjax(sourceAccreditService.deleteSourceAccreditByIds(ids)); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/AssetAccredit.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/AssetAccredit.java new file mode 100644 index 0000000..2102919 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/AssetAccredit.java @@ -0,0 +1,86 @@ +package com.muyu.etl.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; + +/** + * 【请填写功能名称】对象 asset_accredit + * + * @author ruoyi + * @date 2024-04-25 + */ +public class AssetAccredit extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 部门id */ + @Excel(name = "部门id") + private Long deptId; + + /** 数据表id */ + @Excel(name = "数据表id") + private Long dataAssetId; + + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + public Long getDeptId() + { + return deptId; + } + public void setDataAssetId(Long dataAssetId) + { + this.dataAssetId = dataAssetId; + } + + public Long getDataAssetId() + { + return dataAssetId; + } + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("deptId", getDeptId()) + .append("dataAssetId", getDataAssetId()) + .append("userId", getUserId()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/SourceAccredit.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/SourceAccredit.java new file mode 100644 index 0000000..d89c0ae --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/SourceAccredit.java @@ -0,0 +1,85 @@ +package com.muyu.etl.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; + +/** + * 【请填写功能名称】对象 source_accredit + * + * @author ruoyi + * @date 2024-04-25 + */ +public class SourceAccredit extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 部门id */ + @Excel(name = "部门id") + private Long deptId; + + /** 数据源id */ + @Excel(name = "数据源id") + private Long dataSourceId; + + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public Long getDeptId() { + return deptId; + } + + public void setDeptId(Long deptId) { + this.deptId = deptId; + } + + public Long getDataSourceId() { + return dataSourceId; + } + + public void setDataSourceId(Long dataSourceId) { + this.dataSourceId = dataSourceId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("deptId", getDeptId()) + .append("dataSourceId", getDataSourceId()) + .append("userId", getUserId()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/model/AccreditModel.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/model/AccreditModel.java new file mode 100644 index 0000000..9d070d3 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/model/AccreditModel.java @@ -0,0 +1,21 @@ +package com.muyu.etl.domain.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @ClassName AccreditModel + * @Description 描述 + * @Author Xin.Yao + * @Date 2024/4/26 9:09 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AccreditModel { + private List userAccreditModelIds; + private List deptAccreditModelIds; +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/req/AssetAccreditReq.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/req/AssetAccreditReq.java new file mode 100644 index 0000000..75c1a4b --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/req/AssetAccreditReq.java @@ -0,0 +1,24 @@ +package com.muyu.etl.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @ClassName SourceAccreditReq + * @Description 描述 + * @Author Xin.Yao + * @Date 2024/4/26 15:19 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +public class AssetAccreditReq { + private List deptIds; + private Long userId; + private Long dataAssetId; +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/req/SourceAccreditReq.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/req/SourceAccreditReq.java new file mode 100644 index 0000000..1e4938a --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/req/SourceAccreditReq.java @@ -0,0 +1,24 @@ +package com.muyu.etl.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @ClassName SourceAccreditReq + * @Description 描述 + * @Author Xin.Yao + * @Date 2024/4/26 15:19 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +public class SourceAccreditReq { + private List deptIds; + private Long userId; + private Long dataSourceId; +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/AssetAccreditMapper.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/AssetAccreditMapper.java new file mode 100644 index 0000000..e6c91be --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/AssetAccreditMapper.java @@ -0,0 +1,73 @@ +package com.muyu.etl.mapper; + +import java.util.List; +import com.muyu.etl.domain.AssetAccredit; +import com.muyu.etl.domain.SourceAccredit; +import org.apache.ibatis.annotations.Param; + +/** + * 【请填写功能名称】Mapper接口 + * + * @author ruoyi + * @date 2024-04-25 + */ +public interface AssetAccreditMapper +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public AssetAccredit selectAssetAccreditById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param assetAccredit 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectAssetAccreditList(AssetAccredit assetAccredit); + + /** + * 新增【请填写功能名称】 + * + * @param assetAccredit 【请填写功能名称】 + * @return 结果 + */ + public int insertAssetAccredit(AssetAccredit assetAccredit); + + /** + * 修改【请填写功能名称】 + * + * @param assetAccredit 【请填写功能名称】 + * @return 结果 + */ + public int updateAssetAccredit(AssetAccredit assetAccredit); + + /** + * 删除【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteAssetAccreditById(Long id); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteAssetAccreditByIds(Long[] ids); + + void deleteAssetAccreditByAssetIds(@Param("assetIds") List assetIds); + + List getAssetAccreditByDataAssetId(@Param("id") Long id); + + List getAssetAccreditByUserId(@Param("id") Long id); + + void deleteAssetAccreditByDeptUser(@Param("deptIds") List deptIds, @Param("userId") Long userId, @Param("dataAssetId") Long dataAssetId); + + void insertBatchAssetAccredit(@Param("assetAccredits") List assetAccredits); +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DataAssetMapper.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DataAssetMapper.java index 6b31b79..dd97514 100644 --- a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DataAssetMapper.java +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DataAssetMapper.java @@ -66,4 +66,6 @@ public interface DataAssetMapper List selectDataAssetBatchId(@Param("longs") List longs); List getDataAssetList(@Param("ids") Long[] ids); + + List getDataAssetByAssetId(@Param("assetIds") List assetIds); } diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/SourceAccreditMapper.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/SourceAccreditMapper.java new file mode 100644 index 0000000..9a99fa9 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/SourceAccreditMapper.java @@ -0,0 +1,72 @@ +package com.muyu.etl.mapper; + +import java.util.List; +import com.muyu.etl.domain.SourceAccredit; +import org.apache.ibatis.annotations.Param; + +/** + * 【请填写功能名称】Mapper接口 + * + * @author ruoyi + * @date 2024-04-25 + */ +public interface SourceAccreditMapper +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public SourceAccredit selectSourceAccreditById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param sourceAccredit 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectSourceAccreditList(SourceAccredit sourceAccredit); + + /** + * 新增【请填写功能名称】 + * + * @param sourceAccredit 【请填写功能名称】 + * @return 结果 + */ + public int insertSourceAccredit(SourceAccredit sourceAccredit); + + /** + * 修改【请填写功能名称】 + * + * @param sourceAccredit 【请填写功能名称】 + * @return 结果 + */ + public int updateSourceAccredit(SourceAccredit sourceAccredit); + + /** + * 删除【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteSourceAccreditById(Long id); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSourceAccreditByIds(Long[] ids); + + void deleteSourceAccreditBySourceIds(@Param("sourceIds") List sourceIds); + + List getSourceAccreditByDataSourceId(@Param("id") Long id); + + List getSourceAccreditByUserId(@Param("id") Long id); + + void insertBatchSourceAccredit(@Param("sourceAccredits") List sourceAccredits); + + void deleteSourceAccreditByDeptUser(@Param("deptIds") List deptIds, @Param("userId") Long userId, @Param("dataSourceId") Long dataSourceId); +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IAssetAccreditService.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IAssetAccreditService.java new file mode 100644 index 0000000..6908314 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IAssetAccreditService.java @@ -0,0 +1,68 @@ +package com.muyu.etl.service; + +import java.util.List; + +import com.muyu.common.core.domain.Result; +import com.muyu.etl.domain.AssetAccredit; +import com.muyu.etl.domain.req.AssetAccreditReq; + +/** + * 【请填写功能名称】Service接口 + * + * @author ruoyi + * @date 2024-04-25 + */ +public interface IAssetAccreditService +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public AssetAccredit selectAssetAccreditById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param assetAccredit 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectAssetAccreditList(AssetAccredit assetAccredit); + + /** + * 新增【请填写功能名称】 + * + * @param assetAccreditReq 【请填写功能名称】 + * @return 结果 + */ + public Result insertAssetAccredit(AssetAccreditReq assetAccreditReq); + + /** + * 修改【请填写功能名称】 + * + * @param assetAccredit 【请填写功能名称】 + * @return 结果 + */ + public int updateAssetAccredit(AssetAccredit assetAccredit); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键集合 + * @return 结果 + */ + public int deleteAssetAccreditByIds(Long[] ids); + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteAssetAccreditById(Long id); + + Result getAssetAccreditByDataAssetId(Long id); + + Result deleteAssetAccreditByAssetIds(AssetAccreditReq assetAccreditReq); +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/ISourceAccreditService.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/ISourceAccreditService.java new file mode 100644 index 0000000..2d21ff4 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/ISourceAccreditService.java @@ -0,0 +1,68 @@ +package com.muyu.etl.service; + +import java.util.List; + +import com.muyu.common.core.domain.Result; +import com.muyu.etl.domain.SourceAccredit; +import com.muyu.etl.domain.req.SourceAccreditReq; + +/** + * 【请填写功能名称】Service接口 + * + * @author ruoyi + * @date 2024-04-25 + */ +public interface ISourceAccreditService +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public SourceAccredit selectSourceAccreditById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param sourceAccredit 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectSourceAccreditList(SourceAccredit sourceAccredit); + + /** + * 新增【请填写功能名称】 + * + * @param sourceAccreditReq 【请填写功能名称】 + * @return 结果 + */ + public Result insertSourceAccredit(SourceAccreditReq sourceAccreditReq); + + /** + * 修改【请填写功能名称】 + * + * @param sourceAccredit 【请填写功能名称】 + * @return 结果 + */ + public int updateSourceAccredit(SourceAccredit sourceAccredit); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键集合 + * @return 结果 + */ + public int deleteSourceAccreditByIds(Long[] ids); + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteSourceAccreditById(Long id); + + Result getSourceAccreditByDataSourceId(Long id); + + Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq); +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/AssetAccreditServiceImpl.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/AssetAccreditServiceImpl.java new file mode 100644 index 0000000..e68d824 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/AssetAccreditServiceImpl.java @@ -0,0 +1,145 @@ +package com.muyu.etl.service.impl; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.DateUtils; +import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.etl.domain.SourceAccredit; +import com.muyu.etl.domain.model.AccreditModel; +import com.muyu.etl.domain.req.AssetAccreditReq; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.muyu.etl.mapper.AssetAccreditMapper; +import com.muyu.etl.domain.AssetAccredit; +import com.muyu.etl.service.IAssetAccreditService; + +/** + * 【请填写功能名称】Service业务层处理 + * + * @author ruoyi + * @date 2024-04-25 + */ +@Service +public class AssetAccreditServiceImpl implements IAssetAccreditService +{ + @Autowired + private AssetAccreditMapper assetAccreditMapper; + + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + @Override + public AssetAccredit selectAssetAccreditById(Long id) + { + return assetAccreditMapper.selectAssetAccreditById(id); + } + + /** + * 查询【请填写功能名称】列表 + * + * @param assetAccredit 【请填写功能名称】 + * @return 【请填写功能名称】 + */ + @Override + public List selectAssetAccreditList(AssetAccredit assetAccredit) + { + return assetAccreditMapper.selectAssetAccreditList(assetAccredit); + } + + /** + * 新增【请填写功能名称】 + * + * @param assetAccreditReq 【请填写功能名称】 + * @return 结果 + */ + @Override + public Result insertAssetAccredit(AssetAccreditReq assetAccreditReq) + { + deleteAssetAccreditByAssetIds(assetAccreditReq); + List assetAccredits = new ArrayList<>(); + if (assetAccreditReq.getUserId() != null){ + AssetAccredit assetAccredit = new AssetAccredit(); + assetAccredit.setDataAssetId(assetAccreditReq.getDataAssetId()); + assetAccredit.setUserId(assetAccreditReq.getUserId()); + assetAccredit.setCreateBy(SecurityUtils.getUsername()); + assetAccredit.setCreateTime(new Date()); + assetAccredits.add(assetAccredit); + }else{ + assetAccredits=assetAccreditReq.getDeptIds().stream().map(deptId -> { + AssetAccredit assetAccredit = new AssetAccredit(); + assetAccredit.setDataAssetId(assetAccreditReq.getDataAssetId()); + assetAccredit.setDeptId(deptId); + assetAccredit.setCreateBy(SecurityUtils.getUsername()); + assetAccredit.setCreateTime(new Date()); + return assetAccredit; + }).toList(); + } + assetAccreditMapper.insertBatchAssetAccredit(assetAccredits); + return Result.success(); + } + + /** + * 修改【请填写功能名称】 + * + * @param assetAccredit 【请填写功能名称】 + * @return 结果 + */ + @Override + public int updateAssetAccredit(AssetAccredit assetAccredit) + { + assetAccredit.setUpdateTime(DateUtils.getNowDate()); + return assetAccreditMapper.updateAssetAccredit(assetAccredit); + } + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteAssetAccreditByIds(Long[] ids) + { + return assetAccreditMapper.deleteAssetAccreditByIds(ids); + } + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteAssetAccreditById(Long id) + { + return assetAccreditMapper.deleteAssetAccreditById(id); + } + + @Override + public Result getAssetAccreditByDataAssetId(Long id) { + List assetAccreditList = assetAccreditMapper.getAssetAccreditByDataAssetId(id); + List userAccreditIds = assetAccreditList.stream().map(AssetAccredit::getUserId).filter(Objects::nonNull).toList(); + List deptAccreditIds = assetAccreditList.stream().map(AssetAccredit::getDeptId).filter(Objects::nonNull).toList(); + AccreditModel accreditModel = new AccreditModel(); + accreditModel.setDeptAccreditModelIds(deptAccreditIds); + accreditModel.setUserAccreditModelIds(userAccreditIds); + return Result.success(accreditModel); + } + + @Override + public Result deleteAssetAccreditByAssetIds(AssetAccreditReq assetAccreditReq) { + if (assetAccreditReq.getUserId() != null){ + assetAccreditMapper.deleteAssetAccreditByDeptUser(null,assetAccreditReq.getUserId(),assetAccreditReq.getDataAssetId()); + }else{ + assetAccreditMapper.deleteAssetAccreditByDeptUser(assetAccreditReq.getDeptIds(),null,assetAccreditReq.getDataAssetId()); + } + return null; + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DataSourceServiceImpl.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DataSourceServiceImpl.java index a39e861..86c44a7 100644 --- a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DataSourceServiceImpl.java +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DataSourceServiceImpl.java @@ -3,10 +3,13 @@ package com.muyu.etl.service.impl; import java.sql.*; import java.util.*; import java.util.Date; +import java.util.stream.Stream; import com.muyu.common.core.domain.Result; import com.muyu.common.core.utils.DateUtils; import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.common.system.domain.LoginUser; +import com.muyu.common.system.domain.SysRole; import com.muyu.etl.domain.*; import com.muyu.etl.domain.Dictionary; import com.muyu.etl.domain.custom.*; @@ -72,8 +75,23 @@ public class DataSourceServiceImpl implements IDataSourceService @Override public List selectDataSourceList(DataSource dataSource) { + List dataSourceList = new ArrayList(); List dataSources = dataSourceMapper.selectDataSourceList(dataSource); - return dataSources; + List roles = SecurityUtils.getLoginUser().getSysUser().getRoles(); + if (roles.get(0).getRoleId()==1){ + dataSourceList = dataSources; + }else{ + ArrayList longs1 = new ArrayList<>(); + List sourceIds = sourceAccreditMapper.getSourceAccreditByUserId(SecurityUtils.getUserId()).stream().map(SourceAccredit::getDataSourceId).filter(Objects::nonNull).toList(); + List assetIds = assetAccreditMapper.getAssetAccreditByUserId(SecurityUtils.getUserId()).stream().map(AssetAccredit::getDataAssetId).filter(Objects::nonNull).toList(); + if (!assetIds.isEmpty()){ + List longs = dataAssetMapper.getDataAssetByAssetId(assetIds).stream().map(DataAsset::getDataSourceId).toList(); + longs1.addAll(longs); + } + longs1.addAll(sourceIds); + dataSourceList = dataSources.stream().filter(dataSourceInfo -> longs1.contains(dataSourceInfo.getId())).toList(); + } + return dataSourceList; } /** @@ -458,8 +476,16 @@ public class DataSourceServiceImpl implements IDataSourceService public Result dataAssetList(DataSource dataSource) { DataAsset dataAsset = new DataAsset(); dataAsset.setDataSourceId(dataSource.getId()); + List dataAssetList = new ArrayList<>(); List dataAssets = dataAssetMapper.selectDataAssetList(dataAsset); - return Result.success(dataAssets); + List roles = SecurityUtils.getLoginUser().getSysUser().getRoles(); + if (roles.get(0).getRoleId()==1){ + dataAssetList = dataAssets; + }else{ + List assetIds = assetAccreditMapper.getAssetAccreditByUserId(SecurityUtils.getUserId()).stream().map(AssetAccredit::getDataAssetId).filter(Objects::nonNull).toList(); + dataAssetList = dataAssets.stream().filter(dataAssetInfo -> assetIds.contains(dataAssetInfo.getId())).toList(); + } + return Result.success(dataAssetList); } @Override @@ -486,18 +512,45 @@ public class DataSourceServiceImpl implements IDataSourceService @Override public Result statistics() { //查询所有数据源 + List dataSourceList = new ArrayList<>(); List dataSources = dataSourceMapper.selectDataSourceList(new DataSource()); + List roles = SecurityUtils.getLoginUser().getSysUser().getRoles(); + List assetIds; + if (roles.get(0).getRoleId()==1){ + assetIds = new ArrayList<>(); + dataSourceList = dataSources; + }else{ + ArrayList longs1 = new ArrayList<>(); + List sourceIds = sourceAccreditMapper.getSourceAccreditByUserId(SecurityUtils.getUserId()).stream().map(SourceAccredit::getDataSourceId).filter(Objects::nonNull).toList(); + assetIds = assetAccreditMapper.getAssetAccreditByUserId(SecurityUtils.getUserId()).stream().map(AssetAccredit::getDataAssetId).filter(Objects::nonNull).toList(); + if (!assetIds.isEmpty()){ + List longs = dataAssetMapper.getDataAssetByAssetId(assetIds).stream().map(DataAsset::getDataSourceId).toList(); + longs1.addAll(longs); + } + longs1.addAll(sourceIds); + dataSourceList = dataSources.stream().filter(dataSourceInfo -> longs1.contains(dataSourceInfo.getId())).toList(); + } //获取所有数据源的主键 - List longs = dataSources.stream().map(dataSource -> dataSource.getId()).toList(); - List dataAssetList=dataAssetMapper.selectDataAssetBatchId(longs); + List longs = dataSourceList.stream().map(dataSource -> dataSource.getId()).toList(); Statistics statistics = new Statistics(); - statistics.setDataAsset(Long.valueOf(dataSources.size())); - long sum1; - long sum2=0; - sum1 = dataAssetList.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getFields())).sum(); - sum2 = dataAssetList.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getTableCount())).sum(); - statistics.setAssetModel(sum1); - statistics.setDataModel(sum2); + if (!longs.isEmpty()){ + List dataAssetList=dataAssetMapper.selectDataAssetBatchId(longs); + if (roles.get(0).getRoleId()!=1){ + dataAssetList = dataAssetList.stream().filter(dataAsset -> assetIds.contains(dataAsset.getId())).toList(); + } + + statistics.setDataAsset(Long.valueOf(dataSourceList.size())); + long sum1; + long sum2=0; + sum1 = dataAssetList.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getFields())).sum(); + sum2 = dataAssetList.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getTableCount())).sum(); + statistics.setAssetModel(sum1); + statistics.setDataModel(sum2); + }else{ + statistics.setAssetModel(0L); + statistics.setDataModel(0L); + } + return Result.success(statistics); } } diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/SourceAccreditServiceImpl.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/SourceAccreditServiceImpl.java new file mode 100644 index 0000000..f521af6 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/SourceAccreditServiceImpl.java @@ -0,0 +1,147 @@ +package com.muyu.etl.service.impl; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.DateUtils; +import com.muyu.common.core.web.page.TableDataInfo; +import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.common.system.domain.SysUser; +import com.muyu.etl.domain.model.AccreditModel; +import com.muyu.etl.domain.req.SourceAccreditReq; +import com.muyu.etl.feign.SysUserFeignService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.muyu.etl.mapper.SourceAccreditMapper; +import com.muyu.etl.domain.SourceAccredit; +import com.muyu.etl.service.ISourceAccreditService; + +/** + * 【请填写功能名称】Service业务层处理 + * + * @author ruoyi + * @date 2024-04-25 + */ +@Service +public class SourceAccreditServiceImpl implements ISourceAccreditService +{ + @Autowired + private SourceAccreditMapper sourceAccreditMapper; + + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + @Override + public SourceAccredit selectSourceAccreditById(Long id) + { + return sourceAccreditMapper.selectSourceAccreditById(id); + } + + /** + * 查询【请填写功能名称】列表 + * + * @param sourceAccredit 【请填写功能名称】 + * @return 【请填写功能名称】 + */ + @Override + public List selectSourceAccreditList(SourceAccredit sourceAccredit) + { + return sourceAccreditMapper.selectSourceAccreditList(sourceAccredit); + } + + /** + * 新增【请填写功能名称】 + * + * @param sourceAccreditReq 【请填写功能名称】 + * @return 结果 + */ + @Override + public Result insertSourceAccredit(SourceAccreditReq sourceAccreditReq) + { + deleteSourceAccreditBySourceIds(sourceAccreditReq); + List sourceAccredits = new ArrayList<>(); + if (sourceAccreditReq.getUserId() != null){ + SourceAccredit sourceAccredit = new SourceAccredit(); + sourceAccredit.setDataSourceId(sourceAccreditReq.getDataSourceId()); + sourceAccredit.setUserId(sourceAccreditReq.getUserId()); + sourceAccredit.setCreateBy(SecurityUtils.getUsername()); + sourceAccredit.setCreateTime(new Date()); + sourceAccredits.add(sourceAccredit); + }else{ + sourceAccredits=sourceAccreditReq.getDeptIds().stream().map(deptId -> { + SourceAccredit sourceAccredit = new SourceAccredit(); + sourceAccredit.setDataSourceId(sourceAccreditReq.getDataSourceId()); + sourceAccredit.setDeptId(deptId); + sourceAccredit.setCreateBy(SecurityUtils.getUsername()); + sourceAccredit.setCreateTime(new Date()); + return sourceAccredit; + }).toList(); + } + sourceAccreditMapper.insertBatchSourceAccredit(sourceAccredits); + return Result.success(); + } + + /** + * 修改【请填写功能名称】 + * + * @param sourceAccredit 【请填写功能名称】 + * @return 结果 + */ + @Override + public int updateSourceAccredit(SourceAccredit sourceAccredit) + { + sourceAccredit.setUpdateTime(DateUtils.getNowDate()); + return sourceAccreditMapper.updateSourceAccredit(sourceAccredit); + } + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteSourceAccreditByIds(Long[] ids) + { + return sourceAccreditMapper.deleteSourceAccreditByIds(ids); + } + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteSourceAccreditById(Long id) + { + return sourceAccreditMapper.deleteSourceAccreditById(id); + } + + @Override + public Result getSourceAccreditByDataSourceId(Long id) { + List sourceAccreditList = sourceAccreditMapper.getSourceAccreditByDataSourceId(id); + List userAccreditIds = sourceAccreditList.stream().map(SourceAccredit::getUserId).filter(Objects::nonNull).toList(); + List deptAccreditIds = sourceAccreditList.stream().map(SourceAccredit::getDeptId).filter(Objects::nonNull).toList(); + AccreditModel accreditModel = new AccreditModel(); + accreditModel.setDeptAccreditModelIds(deptAccreditIds); + accreditModel.setUserAccreditModelIds(userAccreditIds); + return Result.success(accreditModel); + } + + @Override + public Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq) { + if (sourceAccreditReq.getUserId() != null){ + sourceAccreditMapper.deleteSourceAccreditByDeptUser(null,sourceAccreditReq.getUserId(),sourceAccreditReq.getDataSourceId()); + }else{ + sourceAccreditMapper.deleteSourceAccreditByDeptUser(sourceAccreditReq.getDeptIds(),null,sourceAccreditReq.getDataSourceId()); + } + return Result.success(); + } +} diff --git a/muyu-modules/muyu-etl/src/main/resources/mapper/system/AssetAccreditMapper.xml b/muyu-modules/muyu-etl/src/main/resources/mapper/system/AssetAccreditMapper.xml new file mode 100644 index 0000000..ba41ae2 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/resources/mapper/system/AssetAccreditMapper.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + select id, dept_id, data_asset_id, user_id, remark, create_by, create_time, update_by, update_time from asset_accredit + + + + + + + + + + insert into asset_accredit + + dept_id, + data_asset_id, + user_id, + remark, + create_by, + create_time, + update_by, + update_time, + + + #{deptId}, + #{dataAssetId}, + #{userId}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + insert into asset_accredit + + dept_id, + data_asset_id, + user_id, + create_by, + create_time + + values + + ( + #{assetAccredit.deptId}, + null, + #{assetAccredit.dataAssetId}, + #{assetAccredit.userId}, + null, + #{assetAccredit.createBy}, + #{assetAccredit.createTime} + ) + + + + + update asset_accredit + + dept_id = #{deptId}, + data_asset_id = #{dataAssetId}, + user_id = #{userId}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from asset_accredit where id = #{id} + + + + delete from asset_accredit where id in + + #{id} + + + + delete from asset_accredit where data_asset_id in + + #{assetId} + + + + delete from asset_accredit where + data_asset_id = #{dataAssetId} + + and user_id = #{userId} + + + and dept_id in + + #{deptId} + + + + \ No newline at end of file diff --git a/muyu-modules/muyu-etl/src/main/resources/mapper/system/DataAssetMapper.xml b/muyu-modules/muyu-etl/src/main/resources/mapper/system/DataAssetMapper.xml index b64f12f..97ad5df 100644 --- a/muyu-modules/muyu-etl/src/main/resources/mapper/system/DataAssetMapper.xml +++ b/muyu-modules/muyu-etl/src/main/resources/mapper/system/DataAssetMapper.xml @@ -55,6 +55,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) + insert into data_asset diff --git a/muyu-modules/muyu-etl/src/main/resources/mapper/system/SourceAccreditMapper.xml b/muyu-modules/muyu-etl/src/main/resources/mapper/system/SourceAccreditMapper.xml new file mode 100644 index 0000000..89ae6ab --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/resources/mapper/system/SourceAccreditMapper.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + select id, dept_id, data_source_id, user_id, remark, create_by, create_time, update_by, update_time from source_accredit + + + + + + + + + + insert into source_accredit + + dept_id, + data_source_id, + user_id, + remark, + create_by, + create_time, + update_by, + update_time, + + + #{dept_id}, + #{dataSourceId}, + #{userId}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + insert into source_accredit + + dept_id, + data_source_id, + user_id, + create_by, + create_time + + values + + ( + #{sourceAccredit.deptId}, + null, + #{sourceAccredit.dataSourceId}, + #{sourceAccredit.userId}, + null, + #{sourceAccredit.createBy}, + #{sourceAccredit.createTime} + ) + + + + + update source_accredit + + dept_id = #{deptId}, + data_source_id = #{dataSourceId}, + user_id = #{userId}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from source_accredit where id = #{id} + + + + delete from source_accredit where id in + + #{id} + + + + delete from source_accredit where data_source_id in + + #{sourceId} + + + + delete from source_accredit where + data_source_id = #{dataSourceId} + + and user_id = #{userId} + + + and dept_id in + + #{deptId} + + + + \ No newline at end of file