From 3860e5be6992552f26e567fe4a073e3efad37ba8 Mon Sep 17 00:00:00 2001 From: ZQN <364596817@qq.com> Date: 星期二, 23 七月 2024 16:42:51 +0800 Subject: [PATCH] 企业来访添加其他机构 --- project-admin/src/main/java/com/project/admin/controller/system/SysProfileController.java | 99 ++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 84 insertions(+), 15 deletions(-) diff --git a/project-admin/src/main/java/com/project/admin/controller/system/SysProfileController.java b/project-admin/src/main/java/com/project/admin/controller/system/SysProfileController.java index 7dacc7f..b8220a0 100644 --- a/project-admin/src/main/java/com/project/admin/controller/system/SysProfileController.java +++ b/project-admin/src/main/java/com/project/admin/controller/system/SysProfileController.java @@ -1,21 +1,11 @@ package com.project.admin.controller.system; -import com.project.common.config.ProjectConfig; -import com.project.common.core.domain.entity.SysDept; -import com.project.system.service.ISysDeptService; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; import com.project.common.annotation.Log; +import com.project.common.config.ProjectConfig; import com.project.common.constant.UserConstants; import com.project.common.core.controller.BaseController; import com.project.common.core.domain.AjaxResult; +import com.project.common.core.domain.entity.SysDept; import com.project.common.core.domain.entity.SysUser; import com.project.common.core.domain.model.LoginUser; import com.project.common.enums.BusinessType; @@ -23,8 +13,17 @@ import com.project.common.utils.StringUtils; import com.project.common.utils.file.FileUploadUtils; import com.project.common.utils.file.MimeTypeUtils; +import com.project.framework.web.service.SysPermissionService; import com.project.framework.web.service.TokenService; +import com.project.system.domain.SysCompany; +import com.project.system.service.ISysCompanyService; +import com.project.system.service.ISysDeptService; import com.project.system.service.ISysUserService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Set; /** * 涓汉淇℃伅 涓氬姟澶勭悊 @@ -39,6 +38,8 @@ private final ISysUserService userService; private final ISysDeptService deptService; private final TokenService tokenService; + private final SysPermissionService permissionService; + private final ISysCompanyService companyService; /** @@ -47,10 +48,27 @@ @GetMapping public AjaxResult profile() { - SysUser user = userService.getById(getUserId()); - SysDept sysDept = deptService.selectDeptById(user.getDeptId()); - user.setDept(sysDept); + SysUser user = userService.selectUserById(SecurityUtils.getLoginUser().getUserId()); + if ("02".equals(user.getUserType())){ + SysCompany company = companyService.getById(userService.getById(user.getUserId()).getDeptId()); + SysDept sysDept = new SysDept(); + sysDept.setDeptName(company.getCompanyName()); + user.setDept(sysDept); + } else { + SysDept sysDept = deptService.selectDeptById(userService.getById(user.getUserId()).getDeptId()); + if (sysDept!=null){ + sysDept.setDeptName(deptService.getDeptAllName(sysDept.getDeptId())); + user.setDept(sysDept); + } + } + + // 瑙掕壊闆嗗悎 + Set<String> roles = permissionService.getRolePermission(user); + // 鏉冮檺闆嗗悎 + Set<String> permissions = permissionService.getMenuPermission(user); AjaxResult ajax = AjaxResult.success(user); + ajax.put("roles", roles); + ajax.put("permissions", permissions); ajax.put("roleGroup", userService.selectUserRoleGroup(user.getUserName())); ajax.put("postGroup", userService.selectUserPostGroup(user.getUserName())); return ajax; @@ -85,6 +103,7 @@ return error("淇敼涓汉淇℃伅寮傚父锛岃鑱旂郴绠$悊鍛�"); } + /** * 閲嶇疆瀵嗙爜 */ @@ -114,6 +133,56 @@ } /** + * 鏇存崲鎵嬫満鍙� + */ + @Log(title = "鏇存崲鎵嬫満鍙�", businessType = BusinessType.UPDATE) + @PostMapping("/updatePhone/{phone}/{companyId}") + public AjaxResult updatePhone(@PathVariable String phone, @PathVariable String companyId) + { + if (StringUtils.isEmpty(phone)){ + return error("璇峰~鍐欐墜鏈哄彿"); + } + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = userService.selectUserById(SecurityUtils.getUserId()); + if ("02".equals(user.getUserType()) && StringUtils.isNotEmpty(companyId)){//浼佷笟 + //澶氫紒涓氳处鎴锋洿鎹㈠彿鐮� + //鏂板彿鐮佷笉瀛樺湪锛� + SysUser one = userService.getOne(userService.lq().eq(SysUser::getPhonenumber, phone)); + if (one!=null && !"02".equals(one.getUserType())){ + return error("璇ユ墜鏈哄彿涓嶆槸浼佷笟鍙风爜鑼冨洿锛岃鏇存崲鍙风爜"); + } + if (companyService.count(SysCompany::getCompanyPhone, user.getPhonenumber())==1){ + userService.deleteUserByCompanyPhone(user.getPhonenumber()); + } + if (one==null){ //涓嶅瓨鍦�,娣诲姞浼佷笟璐︽埛 + SysCompany company = companyService.getById(Long.parseLong(companyId)); + company.setCompanyPhone(phone); + companyService.addCompanyUser(company, 1); + } + //淇敼浼佷笟鐢佃瘽 + companyService.update(companyService.lu().set(SysCompany::getCompanyPhone, phone).eq(SysCompany::getCompanyId, Long.parseLong(companyId))); + return success(1); + } + user.setPhonenumber(phone); + + if (StringUtils.isNotEmpty(user.getPhonenumber()) + && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) + { + return error("淇敼鐢ㄦ埛'" + user.getUserName() + "'澶辫触锛屾墜鏈哄彿鐮佸凡瀛樺湪"); + } + + if (userService.resetPhone(user.getUserId(), phone) > 0) + { + // 鏇存柊缂撳瓨 + loginUser.getUser().setUserName(phone); + loginUser.getUser().setPhonenumber(phone); + tokenService.setLoginUser(loginUser); + return success(0); + } + return error("淇敼瀵嗙爜寮傚父锛岃鑱旂郴绠$悊鍛�"); + } + + /** * 澶村儚涓婁紶 */ @Log(title = "鐢ㄦ埛澶村儚", businessType = BusinessType.UPDATE) -- Gitblit v1.9.1