|
|
@@ -7,12 +7,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
+import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
|
|
|
import com.zhongzheng.common.utils.*;
|
|
|
import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.common.utils.ip.IpUtils;
|
|
|
import com.zhongzheng.modules.alisms.service.IAliSmsService;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseMenu;
|
|
|
import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
|
|
|
import com.zhongzheng.modules.user.bo.UserAddBo;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
@@ -33,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 登录校验方法
|
|
|
@@ -59,6 +62,9 @@ public class WxLoginService
|
|
|
@Value("${wx.gzh.appid}")
|
|
|
private String gzh_appid;
|
|
|
|
|
|
+ @Value("${wx.scanLogin.host}")
|
|
|
+ private String scanLoginHost;
|
|
|
+
|
|
|
@Value("${wx.gzh.appsecret}")
|
|
|
private String gzh_appsrcret;
|
|
|
|
|
|
@@ -79,6 +85,9 @@ public class WxLoginService
|
|
|
@Autowired
|
|
|
private IAliSmsService iSmsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
@Autowired
|
|
|
private UserSchoolInfoMapper userSchoolInfoMapper;
|
|
|
|
|
|
@@ -94,6 +103,39 @@ public class WxLoginService
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ public String pcLoginUrl() {
|
|
|
+ String scanCode = ToolsUtils.getCharAndNumr(6);
|
|
|
+ String key = "SCAN_LOGIN_"+scanCode;
|
|
|
+ redisCache.setCacheObject(key, -1,30, TimeUnit.SECONDS);//30秒锁定
|
|
|
+ return scanLoginHost+"pc/login/"+scanCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PC检查是否小程序登录成功
|
|
|
+ * @param scanCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,Object> checkPcLogin(String scanCode) {
|
|
|
+ String key = "SCAN_LOGIN_"+scanCode;
|
|
|
+ Long userId = redisCache.getCacheObject(key);
|
|
|
+ if(Validator.isNotEmpty(userId)&&userId.longValue()>0L){
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>().eq(User::getUserId, userId).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("暂未登录");
|
|
|
+ }
|
|
|
+ ClientLoginUser loginUser = new ClientLoginUser();
|
|
|
+ loginUser.setUser(user);
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put(Constants.TOKEN,wxTokenService.createToken(loginUser));
|
|
|
+ map.put("user_account",loginUser.getUser().getUserAccount());
|
|
|
+ map.put("full_info",Validator.isEmpty(user.getIdCard())?false:true); //是否完善身份信息
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ throw new CustomException("暂未登录");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Map<String,Object> login(WxLoginBody loginBody) {
|
|
|
User user = getWxUnionIdUser(loginBody);
|