修复角色后台,新增角色表单校验功能

This commit is contained in:
lhc
2021-04-01 09:08:18 +08:00
parent 7c37b88f4f
commit 6d8f167f21
3 changed files with 28 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import com.hcframe.user.module.auth.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
@@ -30,14 +31,14 @@ public class RoleController {
@PostMapping()
@ApiOperation(value = "新增role", notes = "给后台传key-value对象模式即可")
public ResultVO<Object> addRole(@RequestParam Map<String,Object> role) {
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);
public ResultVO<Integer> updateRole(@RequestParam Map<String, Object> role, @PathVariable Integer version) {
return roleService.updateRole(role, version);
}
@DeleteMapping("/{ids}")
@@ -48,7 +49,14 @@ public class RoleController {
@GetMapping()
@ApiOperation(value = "获取机构列表")
public ResultVO<PageInfo<Map<String,Object>>> getOrgList(String data, WebPageInfo webPageInfo) {
public ResultVO<PageInfo<Map<String, Object>>> getOrgList(String data, WebPageInfo webPageInfo) {
return roleService.getRoleList(data, webPageInfo);
}
@GetMapping("valid")
@ApiOperation(value = "校验角色是否重复")
@ApiImplicitParam(name = "code", value = "角色编码")
public ResultVO<Object> validCode(String code) {
return roleService.validCode(code);
}
}

View File

@@ -21,4 +21,6 @@ public interface RoleService {
ResultVO<Object> deleteRole(String ids);
ResultVO<PageInfo<Map<String, Object>>> getRoleList(String data, WebPageInfo webPageInfo);
ResultVO<Object> validCode(String code);
}

View File

@@ -5,6 +5,7 @@ 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.module.Condition;
import com.hcframe.base.module.data.service.TableService;
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
import com.hcframe.user.module.auth.service.RoleService;
@@ -33,20 +34,20 @@ public class RoleServiceImpl implements RoleService {
final TableService tableService;
public RoleServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
TableService tableService) {
TableService tableService) {
this.baseMapper = baseMapper;
this.tableService = tableService;
}
@Override
public ResultVO<Object> addRole(Map<String, Object> role) {
tableService.saveWithDate(TABLE_INFO,role);
tableService.saveWithDate(TABLE_INFO, role);
return ResultVO.getSuccess();
}
@Override
public ResultVO<Integer> updateRole(Map<String, Object> role, Integer version) {
return tableService.updateWithDate(TABLE_INFO,role,version);
return tableService.updateWithDate(TABLE_INFO, role, version);
}
@Override
@@ -61,4 +62,14 @@ public class RoleServiceImpl implements RoleService {
public ResultVO<PageInfo<Map<String, Object>>> getRoleList(String data, WebPageInfo webPageInfo) {
return ResultVO.getSuccess(tableService.searchSingleTables(data, TABLE_INFO, webPageInfo));
}
@Override
public ResultVO<Object> validCode(String code) {
Condition condition = Condition.creatCriteria().andEqual("ROLE_CODE", code).build();
Long i = baseMapper.count(TABLE_NAME, condition);
if (i > 0L) {
return ResultVO.getFailed("角色编码不能重复");
}
return ResultVO.getSuccess();
}
}