AccessTokenServiceImpl.java
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.meishu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.meishu.common.exception.HttpException;
import com.meishu.dto.token.GetAllStudentsDTO;
import com.meishu.dto.token.GetAllTeachersDTO;
import com.meishu.mapper.AdministerMapper;
import com.meishu.mapper.UuidHistoryMapper;
import com.meishu.model.AccessTokenDO;
import com.meishu.mapper.AccessTokenMapper;
import com.meishu.model.AdministerDO;
import com.meishu.model.UserRoleDO;
import com.meishu.model.UuidHistoryDO;
import com.meishu.service.AccessTokenService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meishu.util.SecretUtils;
import com.meishu.vo.accesstoken.GetAllStudentsVO;
import com.meishu.vo.accesstoken.GetAllTeachersVO;
import com.meishu.vo.administer.GetTeacherSubjectVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author Tuyp
* @since 2021-05-10
*/
@Service
public class AccessTokenServiceImpl extends ServiceImpl<AccessTokenMapper, AccessTokenDO> implements AccessTokenService {
@Autowired
private AdministerMapper administerMapper;
@Autowired
private UuidHistoryMapper uuidHistoryMapper;
public List<GetAllTeachersVO> getAllTeachers(GetAllTeachersDTO getAllTeachersDTO){
int count = uuidHistoryMapper.selectCount(new QueryWrapper<UuidHistoryDO>()
.lambda()
.eq(UuidHistoryDO::getUuid,getAllTeachersDTO.getUuid()));
if (count>0){
throw new HttpException(80001);
}
String uuidSec = SecretUtils.hash(getAllTeachersDTO.getUuid()+"ixihs");
if (!uuidSec.equals(getAllTeachersDTO.getUuidSecret())){
throw new HttpException(80002);
}
//查找所有老师
List<GetAllTeachersVO> administerDOS = this.baseMapper.getAllTeachers(getAllTeachersDTO);
administerDOS.stream().forEach(x->{
List<GetTeacherSubjectVO> getTeacherSubjectVOS = administerMapper.getTeacherSubject(x.getId());
x.setSubjectDictDOS(getTeacherSubjectVOS);
});
UuidHistoryDO uuidHistoryDO = new UuidHistoryDO();
uuidHistoryDO.setUuid(getAllTeachersDTO.getUuid());
uuidHistoryMapper.insert(uuidHistoryDO);
return administerDOS;
}
public List<GetAllStudentsVO> getAllStudents(GetAllStudentsDTO getAllStudentsDTO){
int count = uuidHistoryMapper.selectCount(new QueryWrapper<UuidHistoryDO>()
.lambda()
.eq(UuidHistoryDO::getUuid,getAllStudentsDTO.getUuid()));
if (count>0){
throw new HttpException(80001);
}
String uuidSec = SecretUtils.hash(getAllStudentsDTO.getUuid()+"ixihs");
if (!uuidSec.equals(getAllStudentsDTO.getUuidSecret())){
throw new HttpException(80002);
}
UuidHistoryDO uuidHistoryDO = new UuidHistoryDO();
uuidHistoryDO.setUuid(getAllStudentsDTO.getUuid());
uuidHistoryMapper.insert(uuidHistoryDO);
return this.baseMapper.getAllStudents(getAllStudentsDTO);
}
}