| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.common.enums.DictEnum; |
| | | import org.springblade.common.utils.arg; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.DigestUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.excel.UserExcel; |
| | | import org.springblade.modules.system.excel.UserImporter; |
| | | import org.springblade.modules.system.node.TreeNode; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.vo.DeptVO; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE; |
| | | |
| | | /** |
| | |
| | | public class UserController { |
| | | |
| | | private final IUserService userService; |
| | | private final IDeptService iDeptService; |
| | | |
| | | /** |
| | | * 查询单条 |
| | |
| | | /** |
| | | * 自定义用户列表 |
| | | */ |
| | | @GetMapping("/pages") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "realName", value = "姓名", paramType = "query", dataType = "string") |
| | | }) |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "列表", notes = "传入account和realName") |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<UserVO>> pages(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) { |
| | | IPage<UserVO> pages = userService.selectUserPages(Condition.getPage(query), user, deptId, "000000"); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 自定义用户列表 |
| | | */ |
| | | @GetMapping("/page") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"), |
| | |
| | | @ApiOperation(value = "列表", notes = "传入account和realName") |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<UserVO>> page(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) { |
| | | IPage<UserVO> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, "000000"); |
| | | return R.data(pages); |
| | | IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : bladeUser.getTenantId())); |
| | | return R.data(UserWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "导入用户", notes = "传入excel") |
| | | public R importUser(MultipartFile file, Integer isCovered) { |
| | | UserImporter userImporter = new UserImporter(userService, isCovered == 1); |
| | | UserImporter userImporter = new UserImporter(userService, false); |
| | | ExcelUtil.save(file, userImporter, UserExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | |
| | | List<Map<Object, Object>> list = userService.selectInr(deptid); |
| | | return R.data(list); |
| | | } |
| | | @GetMapping("/zc") |
| | | public R zc(String deptname,String username,String password,String sname,String phone) { |
| | | Dept dept = new Dept(); |
| | | Long i = 1426355050199945218L; |
| | | dept.setParentId(i); |
| | | dept.setTenantId("000000"); |
| | | dept.setDeptName(deptname); |
| | | dept.setAncestors("0,1426354978959691778,1426355050199945218"); |
| | | dept.setDeptCategory(1); |
| | | User user = new User(); |
| | | user.setAccount(username); |
| | | user.setPassword(DigestUtil.encrypt(password)); |
| | | user.setRealName(sname); |
| | | user.setPhone(phone); |
| | | if (iDeptService.submit(dept)) { |
| | | CacheUtil.clear(SYS_CACHE); |
| | | // 返回懒加载树更新节点所需字段 |
| | | Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId()) |
| | | .set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory())); |
| | | String id = kv.get("id").toString(); |
| | | user.setDeptId(id); |
| | | } |
| | | userService.saveOrUpdate(user); |
| | | return R.success("注册成功"); |
| | | } |
| | | |
| | | |
| | | } |