From 5cbb2e7fc3d81ac895548179a7be9a65fa726c6d Mon Sep 17 00:00:00 2001 From: ZQN <364596817@qq.com> Date: 星期三, 14 八月 2024 17:55:28 +0800 Subject: [PATCH] 企业二维码批量下载 --- project-admin/src/main/java/com/project/admin/controller/system/SysProfileController.java | 108 +++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 87 insertions(+), 21 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 2101771..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,19 +1,11 @@ package com.project.admin.controller.system; -import com.project.common.config.ProjectConfig; -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; @@ -21,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; /** * 涓汉淇℃伅 涓氬姟澶勭悊 @@ -35,7 +36,10 @@ public class SysProfileController extends BaseController { private final ISysUserService userService; + private final ISysDeptService deptService; private final TokenService tokenService; + private final SysPermissionService permissionService; + private final ISysCompanyService companyService; /** @@ -44,8 +48,27 @@ @GetMapping public AjaxResult profile() { - SysUser user = userService.getById(getUserId()); + 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; @@ -59,14 +82,6 @@ public AjaxResult updateProfile(@RequestBody SysUser user) { LoginUser loginUser = getLoginUser(); - user.setUserName(user.getUserName()); - SysUser byId = userService.getById(user.getUserId()); - byId.setNickName(user.getNickName()); - byId.setPhonenumber(user.getPhonenumber()); - byId.setEmail(user.getEmail()); - byId.setSex(user.getSex()); - byId.setAvatar(user.getAvatar()); - byId.setDeptId(user.getDeptId()); if (StringUtils.isNotEmpty(user.getPhonenumber()) && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { @@ -77,16 +92,17 @@ { return error("淇敼鐢ㄦ埛'" + user.getUserName() + "'澶辫触锛岄偖绠辫处鍙峰凡瀛樺湪"); } - int upd = userService.updateUser(byId); + int upd = userService.updateUser(user); if (upd > 0) { // 鏇存柊缂撳瓨鐢ㄦ埛淇℃伅 - loginUser.setUser(byId); + loginUser.setUser(user); tokenService.setLoginUser(loginUser); return success(); } return error("淇敼涓汉淇℃伅寮傚父锛岃鑱旂郴绠$悊鍛�"); } + /** * 閲嶇疆瀵嗙爜 @@ -117,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