diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/entity/IUser.java b/campus-modular/src/main/java/com/oddfar/campus/business/entity/IUser.java index c83969cb..1cce4496 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/entity/IUser.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/entity/IUser.java @@ -130,6 +130,24 @@ public IUser() { } + public IUser(Long mobile, JSONObject jsonObject) { + JSONObject data = jsonObject.getJSONObject("data"); + this.userId = data.getLong("userId"); + this.mobile = mobile; + this.token = data.getString("token"); + this.cookie = data.getString("cookie"); + this.jsonResult = StringUtils.substring(jsonObject.toJSONString(), 0, 2000); + + if (StringUtils.isEmpty(this.remark)) { + this.remark = data.getString("userName"); + } + + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, 30); + Date thirtyDaysLater = calendar.getTime(); + this.expireTime = thirtyDaysLater; + } + public IUser(Long mobile, String deviceId, JSONObject jsonObject) { JSONObject data = jsonObject.getJSONObject("data"); this.userId = data.getLong("userId"); diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java b/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java index 5e5db73a..4ccc7225 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IMTServiceImpl.java @@ -15,6 +15,7 @@ import com.alibaba.fastjson2.JSONObject; import com.oddfar.campus.business.entity.IUser; import com.oddfar.campus.business.mapper.IShopMapper; +import com.oddfar.campus.business.mapper.IUserMapper; import com.oddfar.campus.business.service.IMTLogFactory; import com.oddfar.campus.business.service.IMTService; import com.oddfar.campus.business.service.IShopService; @@ -46,7 +47,9 @@ public class IMTServiceImpl implements IMTService { private static final Logger logger = LoggerFactory.getLogger(IMTServiceImpl.class); @Autowired - IShopMapper iShopMapper; + private IShopMapper iShopMapper; + @Autowired + private IUserMapper iUserMapper; @Autowired private RedisCache redisCache; @@ -147,7 +150,10 @@ public boolean login(String mobile, String code, String deviceId) { HttpRequest request = HttpUtil.createRequest(Method.POST, "https://app.moutai519.com.cn/xhr/front/user/register/login"); - + IUser user = iUserMapper.selectById(mobile); + if (user != null) { + deviceId = user.getDeviceId(); + } request.header("MT-Device-ID", deviceId); request.header("MT-APP-Version", getMTVersion()); request.header("User-Agent", "iOS;16.3;Apple;?unrecognized?"); @@ -163,7 +169,7 @@ public boolean login(String mobile, String code, String deviceId) { return true; } else { logger.error("「登录请求-失败」" + body.toJSONString()); - throw new ServiceException("登录失败,日志已记录"); + throw new ServiceException("登录失败,本地错误日志已记录"); // return false; } diff --git a/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IUserServiceImpl.java b/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IUserServiceImpl.java index 0e8897f2..c23bdfe5 100644 --- a/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IUserServiceImpl.java +++ b/campus-modular/src/main/java/com/oddfar/campus/business/service/impl/IUserServiceImpl.java @@ -33,18 +33,19 @@ public PageResult page(IUser iUser) { @Override public int insertIUser(Long mobile, String deviceId, JSONObject jsonObject) { JSONObject data = jsonObject.getJSONObject("data"); - if (StringUtils.isEmpty(deviceId)) { - deviceId = UUID.randomUUID().toString().toLowerCase(); - } + IUser user = iUserMapper.selectById(mobile); if (user != null) { //存在则更新 - IUser iUser = new IUser(mobile, deviceId, jsonObject); + IUser iUser = new IUser(mobile, jsonObject); iUser.setCreateUser(SecurityUtils.getUserId()); BeanUtil.copyProperties(iUser, user); return iUserMapper.updateById(user); } else { + if (StringUtils.isEmpty(deviceId)) { + deviceId = UUID.randomUUID().toString().toLowerCase(); + } IUser iUser = new IUser(mobile, deviceId, jsonObject); iUser.setCreateUser(SecurityUtils.getUserId()); return iUserMapper.insert(iUser); diff --git a/vue_campus_admin/src/views/imt/user/index.vue b/vue_campus_admin/src/views/imt/user/index.vue index 336ef28d..2cab9488 100644 --- a/vue_campus_admin/src/views/imt/user/index.vue +++ b/vue_campus_admin/src/views/imt/user/index.vue @@ -793,6 +793,7 @@ export default { this.$modal.msgSuccess(msg); this.open = false; this.openUser = false; + this.refreshToken = false; this.getList(); }); }, @@ -820,4 +821,4 @@ export default { margin-bottom: 0; width: 50%; } - \ No newline at end of file +