feat(AssetAuthInfoController):新增资产授权修改
parent
01c567140e
commit
609b6478b6
|
@ -0,0 +1,82 @@
|
|||
package com.ruoyi.etl.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.etl.domain.req.AssetAuthInfoQueryReq;
|
||||
import com.ruoyi.etl.domain.req.AssetAuthInfoSaveReq;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 资产授权对象 asset_auth_info
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("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 = "授权编号", 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;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
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(AssetAuthInfoSaveReq assetAuthInfoSaveReq,Supplier<String> createBy){
|
||||
return AssetAuthInfo.builder()
|
||||
.authId(assetAuthInfoSaveReq.getAuthId())
|
||||
.idType(assetAuthInfoSaveReq.getIdType())
|
||||
.authData(assetAuthInfoSaveReq.getAuthData())
|
||||
.authType(assetAuthInfoSaveReq.getAuthType())
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.ruoyi.etl.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 资产授权对象 asset_auth_info
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@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,51 @@
|
|||
package com.ruoyi.etl.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 资产授权对象 asset_auth_info
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@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,73 @@
|
|||
package com.ruoyi.etl.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.etl.domain.AssetAuthInfo;
|
||||
import com.ruoyi.etl.domain.req.AssetAuthInfoQueryReq;
|
||||
import com.ruoyi.etl.domain.req.AssetAuthInfoSaveReq;
|
||||
import com.ruoyi.etl.service.AssetAuthInfoService;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 资产授权Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Api(tags = "资产授权")
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AssetAuthInfoController extends BaseController {
|
||||
@Autowired
|
||||
private AssetAuthInfoService assetAuthInfoService;
|
||||
|
||||
/**
|
||||
* 查询资产授权列表
|
||||
*/
|
||||
@ApiOperation("获取资产授权列表")
|
||||
@RequiresPermissions("etl:auth:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<AssetAuthInfo>> list(AssetAuthInfoQueryReq assetAuthInfoQueryReq) {
|
||||
startPage();
|
||||
List<AssetAuthInfo> list = assetAuthInfoService.list(AssetAuthInfo.queryBuild(assetAuthInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增资产授权
|
||||
*/
|
||||
@RequiresPermissions("etl:auth:add")
|
||||
@Log(title = "资产授权", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增资产授权")
|
||||
public Result<String> add(@RequestBody AssetAuthInfoSaveReq assetAuthInfoSaveReq) {
|
||||
return toAjax(assetAuthInfoService.save(AssetAuthInfo.saveBuild(assetAuthInfoSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除资产授权
|
||||
*/
|
||||
@RequiresPermissions("etl:auth:remove")
|
||||
@Log(title = "资产授权", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除资产授权")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(assetAuthInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.etl.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.etl.domain.AssetAuthInfo;
|
||||
|
||||
/**
|
||||
* 资产授权Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface AssetAuthInfoMapper extends BaseMapper<AssetAuthInfo> {
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.ruoyi.etl.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.etl.domain.AssetAuthInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 资产授权Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface AssetAuthInfoService extends IService<AssetAuthInfo> {
|
||||
/**
|
||||
* 查询资产授权列表
|
||||
*
|
||||
* @param assetAuthInfo 资产授权
|
||||
* @return 资产授权集合
|
||||
*/
|
||||
public List<AssetAuthInfo> list(AssetAuthInfo assetAuthInfo);
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.ruoyi.etl.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.etl.mapper.AssetAuthInfoMapper;
|
||||
import com.ruoyi.etl.domain.AssetAuthInfo;
|
||||
import com.ruoyi.etl.service.AssetAuthInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
/**
|
||||
* 资产授权Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AssetAuthInfoServiceImpl extends ServiceImpl<AssetAuthInfoMapper, AssetAuthInfo> implements AssetAuthInfoService {
|
||||
|
||||
/**
|
||||
* 查询资产授权列表
|
||||
*
|
||||
* @param assetAuthInfo 资产授权
|
||||
* @return 资产授权
|
||||
*/
|
||||
@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()));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue