commit
34d8dbd69d
|
@ -59,6 +59,9 @@ public class BaseController {
|
|||
* @return
|
||||
*/
|
||||
public <T,DTO> QueryWrapper<T> buildQueryWrapper(DTO entityOrDto) throws Exception{
|
||||
if(entityOrDto instanceof HttpServletRequest){
|
||||
throw new Exception("参数错误:buildQueryWrapper()参数为Entity/DTO对象!");
|
||||
}
|
||||
return QueryBuilder.toQueryWrapper(entityOrDto);
|
||||
}
|
||||
|
||||
|
@ -69,6 +72,9 @@ public class BaseController {
|
|||
* @return
|
||||
*/
|
||||
public <T,DTO> LambdaQueryWrapper<T> buildLambdaQueryWrapper(DTO entityOrDto) throws Exception{
|
||||
if(entityOrDto instanceof HttpServletRequest){
|
||||
throw new Exception("参数错误:buildQueryWrapper()参数为Entity/DTO对象!");
|
||||
}
|
||||
return QueryBuilder.toLambdaQueryWrapper(entityOrDto);
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ public class BeanUtils {
|
|||
String key = null;
|
||||
if(V.isEmpty(fields)){
|
||||
//未指定字段,以id为key
|
||||
key = getStringProperty(model, Cons.FieldName.parentId.name());
|
||||
key = getStringProperty(model, Cons.FieldName.id.name());
|
||||
}
|
||||
// 指定了一个字段,以该字段为key,类型同该字段
|
||||
else if(fields.length == 1){
|
||||
|
@ -306,7 +306,7 @@ public class BeanUtils {
|
|||
*/
|
||||
private static <T extends BaseEntity> void buildDeeperLevelTree(List<T> parentModels, List<T> allModels){
|
||||
List<T> deeperLevelModels = new ArrayList();
|
||||
Map<String, T> parentLevelModelMap = convertToStringKeyObjectMap(parentModels);
|
||||
Map<String, T> parentLevelModelMap = convertToStringKeyObjectMap(parentModels, Cons.FieldName.id.name());
|
||||
for(T model : allModels){
|
||||
Object parentId = getProperty(model, Cons.FieldName.parentId.name());
|
||||
if(parentLevelModelMap.keySet().contains(String.valueOf(parentId)) && !parentId.equals(model.getId())){
|
||||
|
|
|
@ -58,15 +58,11 @@ public class SysUserController extends BaseCrudRestController {
|
|||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("list"), name = "列表")
|
||||
public JsonResult getVOList(SysUser sysUser, Pagination pagination, HttpServletRequest request) throws Exception{
|
||||
QueryWrapper<User> queryWrapper = super.buildQueryWrapper(sysUser);
|
||||
return super.getVOListWithPaging(queryWrapper, pagination, UserVO.class);
|
||||
return super.getVOListWithPaging(queryWrapper, pagination, SysUserVO.class);
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -157,13 +153,6 @@ public class SysUserController extends BaseCrudRestController {
|
|||
List<KeyValue> roleKvList = roleService.getKeyValueList(wrapper);
|
||||
modelMap.put("roleKvList", roleKvList);
|
||||
|
||||
//获取部门KV
|
||||
wrapper = new QueryWrapper<Department>()
|
||||
.lambda()
|
||||
.select(Department::getName, Department::getId);
|
||||
List<KeyValue> departmentKvList = departmentService.getKeyValueList(wrapper);
|
||||
modelMap.put("departmentKvList", departmentKvList);
|
||||
|
||||
//获取用户状态KV
|
||||
List<KeyValue> userStatusKvList = dictionaryService.getKeyValueList(SysUser.USER_STATUS);
|
||||
modelMap.put("userStatusKvList", userStatusKvList);
|
||||
|
|
|
@ -16,9 +16,6 @@ import java.util.List;
|
|||
*/
|
||||
public interface SysUserService extends BaseService<SysUser> {
|
||||
|
||||
//获取列表数据
|
||||
List<SysUserVO> getSysUserList(Wrapper queryWrapper, Pagination pagination);
|
||||
|
||||
//获取详细
|
||||
SysUserVO getSysUser(Long id);
|
||||
|
||||
|
|
|
@ -38,25 +38,6 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
|||
@Autowired
|
||||
private UserRoleService userRoleService;
|
||||
|
||||
@Override
|
||||
public List<SysUserVO> getSysUserList(Wrapper queryWrapper, Pagination pagination) {
|
||||
List<SysUser> sysUserList = super.getEntityList(queryWrapper, pagination);
|
||||
List<SysUserVO> sysUserVOList = RelationsBinder.convertAndBind(sysUserList, SysUserVO.class);
|
||||
if(V.notEmpty(sysUserVOList)){
|
||||
for(SysUserVO sysUserVO : sysUserVOList){
|
||||
List<Role> roleList = sysUserVO.getRoleList();
|
||||
if(V.notEmpty(roleList)){
|
||||
List<String> roleNameList = new ArrayList();
|
||||
for(Role role : roleList){
|
||||
roleNameList.add(role.getName());
|
||||
}
|
||||
sysUserVO.setRoleNameList(roleNameList);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sysUserVOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserVO getSysUser(Long id) {
|
||||
SysUserVO sysUserVO = super.getViewObject(id, SysUserVO.class);
|
||||
|
|
|
@ -21,9 +21,6 @@ public class SysUserVO extends SysUser {
|
|||
|
||||
private static final long serialVersionUID = 5921846275434221060L;
|
||||
|
||||
@BindField(entity=Department.class, field="name", condition="this.department_id=id")
|
||||
private String departmentName;
|
||||
|
||||
@BindDict(type="GENDER", field="gender")
|
||||
private String genderLabel;
|
||||
|
||||
|
@ -36,7 +33,4 @@ public class SysUserVO extends SysUser {
|
|||
@TableField(exist = false)
|
||||
private List<Long> roleIdList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> roleNameList;
|
||||
|
||||
}
|
|
@ -39,20 +39,6 @@ public class PermissionController extends BaseCrudRestController {
|
|||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
|
||||
/***
|
||||
* 查询Entity
|
||||
* @param id ID
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("read"), name = "读取")
|
||||
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request)
|
||||
throws Exception{
|
||||
PermissionVO vo = permissionService.getViewObject(id, PermissionVO.class);
|
||||
return new JsonResult(vo);
|
||||
}
|
||||
|
||||
/***
|
||||
* 查询ViewObject的分页数据 (此为非继承的自定义使用案例,更简化的调用父类案例请参考UserController)
|
||||
* <p>
|
||||
|
@ -71,6 +57,20 @@ public class PermissionController extends BaseCrudRestController {
|
|||
return new JsonResult(Status.OK, entityList).bindPagination(pagination);
|
||||
}
|
||||
|
||||
/***
|
||||
* 查询Entity
|
||||
* @param id ID
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("read"), name = "读取")
|
||||
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request)
|
||||
throws Exception{
|
||||
PermissionVO vo = permissionService.getViewObject(id, PermissionVO.class);
|
||||
return new JsonResult(vo);
|
||||
}
|
||||
|
||||
/***
|
||||
* 创建Entity
|
||||
* @return
|
||||
|
|
|
@ -50,8 +50,8 @@ public class RoleController extends BaseCrudRestController {
|
|||
@GetMapping("/list")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("list"), name = "列表")
|
||||
@AuthorizationCache
|
||||
public JsonResult getVOList(HttpServletRequest request, Pagination pagination) throws Exception{
|
||||
QueryWrapper<Role> queryWrapper = buildQueryWrapper(request);
|
||||
public JsonResult getVOList(Role role, Pagination pagination, HttpServletRequest request) throws Exception{
|
||||
QueryWrapper<Role> queryWrapper = super.buildQueryWrapper(role);
|
||||
// 获取结果
|
||||
List<RoleVO> voList = roleService.getRoleList(queryWrapper, pagination);
|
||||
// 返回结果
|
||||
|
|
Loading…
Reference in New Issue