feat: 新增资产授权
commit
f51991b5d5
|
@ -0,0 +1,79 @@
|
||||||
|
package com.muyu.data.source.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.data.source.domain.req.AssetAuthInfoQueryReq;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产授权对象
|
||||||
|
*
|
||||||
|
* @ClassName asset_authInfo
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/5/5 15:28
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName(value = "asset_auth_info")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "AssetAuthInfo",description = "资产授权")
|
||||||
|
public class AssetAuthInfo extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 授权主键 */
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(name = "授权主键",value = "授权主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 授权编号 */
|
||||||
|
@ApiModelProperty(name = "授权编号",value = "授权编号")
|
||||||
|
private Long authId;
|
||||||
|
|
||||||
|
/** 编号类型 dept/user */
|
||||||
|
@ApiModelProperty(name = "编号类型 dept/user",value = "编号类型 dept/user")
|
||||||
|
private String idType;
|
||||||
|
|
||||||
|
/** 授权数据 */
|
||||||
|
@ApiModelProperty(name = "授权数据",value = "授权数据")
|
||||||
|
private String authData;
|
||||||
|
|
||||||
|
/** 授权类型 datasource/database/table */
|
||||||
|
@ApiModelProperty(name = "授权类型 datasource/database/table",value = "授权类型 datasource/database/table")
|
||||||
|
private String authType;
|
||||||
|
|
||||||
|
public static AssetAuthInfo queryBuild(AssetAuthInfoQueryReq assetAuthInfoQueryReq) {
|
||||||
|
return AssetAuthInfo.builder()
|
||||||
|
.authId(assetAuthInfoQueryReq.getAuthId())
|
||||||
|
.idType(assetAuthInfoQueryReq.getIdType())
|
||||||
|
.authData(assetAuthInfoQueryReq.getAuthData())
|
||||||
|
.authType(assetAuthInfoQueryReq.getAuthType())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetAuthInfo saveBuild(AssetAuthInfoQueryReq assetAuthInfoQueryReq, Supplier<String> getUsername) {
|
||||||
|
|
||||||
|
return AssetAuthInfo.builder()
|
||||||
|
.authId(assetAuthInfoQueryReq.getAuthId())
|
||||||
|
.idType(assetAuthInfoQueryReq.getIdType())
|
||||||
|
.authData(assetAuthInfoQueryReq.getAuthData())
|
||||||
|
.authType(assetAuthInfoQueryReq.getAuthType())
|
||||||
|
.createBy(getUsername.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.muyu.data.source.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产授权对象查询 asset_auth_info
|
||||||
|
*
|
||||||
|
* @author wan
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "AssetAuthInfoQueryReq", description = "资产授权")
|
||||||
|
public class AssetAuthInfoQueryReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 授权编号 */
|
||||||
|
@ApiModelProperty(name = "授权编号", value = "授权编号")
|
||||||
|
private Long authId;
|
||||||
|
|
||||||
|
/** 编号类型 dept/user */
|
||||||
|
@ApiModelProperty(name = "编号类型 dept/user", value = "编号类型 dept/user")
|
||||||
|
private String idType;
|
||||||
|
|
||||||
|
/** 授权数据 */
|
||||||
|
@ApiModelProperty(name = "授权数据", value = "授权数据")
|
||||||
|
private String authData;
|
||||||
|
|
||||||
|
/** 授权类型 datasource/database/table */
|
||||||
|
@ApiModelProperty(name = "授权类型 datasource/database/table", value = "授权类型 datasource/database/table")
|
||||||
|
private String authType;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.muyu.data.source.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产授权对象 asset_auth_info
|
||||||
|
*
|
||||||
|
* @author wan
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "AssetAuthInfoSaveReq", description = "资产授权")
|
||||||
|
public class AssetAuthInfoSaveReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 编号 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "编号", value = "编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 授权编号 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "授权编号", value = "授权编号", required = true)
|
||||||
|
private Long authId;
|
||||||
|
|
||||||
|
/** 编号类型 dept/user */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "编号类型 dept/user", value = "编号类型 dept/user", required = true)
|
||||||
|
private String idType;
|
||||||
|
|
||||||
|
/** 授权数据 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "授权数据", value = "授权数据", required = true)
|
||||||
|
private String authData;
|
||||||
|
|
||||||
|
/** 授权类型 datasource/database/table */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "授权类型 datasource/database/table", value = "授权类型 datasource/database/table", required = true)
|
||||||
|
private String authType;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.muyu.data.source.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.data.source.domain.AssetAuthInfo;
|
||||||
|
import com.muyu.data.source.domain.req.AssetAuthInfoQueryReq;
|
||||||
|
import com.muyu.data.source.service.AssetAuthInfoService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产授权Controller层
|
||||||
|
*
|
||||||
|
* @ClassName AssetAuthInfoController
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/5/5 15:38
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Api(tags = "资产授权")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/auth")
|
||||||
|
public class AssetAuthInfoController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private AssetAuthInfoService assetAuthInfoService;
|
||||||
|
|
||||||
|
@ApiOperation("获取资产授权列表")
|
||||||
|
@RequiresPermissions("source:auth:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<AssetAuthInfo>> list(AssetAuthInfoQueryReq assetAuthInfoQueryReq) {
|
||||||
|
startPage();
|
||||||
|
List<AssetAuthInfo> list = assetAuthInfoService.list(AssetAuthInfo.queryBuild(assetAuthInfoQueryReq));
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresPermissions("source:auth:add")
|
||||||
|
@Log(title = "资产授权", businessType = BusinessType.DELETE)
|
||||||
|
@RequestMapping
|
||||||
|
@ApiOperation("新增资产授权")
|
||||||
|
public Result<String> add(@RequestBody AssetAuthInfoQueryReq assetAuthInfoQueryReq){
|
||||||
|
return toAjax(assetAuthInfoService.save(AssetAuthInfo.saveBuild(assetAuthInfoQueryReq, SecurityUtils::getUsername)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresPermissions("source:auth:remove")
|
||||||
|
@Log(title = "资产授权", businessType = BusinessType.DELETE)
|
||||||
|
@PostMapping("/remove")
|
||||||
|
@ApiOperation("删除资产授权")
|
||||||
|
public Result<String> remove(@RequestBody AssetAuthInfoQueryReq assetAuthInfoQueryReq){
|
||||||
|
return assetAuthInfoService.removeList(assetAuthInfoQueryReq);
|
||||||
|
}
|
||||||
|
}
|
|
@ -111,6 +111,7 @@ public class DataSourceController extends BaseController {
|
||||||
return Result.success(accessTypeList);
|
return Result.success(accessTypeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 测试连接 */
|
||||||
@PostMapping("/testConnection")
|
@PostMapping("/testConnection")
|
||||||
public Result testConnection(@RequestBody DataSourceSaveReq dataSourceSaveReq){
|
public Result testConnection(@RequestBody DataSourceSaveReq dataSourceSaveReq){
|
||||||
return dataSourceService.testConnection(dataSourceSaveReq);
|
return dataSourceService.testConnection(dataSourceSaveReq);
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.muyu.data.source.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.data.source.domain.AssetAuthInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AssetAuthInfo 数据权限Mapper层接口
|
||||||
|
*
|
||||||
|
* @author AnNan.Wang
|
||||||
|
* @ClassName: AssetAuthInfoMapper
|
||||||
|
* @createTime: 2024/5/5 18:30
|
||||||
|
*/
|
||||||
|
public interface AssetAuthInfoMapper extends BaseMapper<AssetAuthInfo> {
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.data.source.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.AssetAuthInfo;
|
||||||
|
import com.muyu.data.source.domain.req.AssetAuthInfoQueryReq;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AssetAuthInfo 资产授权 Service层接口
|
||||||
|
*
|
||||||
|
* @author AnNan.Wang
|
||||||
|
* @ClassName: AssetAuthInfoService
|
||||||
|
* @createTime: 2024/5/5 15:40
|
||||||
|
*/
|
||||||
|
public interface AssetAuthInfoService extends IService<AssetAuthInfo> {
|
||||||
|
/**
|
||||||
|
* 查询资产授权列表
|
||||||
|
*
|
||||||
|
* @param assetAuthInfo 资产授权
|
||||||
|
* @return 资产授权集合
|
||||||
|
*/
|
||||||
|
public List<AssetAuthInfo> list(AssetAuthInfo assetAuthInfo);
|
||||||
|
|
||||||
|
Result<String> removeList(AssetAuthInfoQueryReq assetAuthInfoQueryReq);
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.muyu.data.source.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
import com.muyu.data.source.domain.AssetAuthInfo;
|
||||||
|
import com.muyu.data.source.domain.req.AssetAuthInfoQueryReq;
|
||||||
|
import com.muyu.data.source.mapper.AssetAuthInfoMapper;
|
||||||
|
import com.muyu.data.source.service.AssetAuthInfoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AssetAuthInfo 资产授权Impl实现层
|
||||||
|
*
|
||||||
|
* @ClassName AssetAuthInfoServiceImpl
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/5/5 18:29
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AssetAuthInfoServiceImpl extends ServiceImpl<AssetAuthInfoMapper, AssetAuthInfo>
|
||||||
|
implements AssetAuthInfoService{
|
||||||
|
@Autowired
|
||||||
|
private AssetAuthInfoMapper assetAuthInfoMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AssetAuthInfo> list(AssetAuthInfo assetAuthInfo) {
|
||||||
|
if (Objects.isNull(assetAuthInfo.getIdType())){
|
||||||
|
throw new ServiceException("id类型不能为空");
|
||||||
|
}
|
||||||
|
if (Objects.isNull(assetAuthInfo.getAuthType())){
|
||||||
|
throw new ServiceException("授权类型不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
return list(new LambdaQueryWrapper<AssetAuthInfo>()
|
||||||
|
.eq(AssetAuthInfo::getIdType, assetAuthInfo.getIdType())
|
||||||
|
.eq(AssetAuthInfo::getAuthType, assetAuthInfo.getAuthType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> removeList(AssetAuthInfoQueryReq assetAuthInfoQueryReq) {
|
||||||
|
int delete = assetAuthInfoMapper.delete(
|
||||||
|
new LambdaQueryWrapper<AssetAuthInfo>() {{
|
||||||
|
eq(AssetAuthInfo::getAuthId, assetAuthInfoQueryReq.getAuthId());
|
||||||
|
eq(AssetAuthInfo::getIdType, assetAuthInfoQueryReq.getIdType());
|
||||||
|
eq(AssetAuthInfo::getAuthData, assetAuthInfoQueryReq.getAuthData());
|
||||||
|
eq(AssetAuthInfo::getAuthType, assetAuthInfoQueryReq.getAuthType());
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
if (delete>0) {
|
||||||
|
return Result.success("删除成功");
|
||||||
|
}else {
|
||||||
|
return Result.success("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -105,8 +105,6 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
||||||
if (con!=null){
|
if (con!=null){
|
||||||
return Result.success("连接成功");
|
return Result.success("连接成功");
|
||||||
}
|
}
|
||||||
Statement stmt = con.createStatement();
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("连接失败:"+e.getMessage());
|
log.error("连接失败:"+e.getMessage());
|
||||||
return Result.error("连接失败");
|
return Result.error("连接失败");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="logs/muyu-system"/>
|
<property name="log.path" value="logs/muyu-data-source"/>
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
`comment`,
|
`comment`,
|
||||||
`is_primary_key`,
|
`is_primary_key`,
|
||||||
`type`,
|
`type`,
|
||||||
`detail_kype`,
|
`detail_type`,
|
||||||
`length`,
|
`length`,
|
||||||
`decimal_places`,
|
`decimal_places`,
|
||||||
`is_null`,
|
`is_null`,
|
||||||
|
@ -124,6 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{databaseTable.databaseName}
|
#{databaseTable.databaseName}
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
<select id="findAccessType" resultType="com.muyu.data.source.domain.AccessType">
|
<select id="findAccessType" resultType="com.muyu.data.source.domain.AccessType">
|
||||||
select * from access_type
|
select * from access_type
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9599
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: ruoyi-rule
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 101.34.243.166:8848
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 101.34.243.166:8848
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.muyu.data.source.mapper: DEBUG
|
Loading…
Reference in New Issue