From d151d7af6ebab17d7de4ee2941448f634f0d0d8f Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 09 五月 2025 18:18:16 +0800
Subject: [PATCH] 编辑删除办理进度接口

---
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/api/SystemUserController.java |  182 +++++++++++++++++++++++++++++++++------------
 1 files changed, 133 insertions(+), 49 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/api/SystemUserController.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/api/SystemUserController.java
index b5550e4..b50f429 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/api/SystemUserController.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/api/SystemUserController.java
@@ -8,21 +8,18 @@
 import com.panzhihua.common.model.vos.R;
 import com.panzhihua.common.model.vos.sangeshenbian.SystemUserVo;
 import com.panzhihua.common.service.auth.TokenService;
-import com.panzhihua.sangeshenbian.model.entity.SystemMenu;
-import com.panzhihua.sangeshenbian.model.entity.SystemRoleMenu;
-import com.panzhihua.sangeshenbian.model.entity.SystemUser;
+import com.panzhihua.sangeshenbian.annotation.SysLog;
+import com.panzhihua.sangeshenbian.model.entity.*;
 import com.panzhihua.sangeshenbian.model.vo.RegionVO;
-import com.panzhihua.sangeshenbian.service.ISystemMenuService;
-import com.panzhihua.sangeshenbian.service.ISystemRoleMenuService;
-import com.panzhihua.sangeshenbian.service.ISystemUserService;
-import com.panzhihua.sangeshenbian.warpper.LoginVo;
-import com.panzhihua.sangeshenbian.warpper.SystemUserList;
-import com.panzhihua.sangeshenbian.warpper.SystemUserListVo;
-import com.panzhihua.sangeshenbian.warpper.TokenVo;
+import com.panzhihua.sangeshenbian.service.*;
+import com.panzhihua.sangeshenbian.utils.SignatureUtil;
+import com.panzhihua.sangeshenbian.warpper.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.util.ObjectUtils;
@@ -39,34 +36,45 @@
  * @Date 2025/2/18 22:30
  */
 @Api
+@Slf4j
 @RestController
 @RequestMapping("/systemUser")
 public class SystemUserController extends BaseController {
-	
+
 	@Resource
 	private ISystemUserService systemUserService;
-	
+
 	@Resource
 	private RedisTemplate redisTemplate;
-	
+
 	@Resource
 	private TokenService tokenService;
-	
+
 	private final Integer max_err = 5;
-	
+
 	@Resource
 	private ISystemRoleMenuService systemRoleMenuService;
-	
+
 	@Resource
 	private ISystemMenuService systemMenuService;
-	
-	
-	
-	
-	
+
+	@Resource
+	private IBcRegionService bcRegionService;
+	@Resource
+	private IComStreetService comStreetService;
+	@Resource
+	private IComActService comActService;
+
+	@Resource
+	private ISystemLogService systemLogService;
+
+
+
+
+
 	@PostMapping("/login")
 	@ApiOperation(value = "登录", tags = {"三个身边后台-登录"})
-	@OperLog(operModul = "三个身边后台",operType = 0,businessType = "登录")
+	@SysLog(operatorCategory = "登录",operId = 1)
 	public R<TokenVo> login(@RequestBody LoginVo vo){
 		String key = "login:" + vo.getPhone();
 		Integer size = (Integer) redisTemplate.opsForValue().get(key);
@@ -97,7 +105,8 @@
 		LoginReturnVO loginReturnVO = reult.getData();
 		TokenVo tokenVo = new TokenVo();
 		BeanUtils.copyProperties(loginReturnVO, tokenVo);
-		
+		tokenVo.setUserId(Long.valueOf(systemUser.getId()));
+
 		List<SystemRoleMenu> list = systemRoleMenuService.list(new LambdaQueryWrapper<SystemRoleMenu>().eq(SystemRoleMenu::getSystemRoleId, systemUser.getSystemRoleId()));
 		List<Integer> collect = list.stream().map(SystemRoleMenu::getSystemMenuId).collect(Collectors.toList());
 		Set<String> collect1 = new HashSet<>();
@@ -168,8 +177,8 @@
 		}
 		return R.ok(tokenVo);
 	}
