| | |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.framework.datapermission.core.annotation.DataPermission; |
| | | import com.iailab.module.system.api.user.dto.AdminUserRespDTO; |
| | | import com.iailab.module.system.controller.admin.user.vo.user.UserSaveReqVO; |
| | | import com.iailab.module.system.dal.dataobject.dept.DeptDO; |
| | | import com.iailab.module.system.dal.dataobject.user.AdminUserDO; |
| | | import com.iailab.module.system.service.dept.DeptService; |
| | | import com.iailab.module.system.service.permission.PermissionService; |
| | | import com.iailab.module.system.service.user.AdminUserService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | private AdminUserService userService; |
| | | @Resource |
| | | private DeptService deptService; |
| | | @Resource |
| | | private PermissionService permissionService; |
| | | |
| | | @Override |
| | | @DataPermission(enable = false) // 关闭数据权限,避免只查看自己时,查询不到部门。 |
| | | public CommonResult<AdminUserRespDTO> getUser(Long id) { |
| | | AdminUserDO user = userService.getUser(id); |
| | | return success(BeanUtils.toBean(user, AdminUserRespDTO.class)); |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @Override |
| | | public void saveOrUpdateUserInfo(AdminUserRespDTO userRespDTO) { |
| | | AdminUserDO entity = ConvertUtils.sourceToTarget(userRespDTO, AdminUserDO.class); |
| | | AdminUserDO dto = userService.getUserByUsername(entity.getUsername()); |
| | | UserSaveReqVO bean = BeanUtils.toBean(dto, UserSaveReqVO.class); |
| | | if (dto != null) { |
| | | bean.setId(dto.getId()); |
| | | userService.updateUser(bean); |
| | | } else { |
| | | userService.createUser(bean); |
| | | } |
| | | permissionService.assignUserRole(entity.getId(), userRespDTO.getRoleIdList()); |
| | | } |
| | | |
| | | } |