From 562e95b7cc53fe809d092ac5320eed711993bb7e Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期五, 23 五月 2025 21:20:06 +0800 Subject: [PATCH] 修改bug --- springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/HomeController.java | 67 +++++++++++++++++++++++++++++---- 1 files changed, 59 insertions(+), 8 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/HomeController.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/HomeController.java index 5b1cb3e..6674c0c 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/HomeController.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/controller/HomeController.java @@ -1,27 +1,33 @@ package com.panzhihua.sangeshenbian.controller; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.panzhihua.common.controller.BaseController; +import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.redis.RedisUtils; +import com.panzhihua.sangeshenbian.model.dto.UserIdentityDTO; import com.panzhihua.sangeshenbian.model.entity.Banner; -import com.panzhihua.sangeshenbian.model.entity.Department; import com.panzhihua.sangeshenbian.model.entity.PartyMember; import com.panzhihua.sangeshenbian.model.entity.SystemUser; +import com.panzhihua.sangeshenbian.model.entity.SystemUserLevel; import com.panzhihua.sangeshenbian.model.query.BasePage; import com.panzhihua.sangeshenbian.model.vo.ComplaintTodoVO; import com.panzhihua.sangeshenbian.model.vo.MessageNotificationVO; import com.panzhihua.sangeshenbian.model.vo.PartyCardInfoVO; import com.panzhihua.sangeshenbian.service.*; import com.panzhihua.sangeshenbian.utils.BaiduMapUtil; +import com.panzhihua.sangeshenbian.warpper.IdentityInformation; import com.panzhihua.sangeshenbian.warpper.IdentityInformationVO; -import com.panzhihua.sangeshenbian.warpper.PermissionsVO; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; @@ -43,7 +49,7 @@ private final IPartyMemberService partyMemberService; private final RedisUtils redisUtils; private final IdentityInformationService identityInformationService; - + private final ISystemUserLevelService systemUserLevelService; @ApiOperation("获取banner列表") @GetMapping("/banner-list") public R<List<Banner>> getBannerList() { @@ -57,6 +63,7 @@ // 获取党员信息 PartyMember partyMember = partyMemberService.getOne(new LambdaQueryWrapper<PartyMember>() .eq(PartyMember::getPhone, loginUserInfo.getPhone()) + .eq(PartyMember::getAuditStatus, 1) .eq(PartyMember::getDelFlag, 0)); PartyCardInfoVO partyCardInfoVO = new PartyCardInfoVO(); @@ -85,7 +92,29 @@ @GetMapping("/current-user-info") @ApiOperation("获取三个身边当前用户信息 用于判断用户是否是上级") public R<SystemUser> getCurrentUserInfo() { - return R.ok(systemUserService.getSystemUserAdminByPhone(getLoginUserInfo().getPhone()).orElse(null)); + SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(getLoginUserInfo().getPhone()).orElse(null); + Object o1 = redisUtils.get("identity:" + getLoginUserInfo().getPhone()); + if(o1!=null){ + UserIdentityDTO o2 = (UserIdentityDTO) o1; + Integer levelId = o2.getLevelId(); + if(levelId!=null) { + SystemUserLevel systemUserLevel = systemUserLevelService.getById(levelId); + if (systemUserLevel == null) { + List<SystemUserLevel> list = systemUserLevelService.list(new LambdaQueryWrapper<SystemUserLevel>().eq(SystemUserLevel::getSystemUserId, systemUser.getId()).eq(SystemUserLevel::getStatus, 1)); + if (list.size() > 0) { + systemUser.setLevelId(list.get(0).getLevel()); + } + } else { + systemUser.setLevelId(systemUserLevel.getLevel()); + } + }else { + List<SystemUserLevel> list = systemUserLevelService.list(new LambdaQueryWrapper<SystemUserLevel>().eq(SystemUserLevel::getSystemUserId, systemUser.getId()).eq(SystemUserLevel::getStatus, 1)); + if (list.size() > 0) { + systemUser.setLevelId(list.get(0).getLevel()); + } + } + } + return R.ok(systemUser); } /** @@ -110,7 +139,15 @@ public R<JSONArray> searchLocation(String query, String location) { return R.ok(BaiduMapUtil.searchLocation(query, location)); } - + @GetMapping("/geoconv") + @ApiOperation("百度地图经纬度转换") + public R<JSONObject> geoconv(String coords) { + try { + return R.ok(BaiduMapUtil.geoconv(coords)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } /** * 获取身份信息 */ @@ -118,7 +155,9 @@ @ApiOperation("获取身份信息") public R<IdentityInformationVO> getIdentityInfo() { LoginUserInfoVO loginUserInfo = getLoginUserInfo(); - IdentityInformationVO identityInformationVO = identityInformationService.getIdentityInformationVO(loginUserInfo); + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfo); + IdentityInformationVO identityInformationVO = new IdentityInformationVO(); + BeanUtils.copyProperties(identityInformation, identityInformationVO); return R.ok(identityInformationVO); } @@ -129,9 +168,21 @@ */ @GetMapping("/change-identity") @ApiOperation("切换身份") - public R<?> changeIdentity(Integer identity) { + @ApiImplicitParams({ + @ApiImplicitParam(name = "identity", value = "身份 1:党员 2:管理员", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "levelId", value = "身份层级id,党员身份不传,管理员必传", required = true, dataType = "Integer") + }) + public R<?> changeIdentity(@RequestParam(value = "identity", required = true) Integer identity, + @RequestParam(value = "levelId", required = false) Integer levelId) { LoginUserInfoVO loginUserInfo = getLoginUserInfo(); - redisUtils.set("identity:" + loginUserInfo.getPhone(), identity); + if (identity.equals(2) && Objects.isNull(levelId)) { + throw new ServiceException("管理员所属层级id不能为空"); + } + // 存储到Redis + redisUtils.set("identity:" + loginUserInfo.getPhone(), UserIdentityDTO.builder() + .identity(identity) + .levelId(levelId) + .build()); return R.ok(); } -- Gitblit v1.7.1