-	
-	
+
+
 	@PostMapping("logout")
 	@ApiOperation(value = "退出登录", tags = {"三个身边后台-登录"})
 	@OperLog(operModul = "三个身边后台",operType = 0,businessType = "退出登录")
@@ -180,8 +189,8 @@
 		}
 		return tokenService.logout(token);
 	}
-	
-	
+
+
 	@GetMapping("/list")
 	@ApiOperation(value = "获取列表数据", tags = {"三个身边管理后台-人员管理"})
 	@OperLog(operModul = "三个身边后台",operType = 0,businessType = "获取人员管理列表数据")
@@ -191,12 +200,12 @@
 		IPage<SystemUserListVo> list = systemUserService.list(user, query);
 		return R.ok(list);
 	}
-	
-	
-	
+
+
+
 	@PostMapping("/add")
 	@ApiOperation(value = "添加人员", tags = {"三个身边管理后台-人员管理"})
-	@OperLog(operModul = "三个身边后台",operType = 1,businessType = "添加人员")
+	@SysLog(operatorCategory = "添加账号",operId = 4)
 	public R add(@RequestBody SystemUser systemUser){
 		Integer id = this.getLoginUserInfoSanGeShenBian().getId();
 		SystemUser user = systemUserService.getById(id);
@@ -213,40 +222,79 @@
 		if(0 < count){
 			return R.fail("手机号重复。");
 		}
+
+		String districtsCode = systemUser.getDistrictsCode();
+		if (!StringUtils.isEmpty(districtsCode)){
+			BcRegion bcRegion = bcRegionService.getOne(new LambdaQueryWrapper<BcRegion>().eq(BcRegion::getRegionCode, districtsCode));
+			systemUser.setDistricts(bcRegion.getRegionName());
+		}
+
+		String streetId = systemUser.getStreetId();
+		if (!StringUtils.isEmpty(streetId)){
+			ComStreet comStreet = comStreetService.getById(streetId);
+			systemUser.setStreet(comStreet.getName());
+		}
+		Long communityId = systemUser.getCommunityId();
+		if (communityId != null){
+			ComAct act = comActService.getById(communityId);
+			systemUser.setCommunity(act.getName());
+		}
+
 		systemUser.setStatus(1);
 		systemUser.setCreateTime(LocalDateTime.now());
+		// 2.0.1 默认管理员
+		systemUser.setIsAdmin(1);
 		systemUserService.save(systemUser);
 		return R.ok();
 	}
-	
-	
+
+
 	@PostMapping("/edit")
 	@ApiOperation(value = "编辑人员", tags = {"三个身边后台-人员管理"})
-	@OperLog(operModul = "三个身边后台",operType = 2,businessType = "编辑人员")
+	@SysLog(operatorCategory = "编辑账号",operId = 4)
 	public R edit(@RequestBody SystemUser systemUser){
 		long count = systemUserService.count(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getPhone, systemUser.getPhone())
 				.ne(SystemUser::getStatus, 3).ne(SystemUser::getId, systemUser.getId()));
 		if(0 < count){
 			return R.fail("手机号重复。");
 		}
+
+		String districtsCode = systemUser.getDistrictsCode();
+		if (!StringUtils.isEmpty(districtsCode)){
+			BcRegion bcRegion = bcRegionService.getOne(new LambdaQueryWrapper<BcRegion>().eq(BcRegion::getRegionCode, districtsCode));
+			systemUser.setDistricts(bcRegion.getRegionName());
+		}
+
+		String streetId = systemUser.getStreetId();
+		if (!StringUtils.isEmpty(streetId)){
+			ComStreet comStreet = comStreetService.getById(streetId);
+			systemUser.setStreet(comStreet.getName());
+		}
+		Long communityId = systemUser.getCommunityId();
+		if (communityId != null){
+			ComAct act = comActService.getById(communityId);
+			systemUser.setCommunity(act.getName());
+		}
+
+
 		systemUser.setStatus(1);
 		systemUser.setCreateTime(LocalDateTime.now());
 		systemUserService.updateById(systemUser);
 		return R.ok();
 	}
-	
-	
+
+
 	@DeleteMapping("/delete/{id}")
 	@ApiOperation(value = "删除人员", tags = {"三个身边后台-人员管理"})
