diff --git a/ant-design-vue-jeecg/src/views/user/Login.vue b/ant-design-vue-jeecg/src/views/user/Login.vue
index 0861bb6..a679235 100644
--- a/ant-design-vue-jeecg/src/views/user/Login.vue
+++ b/ant-design-vue-jeecg/src/views/user/Login.vue
@@ -1,36 +1,40 @@
-
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
- 确定
+ 确定
-
+
-
+
@@ -45,170 +49,221 @@ import { timeFix } from '@/utils/util'
import LoginAccount from './LoginAccount'
import LoginPhone from './LoginPhone'
+import { getAction, postAction } from '@api/manage'
export default {
- components: {
- LoginSelectTenant,
- TwoStepCaptcha,
- ThirdLogin,
- LoginAccount,
- LoginPhone
- },
- data () {
- return {
- customActiveKey: 'tab1',
- rememberMe: true,
- loginBtn: false,
- requiredTwoStepCaptcha: false,
- stepCaptchaVisible: false,
- encryptedString:{
- key:"",
- iv:"",
- },
+ components: {
+ LoginSelectTenant,
+ TwoStepCaptcha,
+ ThirdLogin,
+ LoginAccount,
+ LoginPhone
+ },
+ data() {
+ return {
+ customActiveKey: 'tab1',
+ rememberMe: true,
+ loginBtn: false,
+ requiredTwoStepCaptcha: false,
+ stepCaptchaVisible: false,
+ encryptedString: {
+ key: '',
+ iv: ''
}
+ }
+ },
+ created() {
+ Vue.ls.remove(ACCESS_TOKEN)
+ this.getRouterData()
+ this.rememberMe = true
+ // 页面加载时检查URL中的code参数
+ this.checkCodeAndLogin()
+ },
+ methods: {
+ handleTabClick(key) {
+ this.customActiveKey = key
},
- created() {
- Vue.ls.remove(ACCESS_TOKEN)
- this.getRouterData();
- this.rememberMe = true
+ handleRememberMeChange(e) {
+ this.rememberMe = e.target.checked
},
- methods:{
- handleTabClick(key){
- this.customActiveKey = key
- },
- handleRememberMeChange(e){
- this.rememberMe = e.target.checked
- },
- /**跳转到登录页面的参数-账号获取*/
- getRouterData(){
- this.$nextTick(() => {
- let temp = this.$route.params.username || this.$route.query.username || ''
- if (temp) {
- this.$refs.alogin.acceptUsername(temp)
- }
- })
- },
-
- //登录
- handleSubmit () {
- this.loginBtn = true;
- if (this.customActiveKey === 'tab1') {
- // 使用账户密码登录
- this.$refs.alogin.handleLogin(this.rememberMe)
- } else {
- //手机号码登录
- this.$refs.plogin.handleLogin(this.rememberMe)
+ getQueryParam(name) {
+ // 从URL中提取查询字符串(去掉开头的?)
+ const queryString = window.location.search.substring(1)
+ // 分割参数对
+ const paramPairs = queryString.split('&')
+
+ for (let i = 0; i < paramPairs.length; i++) {
+ const pair = paramPairs[i].split('=')
+ // 解码参数名和值(处理中文等特殊字符)
+ const paramName = decodeURIComponent(pair[0])
+ const paramValue = pair[1] ? decodeURIComponent(pair[1]) : ''
+
+ if (paramName === name) {
+ return paramValue
}
- },
- // 校验失败
- validateFail(){
- this.loginBtn = false;
- },
- // 登录后台成功
- requestSuccess(loginResult){
- this.$refs.loginSelect.show(loginResult)
- },
- //登录后台失败
- requestFailed (err) {
- let description = ((err.response || {}).data || {}).message || err.message || "请求出现错误,请稍后再试"
- this.$notification[ 'error' ]({
- message: '登录失败',
- description: description,
- duration: 4,
- });
- //账户密码登录错误后更新验证码
- if(this.customActiveKey === 'tab1' && description.indexOf('密码错误')>0){
- this.$refs.alogin.handleChangeCheckCode()
+ }
+ // 未找到参数返回null
+ return null
+ },
+ /**
+ * 检查URL中的code参数并尝试自动登录
+ */
+ checkCodeAndLogin() {
+ // 获取URL中的code参数
+ const code = this.getQueryParam('code')
+
+ if (code) {
+
+ // 调用登录接口
+ this.handleCodeLogin(code)
+ }
+ },
+ /**
+ * 使用code调用登录接口
+ */
+ handleCodeLogin(code) {
+ this.autoLoginMsg = '检测到授权码,正在自动登录...'
+ this.loading = true
+ getAction(`/inspur/login?code=${code}`).then((res) => {
+ if (res.success) {
+ this.$emit('success', res.result)
+ this.loginSuccess()
}
- this.loginBtn = false;
- },
- loginSelectOk(){
- this.loginSuccess()
- },
- //登录成功
- loginSuccess () {
- this.$router.push({ path: "/dashboard/analysis" }).catch(()=>{
- console.log('登录跳转首页出错,这个错误从哪里来的')
- })
- this.$notification.success({
- message: '欢迎',
- description: `${timeFix()},欢迎回来`,
- });
- },
-
- stepCaptchaSuccess () {
- this.loginSuccess()
- },
- stepCaptchaCancel () {
- this.Logout().then(() => {
- this.loginBtn = false
- this.stepCaptchaVisible = false
- })
- },
- //获取密码加密规则
- getEncrypte(){
- var encryptedString = Vue.ls.get(ENCRYPTED_STRING);
- if(encryptedString == null){
- getEncryptedString().then((data) => {
- this.encryptedString = data
- });
- }else{
- this.encryptedString = encryptedString;
+ }).catch(error => {
+ this.loading = false
+ this.errorMsg = error.message || '自动登录失败,请手动登录'
+ console.error('Auto login failed:', error)
+ })
+ },
+ /**跳转到登录页面的参数-账号获取*/
+ getRouterData() {
+ this.$nextTick(() => {
+ let temp = this.$route.params.username || this.$route.query.username || ''
+ if (temp) {
+ this.$refs.alogin.acceptUsername(temp)
}
+ })
+ },
+
+ //登录
+ handleSubmit() {
+ this.loginBtn = true
+ if (this.customActiveKey === 'tab1') {
+ // 使用账户密码登录
+ this.$refs.alogin.handleLogin(this.rememberMe)
+ } else {
+ //手机号码登录
+ this.$refs.plogin.handleLogin(this.rememberMe)
+ }
+ },
+ // 校验失败
+ validateFail() {
+ this.loginBtn = false
+ },
+ // 登录后台成功
+ requestSuccess(loginResult) {
+ this.$refs.loginSelect.show(loginResult)
+ },
+ //登录后台失败
+ requestFailed(err) {
+ let description = ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试'
+ this.$notification['error']({
+ message: '登录失败',
+ description: description,
+ duration: 4
+ })
+ //账户密码登录错误后更新验证码
+ if (this.customActiveKey === 'tab1' && description.indexOf('密码错误') > 0) {
+ this.$refs.alogin.handleChangeCheckCode()
}
+ this.loginBtn = false
+ },
+ loginSelectOk() {
+ this.loginSuccess()
+ },
+ //登录成功
+ loginSuccess() {
+ this.$router.push({ path: '/dashboard/analysis' }).catch(() => {
+ console.log('登录跳转首页出错,这个错误从哪里来的')
+ })
+ this.$notification.success({
+ message: '欢迎',
+ description: `${timeFix()},欢迎回来`
+ })
+ },
+ stepCaptchaSuccess() {
+ this.loginSuccess()
+ },
+ stepCaptchaCancel() {
+ this.Logout().then(() => {
+ this.loginBtn = false
+ this.stepCaptchaVisible = false
+ })
+ },
+ //获取密码加密规则
+ getEncrypte() {
+ var encryptedString = Vue.ls.get(ENCRYPTED_STRING)
+ if (encryptedString == null) {
+ getEncryptedString().then((data) => {
+ this.encryptedString = data
+ })
+ } else {
+ this.encryptedString = encryptedString
+ }
}
-
}
+}
\ No newline at end of file
diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/controller/InspurUserController.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/controller/InspurUserController.java
index b15354d..2cae004 100644
--- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/controller/InspurUserController.java
+++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/controller/InspurUserController.java
@@ -1,20 +1,36 @@
package org.jeecg.modules.inspur.controller;
+import cn.hutool.json.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.constant.SymbolConstant;
+import org.jeecg.common.system.util.JwtUtil;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.RedisUtil;
+import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.inspur.domain.InspurRegisterParams;
import org.jeecg.modules.inspur.domain.InspurResp;
-import org.jeecg.modules.inspur.entity.InspurUser;
import org.jeecg.modules.inspur.service.InspurService;
import org.jeecg.modules.inspur.util.ConstantInspur;
+import org.jeecg.modules.inspur.util.UniqueIdGenerator;
+import org.jeecg.modules.system.entity.SysDepart;
+import org.jeecg.modules.system.entity.SysTenant;
import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysDepartService;
+import org.jeecg.modules.system.service.ISysDictService;
+import org.jeecg.modules.system.service.ISysTenantService;
+import org.jeecg.modules.system.service.ISysUserService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
/**
* @author 84018
@@ -26,29 +42,141 @@ import java.util.Map;
public class InspurUserController {
private final InspurService inspurService;
+ @Autowired
+ private ISysUserService sysUserService;
+ @Autowired
+ private RedisUtil redisUtil;
+ @Autowired
+ private ISysDepartService sysDepartService;
+ @Autowired
+ private ISysTenantService sysTenantService;
+ @Autowired
+ private ISysDictService sysDictService;
- @RequestMapping("/register")
+ @PostMapping("/register")
public ResponseEntity register(@RequestBody InspurRegisterParams registerParams) {
- String code = registerParams.getCode();
- String token = null;
- String traceId = null;
- if (code != null && !code.isEmpty()) {
- Map map = inspurService.appAuthCheck(code);
- token = (String) map.get("token");
- traceId = (String) map.get("traceId");
+ if (!ConstantInspur.APP_ID.equals(registerParams.getAppKey())) {
+ InspurResp resp = InspurResp.builder()
+ .code(ConstantInspur.SUCCESS_CODE_ERR)
+ .msg("开通失败:AppId错误")
+ .data(null)
+ .build();
+ new ResponseEntity(resp, HttpStatus.OK);
}
- InspurUser inspurUser = inspurService.getUserInfoByToken(token);
- SysUser user = new SysUser();
- user.setUsername("admin");
- user.setPassword("123456");
+
+ if (!ConstantInspur.APP_SECRET.equals(registerParams.getAppSecret())) {
+ InspurResp resp = InspurResp.builder()
+ .code(ConstantInspur.SUCCESS_CODE_ERR)
+ .msg("开通失败:AppSecret错误")
+ .data(null)
+ .build();
+ new ResponseEntity(resp, HttpStatus.OK);
+ }
+
+ String traceId = UniqueIdGenerator.generate16DigitId();
+
+ JSONObject resultJson = inspurService.addAccount(registerParams);
InspurResp resp = InspurResp.builder()
.code(ConstantInspur.SUCCESS_CODE_INT)
.msg("成功")
- .data(user)
+ .data(resultJson)
.traceId(traceId)
.build();
return new ResponseEntity(resp, HttpStatus.OK);
}
+ @GetMapping("/login")
+ public Result login(@RequestParam String code) {
+ Result result = new Result();
+// String token = null;
+// if (code != null && !code.isEmpty()) {
+// Map map = inspurService.appAuthCheck(code);
+// token = (String) map.get("token");
+// }
+// if (StringUtils.isEmpty(token)) {
+// result.error500("登录失败,code无效");
+// return result;
+// }
+//
+// InspurUser inspurUser = inspurService.getUserInfoByToken(token);
+// if (ObjectUtils.isEmpty(inspurUser)) {
+// result.error500("登录失败,用户信息为空");
+// return result;
+// }
+//
+// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
+// queryWrapper.eq(SysUser::getUsername, inspurUser.getLoginLoginname());
+// SysUser sysUser = sysUserService.getOne(queryWrapper);
+// result = sysUserService.checkUserIsEffective(sysUser);
+// if (!result.isSuccess()) {
+// return result;
+// }
+
+ SysUser sysUser = sysUserService.getUserByName("admin");
+ //用户登录信息
+ userInfo(sysUser, result);
+ LoginUser loginUser = new LoginUser();
+ BeanUtils.copyProperties(sysUser, loginUser);
+ return result;
+ }
+
+ /**
+ * 用户信息
+ *
+ * @param sysUser
+ * @param result
+ * @return
+ */
+ private Result userInfo(SysUser sysUser, Result result) {
+ String username = sysUser.getUsername();
+ String syspassword = sysUser.getPassword();
+ // 获取用户部门信息
+ com.alibaba.fastjson.JSONObject obj = new com.alibaba.fastjson.JSONObject(new LinkedHashMap<>());
+
+ // 生成token
+ String token = JwtUtil.sign(username, syspassword);
+ // 设置token缓存有效时间
+ redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
+ redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
+ obj.put("token", token);
+
+ String tenantIds = sysUser.getRelTenantIds();
+ if (oConvertUtils.isNotEmpty(tenantIds)) {
+ List tenantIdList = new ArrayList<>();
+ for (String id : tenantIds.split(SymbolConstant.COMMA)) {
+ tenantIdList.add(Integer.valueOf(id));
+ }
+ List tenantList = sysTenantService.queryEffectiveTenant(tenantIdList);
+ if (tenantList.size() == 0) {
+ result.error500("与该用户关联的租户均已被冻结,无法登录!");
+ return result;
+ } else {
+ obj.put("tenantList", tenantList);
+ }
+ }
+ // 20210802 for:获取用户租户信息
+
+ obj.put("userInfo", sysUser);
+
+ List departs = sysDepartService.queryUserDeparts(sysUser.getId());
+ obj.put("departs", departs);
+ if (departs == null || departs.size() == 0) {
+ obj.put("multi_depart", 0);
+ } else if (departs.size() == 1) {
+ sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
+ obj.put("multi_depart", 1);
+ } else {
+ SysUser sysUserById = sysUserService.getById(sysUser.getId());
+ if (oConvertUtils.isEmpty(sysUserById.getOrgCode())) {
+ sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
+ }
+ // 如果用戶为选择部门,数据库为存在上一次登录部门,则取一条存进去
+ obj.put("multi_depart", 2);
+ }
+ obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
+ result.setResult(obj);
+ result.success("登录成功");
+ return result;
+ }
}
diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/domain/InspurRegisterParams.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/domain/InspurRegisterParams.java
index dbe5329..c9f5c26 100644
--- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/domain/InspurRegisterParams.java
+++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/domain/InspurRegisterParams.java
@@ -43,7 +43,7 @@ public class InspurRegisterParams {
/**
* 应用秘钥
*/
- private int appSecret;
+ private String appSecret;
/**
* 随机码, 由算网平台生成,用于校验访问合法性
diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/domain/InspurResp.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/domain/InspurResp.java
index 0b70cde..e82302b 100644
--- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/domain/InspurResp.java
+++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/domain/InspurResp.java
@@ -1,10 +1,10 @@
package org.jeecg.modules.inspur.domain;
+import cn.hutool.json.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
-import org.jeecg.modules.system.entity.SysUser;
/**
* @author 84018
@@ -32,5 +32,5 @@ public class InspurResp {
/**
* 校验通过返回数据
*/
- private SysUser data;
+ private JSONObject data;
}
diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/service/InspurService.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/service/InspurService.java
index 2b0342d..efe053d 100644
--- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/service/InspurService.java
+++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/service/InspurService.java
@@ -1,6 +1,7 @@
package org.jeecg.modules.inspur.service;
+import cn.hutool.json.JSONObject;
import org.jeecg.modules.inspur.domain.InspurRegisterParams;
import org.jeecg.modules.inspur.entity.InspurUser;
@@ -20,7 +21,7 @@ public interface InspurService {
* @param params 平台的账号信息
* @return
*/
- String addAccount(InspurRegisterParams params);
+ JSONObject addAccount(InspurRegisterParams params);
/**
* 获取平台token
diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/service/impl/InspurServiceImpl.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/service/impl/InspurServiceImpl.java
index 974308a..1c25c8a 100644
--- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/service/impl/InspurServiceImpl.java
+++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/service/impl/InspurServiceImpl.java
@@ -1,16 +1,27 @@
package org.jeecg.modules.inspur.service.impl;
+import cn.hutool.core.date.DateTime;
import cn.hutool.crypto.digest.Digester;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.util.PasswordUtil;
import org.jeecg.modules.inspur.domain.InspurRegisterParams;
import org.jeecg.modules.inspur.entity.InspurTenant;
import org.jeecg.modules.inspur.entity.InspurUser;
import org.jeecg.modules.inspur.service.InspurService;
import org.jeecg.modules.inspur.util.ConstantInspur;
import org.jeecg.modules.inspur.util.UniqueIdGenerator;
+import org.jeecg.modules.system.entity.SysTenant;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.entity.SysUserRole;
+import org.jeecg.modules.system.service.ISysTenantService;
+import org.jeecg.modules.system.service.ISysUserRoleService;
+import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@@ -23,13 +34,83 @@ import java.util.Map;
* @date 2025-05-30 14:40
*/
@Slf4j
+@RequiredArgsConstructor
@Service
public class InspurServiceImpl implements InspurService {
+ final private ISysUserService sysUserService;
+
+ final private ISysTenantService sysTenantService;
+
+ final private ISysUserRoleService userRoleService;
@Override
- public String addAccount(InspurRegisterParams params) {
- System.out.println("添加用户接口。 请求参数:" + JSONUtil.toJsonStr(params));
+ public JSONObject addAccount(InspurRegisterParams params) {
+ JSONObject resultJson = new JSONObject();
+
+ // 先检查用户是否存在
+ SysUser userCheck = sysUserService.getOne(Wrappers.lambdaQuery(SysUser.class).eq(SysUser::getUsername, params.getPltAccountLogin()));
+
+ // 若用户已存在且未被冻结,则直接返回该用户
+ if (userCheck != null && !CommonConstant.USER_FREEZE.equals(userCheck.getStatus())) {
+ resultJson.put("account", userCheck.getUsername());
+ resultJson.put("token", userCheck.getPassword());
+ resultJson.put("tenantId", userCheck.getRelTenantIds());
+ resultJson.put("tenantInfo", params.getEnterpriseName());
+ return resultJson;
+ }
+
+ // 若用户不存在,则创建该用户
+ if (userCheck == null) {
+ SysTenant tenant = new SysTenant();
+ tenant.setName(params.getEnterpriseName());
+ tenant.setCreateBy("inspur");
+ tenant.setCreateTime(DateTime.now());
+ sysTenantService.save(tenant);
+
+ SysUser sysUser = new SysUser();
+ sysUser.setUsername(params.getPltAccountLogin());
+ String pwd = PasswordUtil.encrypt(params.getPltAccountLogin(), ConstantInspur.DEFAULT_PWD, sysUser.getSalt());
+ sysUser.setPassword(params.getPltAccountLogin());
+ sysUser.setCreateBy("inspur");
+ sysUser.setCreateTime(DateTime.now());
+ sysUser.setUpdateBy("inspur");
+ sysUser.setUpdateTime(DateTime.now());
+ sysUser.setPurchaseDuration(params.getPurchaseDuration());
+ sysUser.setPurchaseUnit(params.getPurchaseUnit());
+ sysUser.setRelTenantIds(tenant.getId().toString());
+ sysUser.setStatus(CommonConstant.USER_UNFREEZE);
+ sysUser.setDelFlag(CommonConstant.DEL_FLAG_0);
+ sysUserService.save(sysUser);
+
+ SysUserRole userRole = new SysUserRole();
+ userRole.setRoleId(ConstantInspur.ROLE_ID_ADMIN);
+ userRole.setUserId(sysUser.getId());
+ userRoleService.save(userRole);
+
+ resultJson.put("account", sysUser.getUsername());
+ resultJson.put("token", sysUser.getPassword());
+ resultJson.put("tenantId", sysUser.getRelTenantIds());
+ resultJson.put("tenantInfo", params.getEnterpriseName());
+ return resultJson;
+ }
+
+ // 若用户被冻结, 更新用户状态及有效期
+ if (userCheck != null && CommonConstant.USER_FREEZE.equals(userCheck.getStatus())) {
+ userCheck.setUpdateBy("inspur");
+ userCheck.setUpdateTime(DateTime.now());
+ userCheck.setPurchaseUnit(params.getPurchaseUnit());
+ userCheck.setStatus(CommonConstant.USER_UNFREEZE);
+
+ sysUserService.updateById(userCheck);
+
+ resultJson.put("account", userCheck.getUsername());
+ resultJson.put("token", userCheck.getPassword());
+ resultJson.put("tenantId", userCheck.getRelTenantIds());
+ resultJson.put("tenantInfo", params.getEnterpriseName());
+ return resultJson;
+ }
+
return null;
}
@@ -47,16 +128,17 @@ public class InspurServiceImpl implements InspurService {
JSONObject resultJson = JSONUtil.parseObj(resultStr);
+ Map resultMap = new HashMap<>();
if (ConstantInspur.SUCCESS_CODE.equals(resultJson.getStr("code"))) {
String resultData = resultJson.getStr("data");
String resultTraceId = resultJson.getStr("traceId");
- Map resultMap = new HashMap<>();
resultMap.put("token", resultData);
resultMap.put("traceId", resultTraceId);
return resultMap;
} else {
- throw new RuntimeException(resultJson.getStr("msg"));
+ log.error("身份校验接口返回:" + resultJson.toStringPretty());
}
+ return resultMap;
}
@Override
diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/util/ConstantInspur.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/util/ConstantInspur.java
index eb6d4dc..65b18f5 100644
--- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/util/ConstantInspur.java
+++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/inspur/util/ConstantInspur.java
@@ -15,9 +15,13 @@ public class ConstantInspur {
public static String API_URL_GET_USER_INFO = API_HOST + ":8083/cpn/api/extral/applicationCode/getUserInfoByToken";
public static String API_URL_HEARTBEAT = API_HOST + ":8083/cpn/api/extra/v1/application/heartbeat";
- public static String APP_ID = "1124336947783794688";
- public static String APP_SECRET = "T0UoMjYwNTIwMjUxMTE0NDMxNTQdlI";
+ public static String APP_ID = "1148589323117920256";
+ public static String APP_SECRET = "usUCMDEwODIwMjUwOTI1MDAwMjAFZ0";
public static String SUCCESS_CODE = "20000";
public static Integer SUCCESS_CODE_INT = 20000;
+ public static Integer SUCCESS_CODE_ERR = 50000;
+ public static String DEFAULT_PWD = "123456";
+
+ public static String ROLE_ID_ADMIN = "f6817f48af4fb3af11b9e8bf182f618b";
}