|
@@ -0,0 +1,155 @@
|
|
|
+package com.css.simulation.resource.system.ctrl;
|
|
|
+
|
|
|
+import api.common.pojo.common.ResponseBodyVO;
|
|
|
+import api.common.pojo.constants.DictConstants;
|
|
|
+import api.common.pojo.param.scene.SystemScenePackageParam;
|
|
|
+import api.common.pojo.po.system.UserPO;
|
|
|
+import api.common.pojo.vo.scene.SystemScenePackageVO;
|
|
|
+import api.common.pojo.vo.system.ClusterVO;
|
|
|
+import api.common.pojo.vo.system.ParameterVO;
|
|
|
+import api.common.pojo.vo.system.UserVO;
|
|
|
+import api.common.util.ObjectUtil;
|
|
|
+import com.css.simulation.resource.common.utils.AuthUtil;
|
|
|
+import com.css.simulation.resource.scene.service.SystemScenePackageService;
|
|
|
+import com.css.simulation.resource.system.service.ClusterService;
|
|
|
+import com.css.simulation.resource.system.service.ParameterService;
|
|
|
+import com.css.simulation.resource.system.service.UserService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+@Controller()
|
|
|
+@RequestMapping("/userInfo")
|
|
|
+public class UserInfoCtrl {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ClusterService clusterService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ParameterService parameterService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ SystemScenePackageService systemScenePackageService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前登录人详情
|
|
|
+ */
|
|
|
+ @RequestMapping("/getCurrentUserInfo")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseBodyVO getCurrentUserInfo() {
|
|
|
+ ResponseBodyVO<UserVO> response = new ResponseBodyVO<UserVO>(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ response.setInfo(userService.getCurrentUserInfo());
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据user_id查询参数配置信息
|
|
|
+ */
|
|
|
+ @RequestMapping("/getParameterByUserId")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseBodyVO<ParameterVO> getParameterByUserId() {
|
|
|
+ ResponseBodyVO<ParameterVO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ ParameterVO param = parameterService.getParameterByUserId();
|
|
|
+ response.setInfo(param);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据user_id查询集群配置信息
|
|
|
+ */
|
|
|
+ @RequestMapping("/getClusterByUserId")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseBodyVO<ClusterVO> getClusterByUserId() {
|
|
|
+ ResponseBodyVO<ClusterVO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ ClusterVO clusterVO = clusterService.getClusterByUserId();
|
|
|
+ response.setInfo(clusterVO);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前登录人详情
|
|
|
+ */
|
|
|
+ @RequestMapping("/getSceneResource")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseBodyVO getSceneResource() {
|
|
|
+ String roleCode = AuthUtil.getCurrentUserRoleCode();
|
|
|
+ String userId = AuthUtil.getCurrentUserId();
|
|
|
+ if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){ //管理员账户
|
|
|
+ return null;
|
|
|
+ }else if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
|
|
|
+ //查询父账户
|
|
|
+ userId = AuthUtil.getCreateUserId();
|
|
|
+ }
|
|
|
+ SystemScenePackageParam param = new SystemScenePackageParam();
|
|
|
+ param.setUserId(userId);
|
|
|
+ List<SystemScenePackageVO> list = systemScenePackageService.querySystemScenePackageList(param);
|
|
|
+ long zrTotalCount = list.stream().mapToLong(SystemScenePackageVO::getZrCount).sum();
|
|
|
+ long bzTotalCount = list.stream().mapToLong(SystemScenePackageVO::getBzCount).sum();
|
|
|
+ long jtTotalCount = list.stream().mapToLong(SystemScenePackageVO::getJtCount).sum();
|
|
|
+ long fhTotalCount = list.stream().mapToLong(SystemScenePackageVO::getFhCount).sum();
|
|
|
+ long sum = list.stream().mapToLong(SystemScenePackageVO::getTotalCount).sum();
|
|
|
+ HashMap resMap = new HashMap();
|
|
|
+ resMap.put("list", list);
|
|
|
+ resMap.put("zrTotalCount", zrTotalCount);
|
|
|
+ resMap.put("bzTotalCount", bzTotalCount);
|
|
|
+ resMap.put("jtTotalCount", jtTotalCount);
|
|
|
+ resMap.put("fhTotalCount", fhTotalCount);
|
|
|
+ resMap.put("sum", sum);
|
|
|
+
|
|
|
+ ResponseBodyVO<HashMap> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ response.setInfo(resMap);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人信息管理-修改联系方式
|
|
|
+ */
|
|
|
+ @RequestMapping("/savePhone")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseBodyVO savePhone(@RequestBody UserPO userPO) {
|
|
|
+ if(ObjectUtil.isNull(userPO)){
|
|
|
+ return new ResponseBodyVO(false, 400, "参数必传!",null);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNull(userPO.getId()) || ObjectUtil.isNull(userPO.getNickname())|| ObjectUtil.isNull(userPO.getPhone())){
|
|
|
+ return new ResponseBodyVO(false, 400, "参数必传!",null);
|
|
|
+ }
|
|
|
+ userService.savePhone(userPO);
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人信息管理-修改密码
|
|
|
+ */
|
|
|
+ @RequestMapping("/savePassword")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseBodyVO savePassword(@RequestBody UserPO userPO) throws NoSuchAlgorithmException {
|
|
|
+ if(ObjectUtil.isNull(userPO)){
|
|
|
+ return new ResponseBodyVO(false, 400, "参数必传!",null);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNull(userPO.getId()) || ObjectUtil.isNull(userPO.getPassword()) || ObjectUtil.isNull(userPO.getNewPassword())){
|
|
|
+ return new ResponseBodyVO(false, 400, "参数必传!",null);
|
|
|
+ }
|
|
|
+ UserPO userPORes = userService.savePassword(userPO);
|
|
|
+ if(ObjectUtil.isNull(userPORes)){
|
|
|
+ return new ResponseBodyVO(false, 400, "原密码错误!",null);
|
|
|
+ }
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|