作者 mxy

Merge remote-tracking branch 'origin/master'

... ... @@ -77,7 +77,7 @@ public class LonginController {
return loginService.loginInit(loginBo);
}
@ApiOperation(value = "用户授权或绑定")
@ApiOperation(value = "用户授权或绑定 在openId字段上传code值 ")
@PostMapping("/loginCode")
public AjaxResult loginCode(@Valid @RequestBody LoginBo loginBo) {
return loginService.loginCode(loginBo);
... ... @@ -89,4 +89,7 @@ public class LonginController {
public AjaxResult logOut(){
return this.loginService.logOut();
}
}
... ...
... ... @@ -51,6 +51,16 @@ public class CTeacherVo {
@Excel(name = "学科")
@ApiModelProperty("学科")
private String subject;
/**
* 老师身份证号
*/
@ApiModelProperty("学科")
private String identityCard;
/**
* 老师名字
*/
@ApiModelProperty("老师名字")
private String name;
}
... ...
... ... @@ -25,6 +25,7 @@ public interface CRelationshipStudentSgcMapper extends BaseMapperPlus<CRelations
* 根据学生id 查找学生关联的班级;
* @return
*/
List<MyTeacherVO> getMyCassl();
List<MyTeacherVO> getMyCassl(Long userId);
}
... ...
... ... @@ -60,5 +60,10 @@ public interface LonginService {
*/
AjaxResult logOut();
/**
* 微信授权登录 传code
* @param loginBo
* @return
*/
AjaxResult loginCode(LoginBo loginBo);
}
... ...
... ... @@ -18,6 +18,7 @@ import com.example.client.security.LoginUser;
import com.example.client.security.TokenService;
import com.example.client.service.LonginService;
import com.example.client.service.UserService;
import com.example.client.utils.HttpUtils;
import com.example.client.utils.ip.IpUtils;
import com.example.client.utils.sign.Md5Utils;
import com.example.client.utils.verification.PhoneUtils;
... ... @@ -37,6 +38,12 @@ import java.util.concurrent.TimeUnit;
*/
@Service
public class LonginServiceImpl implements LonginService {
public static final String url = "https://api.weixin.qq.com/sns/oauth2/access_token";
public static final String APPID = "";
public static final String SECRET = "";
@Autowired
private RedisCache redisCache;
@Autowired
... ... @@ -166,13 +173,14 @@ public class LonginServiceImpl implements LonginService {
/**
* 删除缓存
*
* @param key
* @return
*/
public AjaxResult logOut(String key ) {
public AjaxResult logOut(String key) {
String cacheObject = (String)redisCache.getCacheObject(key);
String cacheObject = (String) redisCache.getCacheObject(key);
//刪除等記錄
redisCache.deleteObject(key);
//退出
... ... @@ -181,6 +189,7 @@ public class LonginServiceImpl implements LonginService {
return AjaxResult.success(true);
}
@Override
public AjaxResult forget(UpdatePasswordDTO dto) {
... ... @@ -222,7 +231,7 @@ public class LonginServiceImpl implements LonginService {
CUserVo cUserVo = userService.queryById(userId);
if(cUserVo==null){
if (cUserVo == null) {
return AjaxResult.error("非法进入");
}
CUserBo cUserBo = new CUserBo();
... ... @@ -236,7 +245,7 @@ public class LonginServiceImpl implements LonginService {
//判断是否登录
Object cacheObject = redisCache.getCacheObject(key);
//删除缓存 重新登录
if(cacheObject != null ){
if (cacheObject != null) {
logOut(key);
}
... ... @@ -250,11 +259,11 @@ public class LonginServiceImpl implements LonginService {
if (loginBo.getType() != null && loginBo.getType() == 1) {
UserTrVo userTrVo = new UserTrVo();
CUserVo cUserVo = userService.queryById(UserContext.currentUserId());
if( user != null){
if (user != null) {
AjaxResult.error("这个微信号已经绑定了账号");
}
if (cUserVo != null ) {
if (cUserVo != null) {
CUserBo cUserBo = new CUserBo();
cUserBo.setUserId(UserContext.currentUserId());
cUserBo.setOpenId(loginBo.getOpenId());
... ... @@ -274,7 +283,7 @@ public class LonginServiceImpl implements LonginService {
UserService.insert(cUser1);
}*/
if(user !=null){
if (user != null) {
LoginTokenVO vo = new LoginTokenVO();
//不返回密码
user.setUserPassword(null);
... ... @@ -302,12 +311,10 @@ public class LonginServiceImpl implements LonginService {
CUserVo user = userService.queryById(userId);
//账号和密码来做key
String key = user.getAccount() + user.getUserPassword();
String cacheObject = (String)redisCache.getCacheObject(key);
String cacheObject = (String) redisCache.getCacheObject(key);
//
CUserBo cUserBo = new CUserBo();
cUserBo.setUserId(UserContext.currentUserId());
... ... @@ -327,6 +334,12 @@ public class LonginServiceImpl implements LonginService {
@Override
public AjaxResult loginCode(LoginBo loginBo) {
return null;
String param = "appid=" + APPID + "&secret=" + SECRET + "&code=" + loginBo.getOpenId() + "&grant_type=authorization_code";
String s = HttpUtils.mySendGet(url, param);
System.out.println("======================================================="+s);
return AjaxResult.success(s);
}
}
... ...
... ... @@ -14,6 +14,7 @@ import com.example.client.enumeration.Identity;
import com.example.client.mapper.*;
import com.example.client.service.MineService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -43,7 +44,7 @@ public class MineServiceImpl implements MineService {
private CFollowerMapper cFollowerMapper;
@Autowired
private CActivityMapper cActivityMapper;
private CTeacherMapper cTeacherMapper;
@Autowired
private CExperienceEducationMapper cExperienceEducationMapper;
... ... @@ -719,11 +720,21 @@ public class MineServiceImpl implements MineService {
public AjaxResult openMyTeacher() {
Long userId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(userId);
if(!cUser.getIdentityType().equals(Identity.STUDENT)){
return AjaxResult.error("只有学生有我的老师");
}
List<MyTeacherVO> myCassl = cRelationshipStudentSgcMapper.getMyCassl(userId);
if(myCassl==null){
return AjaxResult.error("你还没有绑定班级");
}
for (MyTeacherVO myTeacherVO : myCassl ){
// cRelationshipStudentSgcMapper.
List<CTeacher> cTeachers = cTeacherMapper.selectList(Wrappers.lambdaQuery(new CTeacher()).eq(CTeacher::getGradeId, myTeacherVO.getGradeId()));
myTeacherVO.setCTeachers(cTeachers);
}
return null;
return AjaxResult.success(myCassl);
}
/**
... ...
... ... @@ -60,7 +60,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getMyCassl" resultType="com.example.client.domain.vo.MyTeacherVO" parameterType="long">
SELECT r.gerde_id, s.school_name FROM c_relationship_student_sgc r
LEFT JOIN c_register_school s on s.school_id =r.school_id
WHERE r.user_id = #{userId}
</select>
... ...