Merge pull request #23 from dibo-software/develop

Develop
This commit is contained in:
Mazc 2019-08-09 12:35:30 +08:00 committed by GitHub
commit 34d8dbd69d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 58 deletions

View File

@ -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);
}

View File

@ -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())){

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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

View File

@ -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);
// 返回结果