|
|
@@ -3,6 +3,7 @@ package com.fs.app.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.fs.app.annotation.Login;
|
|
|
import com.fs.app.param.*;
|
|
|
@@ -20,7 +21,9 @@ import com.fs.core.config.WxOpenProperties;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.domain.FsUserNewTask;
|
|
|
+import com.fs.his.domain.FsUserWx;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
+import com.fs.his.mapper.FsUserWxMapper;
|
|
|
import com.fs.his.service.IFsUserCouponService;
|
|
|
import com.fs.his.service.IFsUserNewTaskService;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
@@ -72,6 +75,9 @@ public class AppLoginController extends AppBaseController{
|
|
|
|
|
|
@Autowired
|
|
|
private ISmsService smsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserWxMapper fsUserWxMapper;
|
|
|
@ApiOperation("注册app用户")
|
|
|
@PostMapping("/register")
|
|
|
@RepeatSubmit
|
|
|
@@ -987,4 +993,40 @@ public class AppLoginController extends AppBaseController{
|
|
|
// 不存在,追加到末尾
|
|
|
return currentAppIds + "," + newAppId;
|
|
|
}
|
|
|
+ @PostMapping("/loginByUnionId")
|
|
|
+ public R loginByUnionId(@RequestBody FsUserUnionIdLoginParam param){
|
|
|
+ if (StringUtils.isEmpty(param.getUnionId()) || StringUtils.isEmpty(param.getOpenId())) {
|
|
|
+ return R.error("unionId或openId不能为空");
|
|
|
+ }
|
|
|
+ FsUser fsUser = userMapper.selectFsUserByUnionid(param.getUnionId());
|
|
|
+ if (ObjectUtil.isEmpty(fsUser)){
|
|
|
+ return R.error("账号不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtils.equals(fsUser.getMpOpenId(), param.getOpenId())) {
|
|
|
+ int rows = userMapper.updateMpOpenIdByUserId(fsUser.getUserId(), param.getOpenId());
|
|
|
+ if (rows <= 0) {
|
|
|
+ return R.error("绑定openId失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String appid = "wx6f25bbf90d1b13ce";
|
|
|
+ FsUserWx userWx = fsUserWxMapper.selectByAppidAndUserId(appid, fsUser.getUserId());
|
|
|
+ if(userWx == null){
|
|
|
+ FsUserWx userWx1 = new FsUserWx();
|
|
|
+ userWx1.setFsUserId(fsUser.getUserId());
|
|
|
+ userWx1.setAppId(appid);
|
|
|
+ userWx1.setUnionId(param.getUnionId());
|
|
|
+ userWx1.setOpenId(param.getOpenId());
|
|
|
+ userWx1.setType(2);
|
|
|
+ userWx1.setCreateTime(new Date());
|
|
|
+ userWx1.setUpdateTime(new Date());
|
|
|
+ fsUserWxMapper.insert(userWx1);
|
|
|
+ }
|
|
|
+ String token = jwtUtils.generateToken(fsUser.getUserId());
|
|
|
+ redisCache.setCacheObject("userToken:" + fsUser.getUserId(), token, 604800, TimeUnit.SECONDS);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("token", token);
|
|
|
+ map.put("user", fsUser);
|
|
|
+ return R.ok(map);
|
|
|
+ }
|
|
|
}
|