diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/utils/dto/CurrentUser.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/utils/dto/CurrentUser.java index e599129..a668d10 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/utils/dto/CurrentUser.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/utils/dto/CurrentUser.java @@ -3,8 +3,8 @@ package org.nl.modules.common.utils.dto; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; -import org.nl.modules.system.domain.User; import org.nl.modules.system.service.dto.UserDto; +import org.nl.system.service.user.dao.User; import java.io.Serializable; import java.util.ArrayList; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/security/rest/AuthorizationController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/security/rest/AuthorizationController.java index b2d57f5..1cda976 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/security/rest/AuthorizationController.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/security/rest/AuthorizationController.java @@ -39,9 +39,9 @@ import org.nl.modules.security.config.bean.LoginProperties; import org.nl.modules.security.service.OnlineUserService; import org.nl.modules.security.service.dto.AuthUserDto; import org.nl.modules.system.service.RoleService; -import org.nl.modules.system.service.UserService; import org.nl.modules.system.service.dto.UserDto; import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.system.service.user.UserService; import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -114,7 +114,7 @@ public class AuthorizationController { user.setId(userInfo.getLong("user_id")); user.setUsername(userInfo.getString("username")); user.setPreson_name((userInfo.getString("person_name"))); - user.setUser(userService.findById(userInfo.getLong("user_id"))); + user.setUser(userService.getById(userInfo.getLong("user_id"))); user.setPermissions(permissionList); // SaLoginModel 配置登录相关参数 diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/Role.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/Role.java index b7733f1..49d1f32 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/Role.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/Role.java @@ -18,6 +18,7 @@ package org.nl.modules.system.domain; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import org.nl.system.service.user.dao.User; import javax.validation.constraints.NotBlank; import java.io.Serializable; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java deleted file mode 100644 index 2da09c5..0000000 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nl.modules.system.domain; - -import com.alibaba.fastjson.annotation.JSONField; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; -import org.nl.modules.common.base.BaseDTO; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.util.Date; - -/** - * @author Zheng Jie - * @date 2018-11-22 - */ -@Getter -@Setter -public class User extends BaseDTO implements Serializable { - - - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - - private Long user_id; - @JsonFormat - private String roles; - - private String depts; - - - - private String username; - - - private String person_name; - - @ApiModelProperty(value = "邮箱") - private String email; - - @ApiModelProperty(value = "电话号码") - private String phone; - - @ApiModelProperty(value = "用户性别") - private String gender; - - @ApiModelProperty(value = "头像真实名称",hidden = true) - private String avatarName; - - @ApiModelProperty(value = "头像存储的路径", hidden = true) - private String avatarPath; - - @ApiModelProperty(value = "密码") - private String password; - - @NotNull - @ApiModelProperty(value = "是否启用") - private String is_used; - - @ApiModelProperty(value = "是否为admin账号", hidden = true) - private Boolean isAdmin = false; - - @ApiModelProperty(value = "最后修改密码的时间", hidden = true) - private Date pwdResetTime; - -} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/vo/RoleVo.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/vo/RoleVo.java index 4d464c7..c42ba42 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/vo/RoleVo.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/vo/RoleVo.java @@ -18,8 +18,6 @@ package org.nl.modules.system.domain.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; -import org.nl.modules.system.domain.Menu; -import org.nl.modules.system.domain.User; import javax.validation.constraints.NotBlank; import java.io.Serializable; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/DeptController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/DeptController.java deleted file mode 100644 index c868f71..0000000 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/DeptController.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nl.modules.system.rest; - -import cn.dev33.satoken.annotation.SaCheckPermission; -import cn.dev33.satoken.annotation.SaMode; -import cn.hutool.core.collection.CollectionUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.apache.poi.ss.formula.functions.T; -import org.nl.modules.common.exception.BadRequestException; -import org.nl.modules.common.utils.PageUtil; -import org.nl.modules.logging.annotation.Log; -import org.nl.modules.system.domain.Dept; -import org.nl.modules.system.domain.vo.DeptVo; -import org.nl.modules.system.service.DeptService; -import org.nl.modules.system.service.dto.DeptDto; -import org.nl.modules.system.service.dto.DeptQueryCriteria; -import org.nl.modules.system.service.dto.DeptTree; -import org.nl.modules.system.util.CopyUtil; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.*; - -/** -* @author Zheng Jie -* @date 2019-03-25 -*/ -@RestController -@RequiredArgsConstructor -@Api(tags = "系统:部门管理") -@RequestMapping("/api/dept") -public class DeptController { - - private final DeptService deptService; - private static final String ENTITY_NAME = "dept"; - - @ApiOperation("查询部门") - @GetMapping -// @SaCheckPermission(value = {"user:list", "dept:list"}, mode = SaMode.AND) - public ResponseEntity query(DeptQueryCriteria criteria) throws Exception { - List deptDtos = deptService.queryAll(criteria, true); - return new ResponseEntity<>(PageUtil.toPage(deptDtos, deptDtos.size()),HttpStatus.OK); - } - - @ApiOperation("查询部门") - @GetMapping("/vo") - public ResponseEntity queryvo(DeptQueryCriteria criteria) throws Exception { - if (criteria.getPid() == null){ - criteria.setPidIsNull(true); - } - List deptDtos = deptService.queryAll(criteria, true); - List deptVos = CopyUtil.copyList(deptDtos, DeptVo.class); - return new ResponseEntity<>(PageUtil.toPage(deptVos, deptVos.size()),HttpStatus.OK); - } - - - @ApiOperation("查询所有部门树") - @GetMapping("/allTree") - public ResponseEntity allTree(DeptQueryCriteria criteria) throws Exception { - List deptDtos = deptService.queryAll(criteria, true); - JSONArray array = JSON.parseArray(JSON.toJSONString(deptDtos)); - List deptTrees = array.toJavaList(DeptTree.class); - Object o = deptService.buildTree(deptTrees); - return new ResponseEntity<>(o,HttpStatus.OK); - } - - @ApiOperation("查询部门:根据ID获取同级与上级数据") - @PostMapping("/superior") - @SaCheckPermission(value = {"user:list", "dept:list"}, mode = SaMode.AND) - public ResponseEntity getSuperior(@RequestBody List ids) { - Set deptDtos = new LinkedHashSet<>(); - for (Long id : ids) { - DeptTree deptTree = deptService.findById(id, DeptTree.class); - List superior = deptService.getSuperior(deptTree, new ArrayList<>()); - deptDtos.addAll(superior); - } - List deptVos = CopyUtil.copyList(deptDtos, DeptVo.class); - return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptDtos)),HttpStatus.OK); - } - - @Log("新增部门") - @ApiOperation("新增部门") - @PostMapping -// @SaCheckPermission("dept:add") - public ResponseEntity create(@Validated @RequestBody Dept resources){ - if (resources.getDept_id() != null) { - throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); - } - deptService.create(resources); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @Log("修改部门") - @ApiOperation("修改部门") - @PutMapping -// @SaCheckPermission("dept:edit") - public ResponseEntity update(@RequestBody Dept resources){ - deptService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Log("删除部门") - @ApiOperation("删除部门") - @DeleteMapping -// @SaCheckPermission("dept:del") - public ResponseEntity delete(@RequestBody Set ids){ - deptService.delete(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java deleted file mode 100644 index a200b1f..0000000 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nl.modules.system.rest; - -import cn.dev33.satoken.annotation.SaCheckPermission; -import cn.dev33.satoken.secure.SaSecureUtil; -import cn.dev33.satoken.stp.StpUtil; -import cn.hutool.core.util.ObjectUtil; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.nl.modules.common.config.RsaProperties; -import org.nl.modules.common.exception.BadRequestException; -import org.nl.modules.common.utils.RedisUtils; -import org.nl.modules.common.utils.RsaUtils; -import org.nl.modules.common.utils.SecurityUtils; -import org.nl.modules.logging.annotation.Log; -import org.nl.modules.system.domain.User; -import org.nl.modules.system.service.UserRelateService; -import org.nl.modules.system.service.UserService; -import org.nl.modules.system.service.dto.UserQueryCriteria; -import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import java.util.Set; - -/** - * @author Zheng Jie - * @date 2018-11-23 - */ -@Api(tags = "系统:用户管理") -@RestController -@RequestMapping("/api/users") -@RequiredArgsConstructor -public class UserController { - private final UserService userService; - private final RedisUtils redisUtils; - - @ApiOperation("查询用户") - @GetMapping -// @SaCheckPermission("user:list") - public ResponseEntity query(UserQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @Log("新增用户") - @ApiOperation("新增用户") - @PostMapping -// @SaCheckPermission("user:add") - public ResponseEntity create(@Validated @RequestBody User resources){ - checkLevel(resources); - // 默认密码 123456 - if (ObjectUtil.isEmpty(resources.getPassword())) { - resources.setPassword(SaSecureUtil.md5BySalt("123456", "salt")); - } else { - resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt")); - } - userService.create(resources); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @Log("修改用户") - @ApiOperation("修改用户") - @PutMapping -// @SaCheckPermission("user:edit") - public ResponseEntity update( @RequestBody User resources) throws Exception { - checkLevel(resources); - userService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Log("修改用户:个人中心") - @ApiOperation("修改用户:个人中心") -// @PutMapping(value = "center") - public ResponseEntity center(@RequestBody User resources){ - if(!resources.getUser_id().equals(StpUtil.getLoginIdAsLong())){ - throw new BadRequestException("不能修改他人资料"); - } - userService.updateCenter(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Log("删除用户") - @ApiOperation("删除用户") - @DeleteMapping -// @SaCheckPermission("user:del") - public ResponseEntity delete(@RequestBody Set ids) { - for (Long id : ids) { - /* Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList())); - Integer optLevel = Collections.min(roleService.findByUsersId(id).stream().map(Role::getLevel).collect(Collectors.toList())); - if (currentLevel > optLevel) { - throw new BadRequestException("角色权限不足,不能删除:" + userService.findById(id).getUsername()); - }*/ - // 删除缓存信息 - User userDto = userService.findById(id); - redisUtils.del("data::user:" + userDto.getUser_id()); - redisUtils.del("menu::user:" + userDto.getUser_id()); - redisUtils.del("role::auth:" + userDto.getUser_id()); - redisUtils.del("user::username:" + userDto.getUsername()); - } - userService.delete(ids); - return new ResponseEntity<>(HttpStatus.OK); - } - - /* @ApiOperation("修改密码") - @PostMapping(value = "/updatePass") - public ResponseEntity updatePass(@RequestBody UserPassVo passVo) throws Exception { - // 解密,得到字符密码 - String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass()); - String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass()); - User user = userService.findByName(SecurityUtils.getCurrentUsername()); - if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) { - throw new BadRequestException("修改失败,旧密码错误"); - } - if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(newPass, "salt"))) { - throw new BadRequestException("新密码不能与旧密码相同"); - } - userService.updatePass(user.getUsername(),SaSecureUtil.md5BySalt(newPass, "salt")); - return new ResponseEntity<>(HttpStatus.OK); - }*/ - - @ApiOperation("修改头像") - @PostMapping(value = "/updateAvatar") - public ResponseEntity updateAvatar(@RequestParam MultipartFile avatar){ - return new ResponseEntity<>(userService.updateAvatar(avatar), HttpStatus.OK); - } - - @Log("修改邮箱") - @ApiOperation("修改邮箱") - @PostMapping(value = "/updateEmail/{code}") - public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user) throws Exception { - String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,user.getPassword()); - User userDto = userService.findByName(SecurityUtils.getCurrentUsername()); - if(!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(password, "salt"))){ - throw new BadRequestException("密码错误"); - } - userService.updateEmail(userDto.getUsername(),user.getEmail()); - return new ResponseEntity<>(HttpStatus.OK); - } - - /** - * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 - * @param resources / - */ - private void checkLevel(User resources) { -// Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList())); -// Integer optLevel = roleService.findByRoles(resources.getRoles()); -// if (currentLevel > optLevel) { -// throw new BadRequestException("角色权限不足"); -// } - } -} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/DataService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/DataService.java index 568b642..53df5e1 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/DataService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/DataService.java @@ -15,8 +15,8 @@ */ package org.nl.modules.system.service; -import org.nl.modules.system.domain.User; import org.nl.modules.system.service.dto.UserDto; +import org.nl.system.service.user.dao.User; import java.util.List; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserRelateService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserRelateService.java index 6bfbe2f..4860790 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserRelateService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserRelateService.java @@ -15,7 +15,6 @@ */ package org.nl.modules.system.service; -import org.nl.modules.system.domain.User; import org.nl.modules.system.service.dto.UserQueryCriteria; import org.springframework.data.domain.Pageable; import org.springframework.web.multipart.MultipartFile; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserService.java deleted file mode 100644 index 1ac258a..0000000 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserService.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nl.modules.system.service; - -import org.nl.modules.system.domain.User; -import org.nl.modules.system.service.dto.UserDto; -import org.nl.modules.system.service.dto.UserQueryCriteria; -import org.springframework.data.domain.Pageable; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Zheng Jie - * @date 2018-11-23 - */ -public interface UserService { - - /** - * 根据ID查询 - * @param id ID - * @return / - */ - User findById(long id); - - /** - * 新增用户 - * @param resources / - */ - void create(User resources); - - /** - * 编辑用户 - * @param resources / - */ - void update(User resources) ; - - /** - * 删除用户 - * @param ids / - */ - void delete(Set ids); - - /** - * 根据用户名查询 - * @param userName / - * @return / - */ - User findByName(String userName); - - /** - * 修改密码 - * @param username 用户名 - * @param encryptPassword 密码 - */ - void updatePass(String username, String encryptPassword); - - /** - * 修改头像 - * @param file 文件 - * @return / - */ - Map updateAvatar(MultipartFile file); - - /** - * 修改邮箱 - * @param username 用户名 - * @param email 邮箱 - */ - void updateEmail(String username, String email); - - /** - * 查询全部 - * @param criteria 条件 - * @param pageable 分页参数 - * @return / - */ - Object queryAll(UserQueryCriteria criteria, Pageable pageable); - - /** - * 查询全部不分页 - * @param criteria 条件 - * @return / - */ - List queryAll(UserQueryCriteria criteria); - - - /** - * 用户自助修改资料 - * @param resources / - */ - void updateCenter(User resources); -} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DataServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DataServiceImpl.java index 7f91e74..8264fa4 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DataServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DataServiceImpl.java @@ -16,11 +16,11 @@ package org.nl.modules.system.service.impl; import lombok.RequiredArgsConstructor; -import org.nl.modules.system.domain.User; import org.nl.modules.system.service.DataService; import org.nl.modules.system.service.DeptService; import org.nl.modules.system.service.RoleService; import org.nl.modules.system.service.dto.RoleSmallDto; +import org.nl.system.service.user.dao.User; import org.springframework.cache.annotation.CacheConfig; import org.springframework.stereotype.Service; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java deleted file mode 100644 index 5fdf524..0000000 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nl.modules.system.service.impl; - -import cn.dev33.satoken.secure.SaSecureUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import org.apache.commons.lang3.StringUtils; -import org.nl.modules.common.config.FileProperties; -import org.nl.modules.common.exception.EntityExistException; -import org.nl.modules.common.exception.EntityNotFoundException; -import org.nl.modules.common.utils.CacheKey; -import org.nl.modules.common.utils.FileUtil; -import org.nl.modules.common.utils.RedisUtils; -import org.nl.modules.common.utils.SecurityUtils; -import org.nl.modules.common.utils.dto.CurrentUser; -import org.nl.modules.security.service.OnlineUserService; -import org.nl.modules.system.domain.User; -import org.nl.modules.system.service.DeptService; -import org.nl.modules.system.service.UserRelateService; -import org.nl.modules.system.service.UserService; -import org.nl.modules.system.service.dto.UserQueryCriteria; -import org.nl.modules.tools.MapOf; -import org.nl.modules.wql.WQL; -import org.nl.modules.wql.core.bean.ResultBean; -import org.nl.modules.wql.core.bean.WQLObject; -import org.nl.modules.wql.util.WqlUtil; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.web.multipart.MultipartFile; - -import java.io.File; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author Zheng Jie - * @date 2018-11-23 - */ -@Service -@RequiredArgsConstructor -public class UserServiceImpl implements UserService { - - private final FileProperties properties; - private final RedisUtils redisUtils; - private final OnlineUserService onlineUserService; - private final DeptService deptService; - private final UserRelateService userRelateService; - - - - - @Override - public Object queryAll(UserQueryCriteria criteria, Pageable pageable) { - if(criteria.getNeedAll()!=null && criteria.getNeedAll()){ - Set pidChild = deptService.findPidChild(criteria.getDeptId()); - criteria.getDeptIds().addAll(pidChild); - criteria.getDeptIds().add(criteria.getDeptId()); - criteria.setDeptId(null); - } - JSONObject o = (JSONObject)JSON.toJSON(criteria); - HashMap map = MapOf.of("user_id", MapUtil.getStr(o, "user_id") - , "is_used", MapUtil.getStr(o, "is_used") - , "startTime", MapUtil.getStr(o, "startTime") - , "endTime", MapUtil.getStr(o, "endTime") - , "deptId", MapUtil.getStr(o, "deptId") - ); - if (ObjectUtil.isNotEmpty(MapUtil.getStr(o, "blurry"))){ - map.put("blurry","'%"+MapUtil.getStr(o, "blurry")+"%'"); - } - if (!CollectionUtils.isEmpty(criteria.getDeptIds())){ - String collectSql = criteria.getDeptIds().stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','")); - map.put("deptIds","('"+collectSql+"')"); - } - map.put("flag","1"); - JSONObject jsonObject = WQL.getWO("SYS_USER").addParamMap(map).pageQuery(WqlUtil.getHttpContext(pageable),"user_id desc"); - return jsonObject; - } - - @Override - public List queryAll(UserQueryCriteria criteria) { - JSONObject o = (JSONObject)JSON.toJSON(criteria); - HashMap map = MapOf.of("user_id", MapUtil.getStr(o, "user_id") - , "blurry", MapUtil.getStr(o, "blurry") - , "is_used", MapUtil.getStr(o, "is_used") - , "startTime", MapUtil.getStr(o, "startTime") - , "endTime", MapUtil.getStr(o, "endTime") - , "deptId", MapUtil.getStr(o, "deptId") - ); - if (!CollectionUtils.isEmpty(criteria.getDeptIds())){ - String collectSql = criteria.getDeptIds().stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','")); - map.put("deptIds","('"+collectSql+"')"); - } - map.put("flag","1"); - JSONArray array = WQL.getWO("SYS_USER").addParamMap(map).process().getResultJSONArray(0); - List users = array.toJavaList(User.class); - return users; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public User findById(long id) { - JSONObject result = WQLObject.getWQLObject("sys_user").query("user_id = '" + id + "'").uniqueResult(0); - User user = result.toJavaObject(User.class); - return user; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void create(User resources) { - JSONObject result = WQLObject.getWQLObject("sys_user").query("username = '" + resources.getUsername() + "'").uniqueResult(0); - if (result != null) { - throw new EntityExistException(User.class, "username", resources.getUsername()); - } - CurrentUser user = SecurityUtils.getCurrentUser(); - resources.setCreate_time(new Date()); - resources.setCreate_id(user.getId()); - resources.setCreate_name(user.getUsername()); - ResultBean sys_user = WQLObject.getWQLObject("sys_user").insert(JSONObject.parseObject(JSON.toJSONString(resources))); - //更新用户部门表,更新用户角色表 - String depts = resources.getDepts(); - String roles = resources.getRoles(); - JSONObject currentUser = WQLObject.getWQLObject("sys_user").query("username = '" + resources.getUsername() + "'").uniqueResult(0); - - if (StringUtils.isNotEmpty(depts)){ - String[] split = depts.split(","); - Set collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet()); - userRelateService.inserDeptRelate(currentUser.getLong("user_id"),collect); - } - if (StringUtils.isNotEmpty(roles)){ - String[] split = roles.split(","); - Set collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet()); - userRelateService.inserRoleRelate(currentUser.getLong("user_id"),collect); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - @SneakyThrows - public void update(User resources) { - User user = this.findById(resources.getUser_id()); - redisUtils.del("user::username:" + user.getUsername()); - // 如果用户被禁用,则清除用户登录信息 - if("0".equals(resources.getIs_used())){ - onlineUserService.kickOutForUsername(resources.getUsername()); - } - resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt")); - resources.setUpdate_time(new Date()); - resources.setUpdate_optid(user.getId()); - resources.setUpdate_optname(user.getUsername()); - WQLObject.getWQLObject("sys_user").update(JSONObject.parseObject(JSON.toJSONString(resources)),"user_id ='"+resources.getUser_id()+"'"); - // 清除缓存 - delCaches(user.getUser_id(), user.getUsername()); - //更新部门用户 - String depts = resources.getDepts(); - String roles = resources.getRoles(); - if (StringUtils.isNotEmpty(depts)){ - String[] split = depts.split(","); - Set collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet()); - userRelateService.updateDeptRelate(resources.getUser_id(),collect); - } - if (StringUtils.isNotEmpty(roles)){ - String[] split = roles.split(","); - Set collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet()); - userRelateService.updateRoleRelate(resources.getUser_id(),collect); - } - // 如果用户的角色改变 - if (!resources.getRoles().equals(user.getRoles())) { - redisUtils.del(CacheKey.DATA_USER + resources.getUser_id()); - redisUtils.del(CacheKey.MENU_USER + resources.getUser_id()); - redisUtils.del(CacheKey.ROLE_AUTH + resources.getUser_id()); - } - - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateCenter(User resources) { - User user = this.findById(resources.getUser_id()); - user.setPerson_name(resources.getPerson_name()); - user.setPhone(resources.getPhone()); - user.setGender(resources.getGender()); - WQLObject.getWQLObject("sys_user").update(JSONObject.parseObject(JSON.toJSONString(resources)),"user_id ='"+resources.getUser_id()+"'"); - // 清理缓存 - delCaches(user.getUser_id(), user.getUsername()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(Set ids) { - for (Long id : ids) { - // 清理缓存 - User user = findById(id); - delCaches(user.getUser_id(), user.getUsername()); - } - String collectSql = ids.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','")); - WQLObject.getWQLObject("sys_user").delete("user_id in ('"+collectSql+"')"); - //删除用户部门,角色关系表 - userRelateService.deleteDeptRelate(ids); - userRelateService.deleteRoleRelate(ids); - } - - @Override - public User findByName(String userName) { - JSONObject result = WQLObject.getWQLObject("sys_user").query("userName = '" + userName + "'").uniqueResult(0); - if (result == null) { - throw new EntityNotFoundException(User.class, "name", userName); - } else { - return result.toJavaObject(User.class); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePass(String username, String pass) { - WQLObject.getWQLObject("sys_user").update(MapOf.of("password",pass),"username ='"+username+"'"); - redisUtils.del("user::username:" + username); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Map updateAvatar(MultipartFile multipartFile) { - User user = this.findByName(SecurityUtils.getCurrentUsername()); - String oldPath = user.getAvatarPath(); - File file = FileUtil.upload(multipartFile, properties.getPath().getAvatar()); - user.setAvatarPath(Objects.requireNonNull(file).getPath()); - user.setAvatarName(file.getName()); - this.update(user); - if (StrUtil.isNotEmpty(oldPath)) { - FileUtil.del(oldPath); - } - return new HashMap(1) {{ - put("avatar", file.getName()); - }}; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateEmail(String username, String email) { - WQLObject.getWQLObject("sys_user").update(MapOf.of("email",email),"username ='"+username+"'"); - } - - /** - * 清理缓存 - * - * @param id / - */ - public void delCaches(Long id, String username) { - redisUtils.del(CacheKey.USER_ID + id); - } -} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java index 92fb120..df0be5d 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java @@ -1,21 +1,173 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.nl.system.controller.user; +import cn.dev33.satoken.secure.SaSecureUtil; +import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.nl.modules.common.config.RsaProperties; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.common.utils.RedisUtils; +import org.nl.modules.common.utils.RsaUtils; +import org.nl.modules.common.utils.SecurityUtils; +import org.nl.modules.logging.annotation.Log; +import org.nl.modules.system.service.dto.UserQueryCriteria; +import org.nl.system.service.user.UserService; +import org.nl.system.service.user.dao.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.springframework.web.bind.annotation.RestController; +import java.util.Set; /** - *

- * 用户表 前端控制器 - *

- * - * @author generator - * @since 2022-12-14 + * @author Zheng Jie + * @date 2018-11-23 */ +@Api(tags = "系统:用户管理") @RestController -@RequestMapping("/user") +@RequestMapping("/api/users") +@RequiredArgsConstructor public class UserController { -} + @Autowired + UserService userService; + @ApiOperation("查询用户") + @GetMapping +// @SaCheckPermission("user:list") + public ResponseEntity query(UserQueryCriteria criteria, Page pageable){ + Page page = userService.page(pageable); + return new ResponseEntity<>(page,HttpStatus.OK); + } + + @Log("新增用户") + @ApiOperation("新增用户") + @PostMapping +// @SaCheckPermission("user:add") + public ResponseEntity create(@Validated @RequestBody User resources){ + checkLevel(resources); + // 默认密码 123456 + if (ObjectUtil.isEmpty(resources.getPassword())) { + resources.setPassword(SaSecureUtil.md5BySalt("123456", "salt")); + } else { + resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt")); + } + userService.save(resources); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @Log("修改用户") + @ApiOperation("修改用户") + @PutMapping +// @SaCheckPermission("user:edit") + public ResponseEntity update( @RequestBody User resources) throws Exception { + checkLevel(resources); + userService.saveOrUpdate(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("修改用户:个人中心") + @ApiOperation("修改用户:个人中心") +// @PutMapping(value = "center") + public ResponseEntity center(@RequestBody User resources){ + if(!resources.getUserId().equals(StpUtil.getLoginIdAsLong())){ + throw new BadRequestException("不能修改他人资料"); + } + userService.saveOrUpdate(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除用户") + @ApiOperation("删除用户") + @DeleteMapping +// @SaCheckPermission("user:del") + public ResponseEntity delete(@RequestBody Set ids) { + for (Long id : ids) { + /* Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList())); + Integer optLevel = Collections.min(roleService.findByUsersId(id).stream().map(Role::getLevel).collect(Collectors.toList())); + if (currentLevel > optLevel) { + throw new BadRequestException("角色权限不足,不能删除:" + userService.findById(id).getUsername()); + }*/ + // 删除缓存信息 +// User userDto = userService.findById(id); +// redisUtils.del("data::user:" + userDto.getUser_id()); +// redisUtils.del("menu::user:" + userDto.getUser_id()); +// redisUtils.del("role::auth:" + userDto.getUser_id()); +// redisUtils.del("user::username:" + userDto.getUsername()); + } + userService.removeByIds(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + /* @ApiOperation("修改密码") + @PostMapping(value = "/updatePass") + public ResponseEntity updatePass(@RequestBody UserPassVo passVo) throws Exception { + // 解密,得到字符密码 + String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass()); + String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass()); + User user = userService.findByName(SecurityUtils.getCurrentUsername()); + if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) { + throw new BadRequestException("修改失败,旧密码错误"); + } + if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(newPass, "salt"))) { + throw new BadRequestException("新密码不能与旧密码相同"); + } + userService.updatePass(user.getUsername(),SaSecureUtil.md5BySalt(newPass, "salt")); + return new ResponseEntity<>(HttpStatus.OK); + }*/ + + @ApiOperation("修改头像") + @PostMapping(value = "/updateAvatar") + public ResponseEntity updateAvatar(@RequestParam MultipartFile avatar){ + return new ResponseEntity<>(userService.updateAvatar(avatar), HttpStatus.OK); + } + + @Log("修改邮箱") + @ApiOperation("修改邮箱") + @PostMapping(value = "/updateEmail/{code}") + public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user) throws Exception { + String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,user.getPassword()); + User userInfo = userService.getOne(new QueryWrapper().eq("username",SecurityUtils.getCurrentUsername())); + if(!SaSecureUtil.md5BySalt(userInfo.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(password, "salt"))){ + throw new BadRequestException("密码错误"); + } + userService.update(new UpdateWrapper().set(userInfo.getUsername(),user.getEmail())); + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 + * @param resources / + */ + private void checkLevel(User resources) { +// Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList())); +// Integer optLevel = roleService.findByRoles(resources.getRoles()); +// if (currentLevel > optLevel) { +// throw new BadRequestException("角色权限不足"); +// } + } +} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/UserService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/UserService.java index 84823d7..c364c0d 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/UserService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/UserService.java @@ -2,6 +2,9 @@ package org.nl.system.service.user; import org.nl.system.service.user.dao.User; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Map; /** *

@@ -13,4 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface UserService extends IService { + Map updateAvatar(MultipartFile multipartFile); + } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/UserServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/UserServiceImpl.java index 87398ce..2a3b9a7 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/UserServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/UserServiceImpl.java @@ -1,10 +1,22 @@ package org.nl.system.service.user.impl; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.nl.modules.common.config.FileProperties; +import org.nl.modules.common.utils.FileUtil; +import org.nl.modules.common.utils.SecurityUtils; import org.nl.system.service.user.dao.User; import org.nl.system.service.user.dao.mapper.UserMapper; import org.nl.system.service.user.UserService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; /** *

@@ -17,4 +29,22 @@ import org.springframework.stereotype.Service; @Service public class UserServiceImpl extends ServiceImpl implements UserService { + @Autowired + private FileProperties properties; + + @Override + public Map updateAvatar(MultipartFile multipartFile) { + User user = this.getOne(new QueryWrapper().eq("username", SecurityUtils.getCurrentUsername())); + String oldPath = user.getAvatarPath(); + File file = FileUtil.upload(multipartFile, properties.getPath().getAvatar()); + user.setAvatarPath(Objects.requireNonNull(file).getPath()); + user.setAvatarName(file.getName()); + this.saveOrUpdate(user); + if (StrUtil.isNotEmpty(oldPath)) { + FileUtil.del(oldPath); + } + return new HashMap(1) {{ + put("avatar", file.getName()); + }}; + } } diff --git a/nladmin-system/src/main/java/org/nl/system/controller/dept/DeptController.java b/nladmin-system/src/main/java/org/nl/system/controller/dept/DeptController.java new file mode 100644 index 0000000..0599300 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/system/controller/dept/DeptController.java @@ -0,0 +1,21 @@ +package org.nl.system.controller.dept; + + +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 部门 前端控制器 + *

+ * + * @author generator + * @since 2022-12-14 + */ +@RestController +@RequestMapping("/dept") +public class DeptController { + +} + diff --git a/nladmin-system/src/main/java/org/nl/system/service/dept/DeptService.java b/nladmin-system/src/main/java/org/nl/system/service/dept/DeptService.java new file mode 100644 index 0000000..9bc191a --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/system/service/dept/DeptService.java @@ -0,0 +1,16 @@ +package org.nl.system.service.dept; + +import org.nl.system.service.dept.dao.Dept; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 部门 服务类 + *

+ * + * @author generator + * @since 2022-12-14 + */ +public interface DeptService extends IService { + +} diff --git a/nladmin-system/src/main/java/org/nl/system/service/dept/dao/Dept.java b/nladmin-system/src/main/java/org/nl/system/service/dept/dao/Dept.java new file mode 100644 index 0000000..a906efd --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/system/service/dept/dao/Dept.java @@ -0,0 +1,88 @@ +package org.nl.system.service.dept.dao; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 部门 + *

+ * + * @author generator + * @since 2022-12-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("sys_dept") +public class Dept implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @TableId(value = "dept_id", type = IdType.AUTO) + private Long deptId; + + /** + * 上级部门 + */ + private Long pid; + + /** + * 子部门数目 + */ + private Integer subCount; + + /** + * 名称 + */ + private String name; + + /** + * 排序 + */ + private Integer deptSort; + + /** + * 状态 + */ + private String isUsed; + + private Long createId; + + /** + * 创建者 + */ + private String createName; + + private Long updateOptid; + + /** + * 更新者 + */ + private String updateOptname; + + /** + * 创建日期 + */ + private String createTime; + + /** + * 更新时间 + */ + private String updateTime; + + /** + * 部门编号 + */ + private String code; + + private String extId; + + +} diff --git a/nladmin-system/src/main/java/org/nl/system/service/dept/dao/mapper/DeptMapper.java b/nladmin-system/src/main/java/org/nl/system/service/dept/dao/mapper/DeptMapper.java new file mode 100644 index 0000000..ad9752f --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/system/service/dept/dao/mapper/DeptMapper.java @@ -0,0 +1,16 @@ +package org.nl.system.service.dept.dao.mapper; + +import org.nl.system.service.dept.dao.Dept; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 部门 Mapper 接口 + *

+ * + * @author generator + * @since 2022-12-14 + */ +public interface DeptMapper extends BaseMapper { + +} diff --git a/nladmin-system/src/main/java/org/nl/system/service/dept/dao/mapper/DeptMapper.xml b/nladmin-system/src/main/java/org/nl/system/service/dept/dao/mapper/DeptMapper.xml new file mode 100644 index 0000000..4874ec0 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/system/service/dept/dao/mapper/DeptMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/nladmin-system/src/main/java/org/nl/system/service/dept/impl/DeptServiceImpl.java b/nladmin-system/src/main/java/org/nl/system/service/dept/impl/DeptServiceImpl.java new file mode 100644 index 0000000..0f27397 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/system/service/dept/impl/DeptServiceImpl.java @@ -0,0 +1,20 @@ +package org.nl.system.service.dept.impl; + +import org.nl.system.service.dept.dao.Dept; +import org.nl.system.service.dept.dao.mapper.DeptMapper; +import org.nl.system.service.dept.DeptService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 部门 服务实现类 + *

+ * + * @author generator + * @since 2022-12-14 + */ +@Service +public class DeptServiceImpl extends ServiceImpl implements DeptService { + +}