资产授权
parent
776ffd010b
commit
4332e4d363
|
@ -2,7 +2,9 @@ package com.muyu.source.controller;
|
|||
|
||||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.source.domain.AssetAuthorization;
|
||||
import com.muyu.source.domain.rep.AssetAuthorizationRep;
|
||||
import com.muyu.source.domain.req.AssetAuthorizationReq;
|
||||
import com.muyu.source.service.AssetAuthorizationService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -40,9 +42,74 @@ public class AssetAuthorizationController {
|
|||
* @return Result
|
||||
*/
|
||||
@PostMapping("/findUserIdList")
|
||||
public Result findUserIdList(@RequestBody AssetAuthorizationRep assetAuthorizationReq){
|
||||
public Result findUserIdList(@RequestBody AssetAuthorizationReq assetAuthorizationReq){
|
||||
List<Long> list = assetAuthorizationService.findUserIdList(assetAuthorizationReq);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户权限方法
|
||||
* @param req 相应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@PostMapping("/addUserAssetAccredit")
|
||||
public Result addUserAssetAccredit(@RequestBody AssetAuthorizationReq req){
|
||||
AssetAuthorization assetImpower = new AssetAuthorization();
|
||||
assetImpower.setUserId(req.getUserId());
|
||||
assetImpower.setTableId(req.getTableId());
|
||||
assetImpower.setBasicId(req.getBasicId());
|
||||
boolean save = assetAuthorizationService.save(assetImpower);
|
||||
return save?Result.success():Result.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户权限方法
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@PostMapping("/delUserAssetAccredit")
|
||||
public Result delUserAssetAccredit(@RequestBody AssetAuthorizationReq req){
|
||||
int i = assetAuthorizationService.delUserAssetAccredit(req);
|
||||
return i>0?Result.success():Result.error();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 查询资产赋权部门信息
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@PostMapping("/findDeptIdList")
|
||||
public Result findDeptIdList(@RequestBody AssetAuthorizationReq req){
|
||||
List<Long> list = assetAuthorizationService.findDeptIdList(req);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加用户权限方法
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@PostMapping("/addDeptAssetAccredit")
|
||||
public Result addDeptAssetAccredit(@RequestBody AssetAuthorizationReq req){
|
||||
AssetAuthorization assetImpower = new AssetAuthorization();
|
||||
assetImpower.setDeptId(req.getDeptId());
|
||||
assetImpower.setTableId(req.getTableId());
|
||||
assetImpower.setBasicId(req.getBasicId());
|
||||
boolean save = assetAuthorizationService.save(assetImpower);
|
||||
return save?Result.success():Result.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门权限方法
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@PostMapping("/delDeptAssetAccredit")
|
||||
public Result delDeptAssetAccredit(@RequestBody AssetAuthorizationReq req){
|
||||
int i = assetAuthorizationService.delDeptAssetAccredit(req);
|
||||
return i>0?Result.success():Result.error();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,12 @@ package com.muyu.source.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.source.domain.AssetAuthorization;
|
||||
import com.muyu.source.domain.rep.AssetAuthorizationRep;
|
||||
import com.muyu.source.domain.req.AssetAuthorizationReq;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
|
@ -14,4 +19,8 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface AssetAuthorizationMapper extends BaseMapper<AssetAuthorization> {
|
||||
List<Long> findUserIdList(AssetAuthorizationReq req);
|
||||
|
||||
|
||||
List<Long> findDeptIdList(AssetAuthorizationReq req);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
|
||||
import com.muyu.source.domain.TableInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Mapper
|
||||
public interface TableInfoMapper extends BaseMapper<TableInfo> {
|
||||
List<Long> findTableIdByParentId(@Param("basicId") Long basicId);
|
||||
}
|
||||
|
|
|
@ -14,4 +14,10 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<SysUser> {
|
||||
/**
|
||||
* 根据ID获取用户信息
|
||||
* @param userId 用户参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
SysUser findUserById(Long userId);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,31 @@ public interface AssetAuthorizationService extends IService<AssetAuthorization>
|
|||
*/
|
||||
List<AssetAuthorization> findTableIdAndBasicIdByDeptId(Long deptId);
|
||||
|
||||
List<Long> findUserIdList(AssetAuthorizationRep assetAuthorizationReq);
|
||||
/**
|
||||
* 查询资产赋权用户信息
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
|
||||
List<Long> findUserIdList(AssetAuthorizationReq req);
|
||||
/**
|
||||
* 查询资产赋权部门信息
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
List<Long> findDeptIdList(AssetAuthorizationReq req);
|
||||
|
||||
/**
|
||||
* 删除用户权限方法
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
int delUserAssetAccredit(AssetAuthorizationReq req);
|
||||
|
||||
/**
|
||||
* 删除部门权限方法
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
int delDeptAssetAccredit(AssetAuthorizationReq req);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.source.domain.AssetAuthorization;
|
||||
import com.muyu.source.domain.rep.AssetAuthorizationRep;
|
||||
import com.muyu.source.domain.req.AssetAuthorizationReq;
|
||||
import com.muyu.source.mapper.AssetAuthorizationMapper;
|
||||
import com.muyu.source.mapper.UserMapper;
|
||||
import com.muyu.source.service.AssetAuthorizationService;
|
||||
|
@ -33,6 +34,7 @@ public class AssetAuthorizationServiceImpl extends ServiceImpl<AssetAuthorizatio
|
|||
|
||||
/**
|
||||
* 查询授权的表ID和基本信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 授权的表ID和基本信息
|
||||
*/
|
||||
|
@ -41,13 +43,10 @@ public class AssetAuthorizationServiceImpl extends ServiceImpl<AssetAuthorizatio
|
|||
return assetAuthorizationMapper.selectList(new LambdaQueryWrapper<>() {{
|
||||
eq(AssetAuthorization::getUserId, userId);
|
||||
}});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门ID查询授权的表ID和基本信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 授权的表ID和基本信息
|
||||
*/
|
||||
|
@ -58,22 +57,85 @@ public class AssetAuthorizationServiceImpl extends ServiceImpl<AssetAuthorizatio
|
|||
}});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询资产赋权用户信息
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@Override
|
||||
public List<Long> findUserIdList(AssetAuthorizationRep assetAuthorizationReq) {
|
||||
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("user_id");
|
||||
Long tableId = assetAuthorizationReq.getTableId();
|
||||
Long basicId = assetAuthorizationReq.getBasicId();
|
||||
if (tableId != null) {
|
||||
queryWrapper.eq("table_id", tableId);
|
||||
public List<Long> findUserIdList(AssetAuthorizationReq req) {
|
||||
List<Long> userIdList = assetAuthorizationMapper.findUserIdList(req);
|
||||
return userIdList;
|
||||
}
|
||||
if (basicId != null) {
|
||||
queryWrapper.eq("basic_id", basicId);
|
||||
|
||||
/**
|
||||
* 查询资产赋权部门信息
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@Override
|
||||
public List<Long> findDeptIdList(AssetAuthorizationReq req) {
|
||||
List<Long> deptIdList = assetAuthorizationMapper.findDeptIdList(req);
|
||||
return deptIdList;
|
||||
}
|
||||
return userMapper.selectList(queryWrapper)
|
||||
.stream()
|
||||
.map(SysUser::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
/**
|
||||
* 删除用户权限方法
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@Override
|
||||
public int delUserAssetAccredit(AssetAuthorizationReq req) {
|
||||
LambdaQueryWrapper<AssetAuthorization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (null==req.getBasicId()){
|
||||
queryWrapper.eq(AssetAuthorization::getUserId,req.getUserId())
|
||||
.eq(AssetAuthorization::getTableId,req.getTableId());
|
||||
}else if (null==req.getTableId()){
|
||||
queryWrapper.eq(AssetAuthorization::getUserId,req.getUserId())
|
||||
.eq(AssetAuthorization::getBasicId,req.getBasicId());
|
||||
}
|
||||
|
||||
int delete = assetAuthorizationMapper.delete(queryWrapper);
|
||||
return delete;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门权限方法
|
||||
* @param req 响应参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@Override
|
||||
public int delDeptAssetAccredit(AssetAuthorizationReq req) {
|
||||
LambdaQueryWrapper<AssetAuthorization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (null==req.getBasicId()){
|
||||
queryWrapper.eq(AssetAuthorization::getDeptId,req.getDeptId())
|
||||
.eq(AssetAuthorization::getTableId,req.getTableId());
|
||||
}else if (null==req.getTableId()){
|
||||
queryWrapper.eq(AssetAuthorization::getDeptId,req.getDeptId())
|
||||
.eq(AssetAuthorization::getBasicId,req.getBasicId());
|
||||
}
|
||||
|
||||
int delete = assetAuthorizationMapper.delete(queryWrapper);
|
||||
return delete;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<Long> findUserIdList(AssetAuthorizationRep assetAuthorizationReq) {
|
||||
// QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.select("user_id");
|
||||
// Long tableId = assetAuthorizationReq.getTableId();
|
||||
// Long basicId = assetAuthorizationReq.getBasicId();
|
||||
// if (tableId != null) {
|
||||
// queryWrapper.eq("table_id", tableId);
|
||||
// }
|
||||
// if (basicId != null) {
|
||||
// queryWrapper.eq("basic_id", basicId);
|
||||
// }
|
||||
// return userMapper.selectList(queryWrapper)
|
||||
// .stream()
|
||||
// .map(SysUser::getUserId)
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,12 +22,14 @@ public class TableServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> im
|
|||
@Autowired
|
||||
private StructureMapper structureMapper;
|
||||
|
||||
/**
|
||||
* 根据表名查询表信息
|
||||
* @param tableInfoInsert 查询条件
|
||||
* @return 表信息
|
||||
*/
|
||||
@Override
|
||||
public TableInfo selectTableInfoByName(TableInfo tableInfoInsert) {
|
||||
LambdaQueryWrapper<TableInfo> tableInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// tableInfoLambdaQueryWrapper.eq(TableInfo::getId, tableInfoInsert.getId());
|
||||
//
|
||||
|
||||
tableInfoLambdaQueryWrapper.eq(TableInfo::getBasicId, tableInfoInsert.getBasicId());
|
||||
tableInfoLambdaQueryWrapper.eq(TableInfo::getTableName, tableInfoInsert.getTableName())
|
||||
.eq(TableInfo::getParentId, tableInfoInsert.getParentId());
|
||||
|
@ -36,9 +38,11 @@ public class TableServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> im
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询表结构
|
||||
* @param id id
|
||||
* @return 表结构集合
|
||||
*/
|
||||
@Override
|
||||
public List<Structure> selectTableInfoById(Integer id) {
|
||||
List<Structure> structureList = structureMapper.selectList(new LambdaQueryWrapper<>(Structure.class) {{
|
||||
|
@ -52,5 +56,14 @@ public class TableServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> im
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级id查询子表id
|
||||
* @param basicId id 父级id
|
||||
* @return 子表id集合
|
||||
*/
|
||||
@Override
|
||||
public List<Long> findTableIdByParentId(Long basicId) {
|
||||
return tableInfoMapper.findTableIdByParentId(basicId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.muyu.source.domain.SysUser;
|
||||
import com.muyu.source.mapper.UserMapper;
|
||||
import com.muyu.source.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -16,4 +17,16 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, SysUser> implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
/**
|
||||
* 根据ID获取用户信息
|
||||
* @param userId 用户参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
@Override
|
||||
public SysUser findUserById(Long userId) {
|
||||
return userMapper.findUserById(userId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,37 @@ import com.muyu.source.domain.rep.TableInfoRep;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
*/
|
||||
public interface TableInfoService extends IService<TableInfo> {
|
||||
/**
|
||||
* 根据表名查询表信息
|
||||
* @param tableInfoInsert 查询条件
|
||||
* @return TableInfo
|
||||
*/
|
||||
|
||||
TableInfo selectTableInfoByName(TableInfo tableInfoInsert);
|
||||
|
||||
/**
|
||||
* 根据表id查询表结构
|
||||
* @param id id
|
||||
* @return List<Structure>
|
||||
*/
|
||||
|
||||
List<Structure> selectTableInfoById(Integer id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据基础表id查询表名
|
||||
* @param id id
|
||||
* @return List<TableInfo>
|
||||
*/
|
||||
List<TableInfo> findTableNameById(Long id);
|
||||
|
||||
/**
|
||||
* 根据基础表id查询表id
|
||||
* @param basicId id
|
||||
* @return List<Long>
|
||||
*/
|
||||
List<Long> findTableIdByParentId(Long basicId);
|
||||
}
|
||||
|
|
|
@ -12,5 +12,5 @@ import com.muyu.source.domain.SysUser;
|
|||
* @author Lenovo
|
||||
*/
|
||||
public interface UserService extends IService<SysUser> {
|
||||
|
||||
SysUser findUserById(Long userId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?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="com.muyu.source.controller.AssetAuthorizationController">
|
||||
|
||||
|
||||
|
||||
<select id="findUserIdList" resultType="java.lang.Long">
|
||||
SELECT
|
||||
su.user_id
|
||||
FROM
|
||||
sys_user su
|
||||
LEFT JOIN asset_impower aa ON su.user_id = aa.user_id
|
||||
<where>
|
||||
<if test="tableId!=null">
|
||||
and aa.table_id = #{tableId}
|
||||
</if>
|
||||
<if test="basicId!=null">
|
||||
and aa.basic_id = #{basicId}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
</select>
|
||||
<select id="findDeptIdList" resultType="java.lang.Long">
|
||||
SELECT
|
||||
sd.dept_id
|
||||
FROM
|
||||
sys_dept sd
|
||||
LEFT JOIN asset_impower aa on sd.dept_id = aa.dept_id
|
||||
<where>
|
||||
<if test="tableId!=null">
|
||||
and aa.table_id = #{tableId}
|
||||
</if>
|
||||
<if test="basicId!=null">
|
||||
and aa.basic_id = #{basicId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,12 @@
|
|||
<?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="com.muyu.source.mapper.UserMapper">
|
||||
|
||||
|
||||
<select id="findUserById" resultType="com.muyu.common.system.domain.SysUser">
|
||||
select * from sys_user where user_id=#{userId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,19 @@
|
|||
<?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="com.muyu.source.mapper.TableInfoMapper">
|
||||
|
||||
|
||||
<select id="findTableIdByParentId" resultType="java.lang.Long">
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
table_info
|
||||
<where>
|
||||
<if test="basicId!=null">
|
||||
and parent_id = #{basicId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue