新增角色管理代码
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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.RoleService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lhc
|
||||
* @version 1.0
|
||||
* @className RoleController
|
||||
* @date 2021年03月26日 9:40 上午
|
||||
* @description 角色管理
|
||||
*/
|
||||
@RestController
|
||||
public class RoleController {
|
||||
|
||||
final RoleService roleService;
|
||||
|
||||
public RoleController(RoleService roleService) {
|
||||
this.roleService = roleService;
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@ApiOperation(value = "新增role", notes = "给后台传key-value对象模式即可")
|
||||
public ResultVO<Object> addRole(@RequestParam Map<String,Object> role) {
|
||||
return roleService.addRole(role);
|
||||
}
|
||||
|
||||
@PutMapping("/{version}")
|
||||
@ApiOperation(value = "更新role")
|
||||
public ResultVO<Integer> updateRole(@RequestParam Map<String,Object> role,@PathVariable Integer version) {
|
||||
return roleService.updateRole(role,version);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation(value = "删除role", notes = "删除后关联表数据也会被删除")
|
||||
public ResultVO<Object> deleteOrg(@PathVariable String ids) {
|
||||
return roleService.deleteRole(ids);
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@ApiOperation(value = "获取机构列表")
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getOrgList(String data, WebPageInfo webPageInfo) {
|
||||
return roleService.getRoleList(data, webPageInfo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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 RoleService
|
||||
* @date 2021年03月26日 9:42 上午
|
||||
* @description 描述
|
||||
*/
|
||||
public interface RoleService {
|
||||
ResultVO<Object> addRole(Map<String, Object> role);
|
||||
|
||||
ResultVO<Integer> updateRole(Map<String, Object> role, Integer version);
|
||||
|
||||
ResultVO<Object> deleteRole(String ids);
|
||||
|
||||
ResultVO<PageInfo<Map<String, Object>>> getRoleList(String data, WebPageInfo webPageInfo);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
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.RoleService;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lhc
|
||||
* @version 1.0
|
||||
* @className RoleServiceImpl
|
||||
* @date 2021年03月26日 9:42 上午
|
||||
* @description 描述
|
||||
*/
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
private static final String PK_ID = "ORG_ID";
|
||||
private static final String TABLE_NAME = "OS_SYS_ORG";
|
||||
private static final String OS_SYS_POSITION = "OS_SYS_POSITION";
|
||||
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(TABLE_NAME).tablePk(PK_ID).build();
|
||||
|
||||
final BaseMapper baseMapper;
|
||||
|
||||
final TableService tableService;
|
||||
|
||||
public RoleServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
|
||||
TableService tableService) {
|
||||
this.baseMapper = baseMapper;
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> addRole(Map<String, Object> role) {
|
||||
baseMapper.save(TABLE_NAME,PK_ID,role);
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Integer> updateRole(Map<String, Object> role, Integer version) {
|
||||
return tableService.updateWithDate(TABLE_INFO,role,version);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Object> deleteRole(String ids) {
|
||||
// TODO 补全需要删除的关联表
|
||||
tableService.delete(TABLE_INFO, ids);
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<PageInfo<Map<String, Object>>> getRoleList(String data, WebPageInfo webPageInfo) {
|
||||
return ResultVO.getSuccess(tableService.searchSingleTables(data, TABLE_INFO, webPageInfo));
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,4 @@ public class OrgController {
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getOrgList(String data, WebPageInfo webPageInfo) {
|
||||
return orgService.getOrgList(data, webPageInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -66,5 +66,4 @@ public class OrgServiceImpl implements OrgService {
|
||||
PageInfo<Map<String,Object>> pageInfo = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
|
||||
return ResultVO.getSuccess(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user