-	@OperLog(operModul = "三个身边后台",operType = 3,businessType = "删除人员")
+	@SysLog(operatorCategory = "删除账号",operId = 4)
 	public R delete(@PathVariable("id") Integer id){
 		SystemUser systemUser = systemUserService.getById(id);
 		systemUser.setStatus(3);
 		systemUserService.updateById(systemUser);
-		return R.ok();
+		return R.ok(systemUser.getName());
 	}
-	
-	
+
+
 	@GetMapping("/getSystemUserInfo/{id}")
 	@ApiOperation(value = "查询人员详情", tags = {"三个身边后台-人员管理"})
 	@OperLog(operModul = "三个身边后台",operType = 0,businessType = "查询人员详情")
@@ -254,8 +302,8 @@
 		SystemUser systemUser = systemUserService.getById(id);
 		return R.ok(systemUser);
 	}
-	
-	
+
+
 	@PutMapping("/freeze/{id}")
 	@ApiOperation(value = "冻结账号", tags = {"三个身边后台-人员管理"})
 	@OperLog(operModul = "三个身边后台",operType = 2,businessType = "冻结账号")
@@ -268,8 +316,8 @@
 		systemUserService.updateById(systemUser);
 		return R.ok();
 	}
-	
-	
+
+
 	@PutMapping("/unfreeze/{id}")
 	@ApiOperation(value = "解冻账号", tags = {"三个身边后台-人员管理"})
 	@OperLog(operModul = "三个身边后台",operType = 2,businessType = "解冻账号")
@@ -282,8 +330,8 @@
 		systemUserService.updateById(systemUser);
 		return R.ok();
 	}
-	
-	
+
+
 	/**
 	 * 根据用户id获取信息
 	 * @param id
@@ -304,9 +352,9 @@
 		BeanUtils.copyProperties(systemUser, systemUserVo);
 		return R.ok(systemUserVo);
 	}
-	
-	
-	
+
+
+
 	@GetMapping("/getAdministrativeDivision/{id}/{tier}")
 	@ApiOperation(value = "获取行政区划层级联动数据", tags = {"三个身边后台-人员管理"})
 	@ApiImplicitParams({
@@ -328,6 +376,42 @@
 		if(4 == tier){
 			list = systemUserService.getCommunity(id);
 		}
+		log.info("获取行政区划层级联动数据:{}", list);
 		return R.ok(list);
 	}
+	@GetMapping("/regionTree")
+	@ApiOperation(value = "获取区县-街道-社区树",tags = {"三个身边后台-人员管理"})
+	public R<List<RegionVO>> regionTree(){
+		SystemUserVo loginUserInfo = getLoginUserInfoSanGeShenBian();
+		List<RegionVO> list = systemUserService.getRegionTree(loginUserInfo);
+		return R.ok(list);
+	}
+
+
+	@GetMapping("/getSignature")
+	@ApiOperation(value = "获取签名",tags = {"三个身边小程序"})
+    public R<?> getSignature() throws Exception {
+        String APP_ID = "wx118de8a734d269f0";
+        String APP_SECRET = "0264342daefde5cd70a6adada09ee5b1";
+        String accessToken = SignatureUtil.getAccessToken(APP_ID, APP_SECRET);
+        String jsapiTicket = SignatureUtil.getJsApiTicket(accessToken);
+        String nonceStr = UUID.randomUUID().toString().replace("-", "");
+        String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
+        String url = "https://huacheng.psciio.com/web/sangeshenbian/"; // 当前页面的URL,不包含#及其后面部分
+
+        String signature = SignatureUtil.getSignature(jsapiTicket, nonceStr, timestamp, url);
+
+        System.out.println("appId: " + APP_ID);
+        System.out.println("timestamp: " + timestamp);
+        System.out.println("nonceStr: " + nonceStr);
+        System.out.println("signature: " + signature);
+        SignatureVO signatureVO = new SignatureVO();
+        signatureVO.setTimestamp(timestamp);
+        signatureVO.setNonceStr(nonceStr);
+        signatureVO.setSignature(signature);
+        return R.ok(signatureVO);
+    }
+
+
+
 }

--
Gitblit v1.7.1