| | |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.sys.RoleEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.entity.ctrl.UserUpdateEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | |
| | | TokenService tokenService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", required = false, example = "室") |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(String uname) { |
| | | try { |
| | | int count = userService.selectCount(uname); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uname", value = "用戶名", dataType = "String", paramType = "query", example = "室"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<UserEntity>> selectByPage(String uname, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | List<UserEntity> rs = userService.selectByPage(uname, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "室"), |
| | | @ApiImplicitParam(name = "depcode", value = "单位编码", dataType = "String", paramType = "query", example = "00"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageAndCount") |
| | | public ResponseMsg<List<UserEntity>> selectByPageAndCount(String uname, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<UserEntity>> selectByPageAndCount(String uname, String depcode, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | int count = userService.selectCount(uname); |
| | | |
| | | int count = userService.selectCount(uname, depcode); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | List<UserEntity> rs = userService.selectByPage(uname, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | List<UserEntity> rs = userService.selectByPage(uname, depcode, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "室"), |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "depid", value = "单位ID", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "depcode", value = "单位编码", dataType = "String", paramType = "query", example = "00"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageForRole") |
| | | public ResponseMsg<List<UserEntity>> selectByPageForRole(String uname, Integer roleid, Integer depid, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<UserEntity>> selectByPageForRole(String uname, Integer roleid, String depcode, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | int count = userService.selectCountForRole(uname, roleid, depid); |
| | | int count = userService.selectCountForRole(uname, roleid, depcode); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<UserEntity> rs = userService.selectByPageForRole(uname, roleid, depid, pageSize, pageSize * (pageIndex - 1)); |
| | | List<UserEntity> rs = userService.selectByPageForRole(uname, roleid, depcode, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(userEntity); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(userEntity); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success("成功", rows > 0); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), false); |
| | | return fail(ex, false); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success("成功", rows > 0); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), false); |
| | | return fail(ex, false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询管理员用户") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "type", value = "管理员类别", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectAdminUsers") |
| | | public ResponseMsg<Object> selectAdminUsers(Integer type) { |
| | | try { |
| | | if (null == type || type < 1) { |
| | | return fail("管理员类别不能为空或小于1", false); |
| | | } |
| | | |
| | | List<UserEntity> rs = userService.selectAdminUsers(type); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据用户ID查询角色") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "用户ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectRoleByUserId") |
| | | public ResponseMsg<Object> selectRoleByUserId(Integer id) { |
| | | try { |
| | | if (null == id || id < 1) { |
| | | return fail("用户ID不能为空或小于1", false); |
| | | } |
| | | |
| | | List<RoleEntity> rs = userService.selectRoleByUserId(id); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据角色查询用户") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "角色ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectUserByRoleId") |
| | | public ResponseMsg<Object> selectUserByRoleId(Integer id) { |
| | | try { |
| | | if (null == id || id < 1) { |
| | | return fail("用户ID不能为空或小于1", false); |
| | | } |
| | | |
| | | List<UserEntity> rs = userService.selectUserByRoleId(id); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, false); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | |
| | | int count = userService.updateUsers(entity); |
| | | int count = userService.updateUser(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rows > 0 ? "更新成功" : "更新失败", rows > 0); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), false); |
| | | return fail(ex, false); |
| | | } |
| | | } |
| | | } |