|
|
@@ -27,7 +27,9 @@ import com.fs.course.domain.LuckyBagCollectRecord;
|
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
+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;
|
|
|
@@ -90,6 +92,9 @@ public class AppLoginController extends AppBaseController{
|
|
|
|
|
|
@Autowired
|
|
|
private ISmsService smsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserWxMapper fsUserWxMapper;
|
|
|
@ApiOperation("注册app用户")
|
|
|
@PostMapping("/register")
|
|
|
@RepeatSubmit
|
|
|
@@ -1102,4 +1107,41 @@ public class AppLoginController extends AppBaseController{
|
|
|
OpenImResponseDTO openImResponseDTO = openIMService.deleteUserInfo(ownerUserID, friendUserID);
|
|
|
return R.ok().put("data",openImResponseDTO);
|
|
|
}
|
|
|
+
|
|
|
+ @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);
|
|
|
+ }
|
|
|
}
|