新增角色组管理功能

This commit is contained in:
lhc
2021-04-02 17:36:11 +08:00
parent dfb45ddf63
commit bc02d8e330
8 changed files with 215 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
@@ -48,7 +49,7 @@ public class RoleController {
}
@GetMapping()
@ApiOperation(value = "获取机构列表")
@ApiOperation(value = "获取角色列表")
public ResultVO<PageInfo<Map<String, Object>>> getOrgList(String data, WebPageInfo webPageInfo) {
return roleService.getRoleList(data, webPageInfo);
}
@@ -59,4 +60,10 @@ public class RoleController {
public ResultVO<Object> validCode(String code) {
return roleService.validCode(code);
}
@GetMapping("all")
@ApiOperation(value = "获取全部角色信息")
public ResultVO<List<Map<String,Object>>> getAll() {
return roleService.getAll();
}
}

View File

@@ -0,0 +1,55 @@
package com.hcframe.user.module.auth.controller;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import com.hcframe.user.module.auth.service.RoleGroupServie;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author lhc
* @version 1.0
* @className RoleGroupController
* @date 2021年04月02日 10:11 上午
* @description 描述
*/
@RestController
@Api(tags = "角色组管理")
@RequestMapping("roleGroup")
public class RoleGroupController {
final RoleGroupServie roleGroupServie;
public RoleGroupController(RoleGroupServie roleGroupServie) {
this.roleGroupServie = roleGroupServie;
}
@PostMapping()
@ApiOperation(value = "新增角色组", notes = "给后台传key-value对象模式即可")
public ResultVO<Map<String,Object>> addRole(@RequestParam Map<String, Object> roleGroup) {
return roleGroupServie.add(roleGroup);
}
@PutMapping("/{version}")
@ApiOperation(value = "更新角色组")
public ResultVO<Integer> updateRole(@RequestParam Map<String, Object> roleGroup, @PathVariable Integer version) {
return roleGroupServie.update(roleGroup, version);
}
@DeleteMapping("/{ids}")
@ApiOperation(value = "删除角色组", notes = "删除后关联表数据也会被删除")
public ResultVO<Integer> deleteOrg(@PathVariable String ids) {
return roleGroupServie.delete(ids);
}
@GetMapping()
@ApiOperation(value = "获取角色组列表")
public ResultVO<PageInfo<Map<String, Object>>> getOrgList(String data, WebPageInfo webPageInfo) {
return roleGroupServie.getList(data, webPageInfo);
}
}

View File

@@ -0,0 +1,15 @@
package com.hcframe.user.module.auth.mapper;
import java.util.List;
import java.util.Map;
/**
* @author lhc
* @version 1.0
* @className RoleMapper
* @date 2021年04月02日 4:22 下午
* @description 描述
*/
public interface RoleDao {
List<Map<String, Object>> getAllList();
}

View File

@@ -0,0 +1,35 @@
package com.hcframe.user.module.auth.mapper.impl;
import com.hcframe.base.module.data.module.BaseMapper;
import com.hcframe.base.module.data.module.BaseMapperImpl;
import com.hcframe.user.module.auth.mapper.RoleDao;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* @author lhc
* @version 1.0
* @className RoleDaoImpl
* @date 2021年04月02日 4:23 下午
* @description 描述
*/
@Component
public class RoleDaoImpl implements RoleDao {
final BaseMapper baseMapper;
public RoleDaoImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper) {
this.baseMapper = baseMapper;
}
@Override
public List<Map<String, Object>> getAllList() {
String sql = "SELECT ROLE_ID,ROLE_NAME FROM OS_SYS_ROLE";
return baseMapper.selectSql(sql);
}
}

View File

@@ -0,0 +1,26 @@
package com.hcframe.user.module.auth.service;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import java.util.Map;
/**
* @author lhc
* @version 1.0
* @className RoleGroupServie
* @date 2021年04月02日 10:09 上午
* @description 描述
*/
public interface RoleGroupServie {
ResultVO<Map<String,Object>> add(Map<String, Object> roleGroup);
ResultVO<Integer> update(Map<String, Object> roleGroup, Integer version);
ResultVO<Integer> delete(String ids);
ResultVO<PageInfo<Map<String, Object>>> getList(String data, WebPageInfo webPageInfo);
}

View File

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import java.util.List;
import java.util.Map;
/**
@@ -23,4 +24,6 @@ public interface RoleService {
ResultVO<PageInfo<Map<String, Object>>> getRoleList(String data, WebPageInfo webPageInfo);
ResultVO<Object> validCode(String code);
ResultVO<List<Map<String, Object>>> getAll();
}

View File

@@ -0,0 +1,61 @@
package com.hcframe.user.module.auth.service.impl;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import com.hcframe.base.module.data.module.BaseMapper;
import com.hcframe.base.module.data.module.BaseMapperImpl;
import com.hcframe.base.module.data.service.TableService;
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
import com.hcframe.user.module.auth.service.RoleGroupServie;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* @author lhc
* @version 1.0
* @className RoleGroupService
* @date 2021年04月02日 10:10 上午
* @description 描述
*/
@Service
public class RoleGroupServiceImpl implements RoleGroupServie {
private static final String PK_ID = "GROUP_ID";
private static final String TABLE_NAME = "OS_SYS_ROLE_GROUP";
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(TABLE_NAME).tablePk(PK_ID).build();
final BaseMapper baseMapper;
final TableService tableService;
public RoleGroupServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
TableService tableService) {
this.baseMapper = baseMapper;
this.tableService = tableService;
}
@Override
public ResultVO<Map<String,Object>> add(Map<String, Object> roleGroup) {
return tableService.saveWithDate(TABLE_INFO,roleGroup);
}
@Override
public ResultVO<Integer> update(Map<String, Object> roleGroup, Integer version) {
return tableService.updateWithDate(TABLE_INFO, roleGroup, version);
}
@Override
public ResultVO<Integer> delete(String ids) {
// TODO 补全删除的关联信息
return tableService.delete(TABLE_INFO, ids);
}
@Override
public ResultVO<PageInfo<Map<String, Object>>> getList(String data, WebPageInfo webPageInfo) {
return ResultVO.getSuccess(tableService.searchSingleTables(data, TABLE_INFO, webPageInfo));
}
}

View File

@@ -8,11 +8,13 @@ import com.hcframe.base.module.data.module.BaseMapperImpl;
import com.hcframe.base.module.data.module.Condition;
import com.hcframe.base.module.data.service.TableService;
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
import com.hcframe.user.module.auth.mapper.RoleDao;
import com.hcframe.user.module.auth.service.RoleService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
@@ -33,10 +35,14 @@ public class RoleServiceImpl implements RoleService {
final TableService tableService;
final RoleDao roleDao;
public RoleServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
TableService tableService) {
TableService tableService,
RoleDao roleDao) {
this.baseMapper = baseMapper;
this.tableService = tableService;
this.roleDao = roleDao;
}
@Override
@@ -72,4 +78,9 @@ public class RoleServiceImpl implements RoleService {
}
return ResultVO.getSuccess();
}
@Override
public ResultVO<List<Map<String, Object>>> getAll() {
return ResultVO.getSuccess(roleDao.getAllList());
}
}