Commit a91e9ad7 by 涂亚平

redis

vod_play_history新加字段
1 parent 93b423e7
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
<itext-asian.version>5.2.0</itext-asian.version> <itext-asian.version>5.2.0</itext-asian.version>
<itextpdf.version>5.4.1</itextpdf.version> <itextpdf.version>5.4.1</itextpdf.version>
<java-jwt.version>3.10.3</java-jwt.version> <java-jwt.version>3.10.3</java-jwt.version>
<jedis.version>3.3.0</jedis.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -190,6 +191,18 @@ ...@@ -190,6 +191,18 @@
<artifactId>jlatexmath</artifactId> <artifactId>jlatexmath</artifactId>
<version>1.0.7</version> <version>1.0.7</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.subsidy.common.configure;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@EnableCaching
/**
* <p>
* Redis
* </p>
*
* @author DengMin
* @since 2020/12/14
*/
@Configuration
public class RedisConfig extends CachingConfigurerSupport {
/**
* retemplate相关配置
* @param factory
* @return
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
// 配置连接工厂
template.setConnectionFactory(factory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
// 值采用json序列化
template.setValueSerializer(jacksonSeial);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
// 设置hash key 和value序列化模式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jacksonSeial);
template.afterPropertiesSet();
return template;
}
/**
* 对hash类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForHash();
}
/**
* 对redis字符串类型数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForValue();
}
/**
* 对链表类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForList();
}
/**
* 对无序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForSet();
}
/**
* 对有序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForZSet();
}
}
\ No newline at end of file
...@@ -103,14 +103,14 @@ public class AdministerController { ...@@ -103,14 +103,14 @@ public class AdministerController {
@PostMapping("classDetail") @PostMapping("classDetail")
@ApiOperation("** 班级管理--班级成员 id 班级id userName") @ApiOperation("** 班级管理--班级成员 id 班级id userName")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO classDetail(@RequestBody ClassDetailDTO classDetailDTO){ public ResponseVO classDetail(@RequestBody ClassDetailDTO classDetailDTO){
return ResponseData.generateCreatedResponse(0,administerService.classDetail(classDetailDTO)); return ResponseData.generateCreatedResponse(0,administerService.classDetail(classDetailDTO));
} }
@PostMapping("exportClassDetail") @PostMapping("exportClassDetail")
@ApiOperation("** 班级管理--班级成员--导出 id 班级id userName") @ApiOperation("** 班级管理--班级成员--导出 id 班级id userName")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public void exportClassDetail(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{ public void exportClassDetail(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
classDetailDTO.setFlag(true); classDetailDTO.setFlag(true);
administerService.exportClassDetail(classDetailDTO); administerService.exportClassDetail(classDetailDTO);
...@@ -200,6 +200,11 @@ public class AdministerController { ...@@ -200,6 +200,11 @@ public class AdministerController {
return ResponseData.generateCreatedResponse(0,administerService.importMember(companyId,file)); return ResponseData.generateCreatedResponse(0,administerService.importMember(companyId,file));
} }
@PostMapping("importRedis")
@ApiOperation("导入老师账号到redis")
public void importRedis(){
administerService.importRedis();
}
} }
...@@ -137,9 +137,11 @@ public class MemberController { ...@@ -137,9 +137,11 @@ public class MemberController {
return ResponseData.generateCreatedResponse(0,memberService.checkTimes(exerciseDoneResultDO)); return ResponseData.generateCreatedResponse(0,memberService.checkTimes(exerciseDoneResultDO));
} }
@PostMapping("replace") @PostMapping("importRedis")
public void replace(){ @ApiOperation("导入学生账号到redis")
memberService.replace(); public void importRedis(){
memberService.importRedis();
} }
} }
...@@ -61,4 +61,9 @@ public class SignInRecordController { ...@@ -61,4 +61,9 @@ public class SignInRecordController {
return ResponseData.generateCreatedResponse(0,signInRecordService.signInStatus(signInRecordDO)); return ResponseData.generateCreatedResponse(0,signInRecordService.signInStatus(signInRecordDO));
} }
@PostMapping("getRedisData")
public ResponseVO test(){
return ResponseData.generateCreatedResponse(0,signInRecordService.test());
}
} }
...@@ -50,5 +50,10 @@ public class VodPlayHistoryDO extends BaseModel { ...@@ -50,5 +50,10 @@ public class VodPlayHistoryDO extends BaseModel {
*/ */
private Integer playRecord; private Integer playRecord;
/**
* 聚合
*/
private Integer playCount;
} }
...@@ -68,4 +68,5 @@ public interface AdministerService extends IService<AdministerDO> { ...@@ -68,4 +68,5 @@ public interface AdministerService extends IService<AdministerDO> {
String importMember(Long companyId, MultipartFile multipartFile); String importMember(Long companyId, MultipartFile multipartFile);
void importRedis();
} }
...@@ -11,6 +11,7 @@ import com.subsidy.vo.administer.UserRoleVO; ...@@ -11,6 +11,7 @@ import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.member.*; import com.subsidy.vo.member.*;
import com.subsidy.vo.paper.QueryPapersVO; import com.subsidy.vo.paper.QueryPapersVO;
import java.lang.reflect.Member;
import java.util.List; import java.util.List;
/** /**
...@@ -33,7 +34,7 @@ public interface MemberService extends IService<MemberDO> { ...@@ -33,7 +34,7 @@ public interface MemberService extends IService<MemberDO> {
UserRoleVO login(VerifyCodeDTO verifyCodeDTO); UserRoleVO login(VerifyCodeDTO verifyCodeDTO);
UserRoleVO passwordLogin(PasswordLoginDTO passwordLoginDTO); MemberDO passwordLogin(PasswordLoginDTO passwordLoginDTO);
String updatePassword(MemberDO memberDO); String updatePassword(MemberDO memberDO);
...@@ -55,5 +56,6 @@ public interface MemberService extends IService<MemberDO> { ...@@ -55,5 +56,6 @@ public interface MemberService extends IService<MemberDO> {
String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO); String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO);
void replace(); void importRedis();
} }
...@@ -28,4 +28,6 @@ public interface SignInRecordService extends IService<SignInRecordDO> { ...@@ -28,4 +28,6 @@ public interface SignInRecordService extends IService<SignInRecordDO> {
IPage classSignInfo(ClassSignInfoDTO classSignInfoDTO); IPage classSignInfo(ClassSignInfoDTO classSignInfoDTO);
SignInStatusVO signInStatus(SignInRecordDO signInRecordDO); SignInStatusVO signInStatus(SignInRecordDO signInRecordDO);
Object test();
} }
...@@ -39,6 +39,7 @@ import org.apache.poi.xssf.streaming.SXSSFSheet; ...@@ -39,6 +39,7 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
...@@ -110,16 +111,29 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -110,16 +111,29 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
@Autowired @Autowired
private OprAdmDictMapper oprAdmDictMapper; private OprAdmDictMapper oprAdmDictMapper;
@Autowired
private RedisUtil redisUtil;
public LoginVO login(AdministerDO administerDO) { public LoginVO login(AdministerDO administerDO) {
LoginVO loginVO = new LoginVO(); LoginVO loginVO = new LoginVO();
AdministerDO administerDO1 = this.baseMapper.selectOne(new QueryWrapper<AdministerDO>() /**
* 先从redis里拿
*/
AdministerDO administerDO1 = (AdministerDO)redisUtil.get("subsidyAdminister_"+administerDO.getAccountName());
if (null==administerDO1){
/**
* 查表,并将数据写入到redis
*/
administerDO1 = this.baseMapper.selectOne(new QueryWrapper<AdministerDO>()
.lambda() .lambda()
.eq(AdministerDO::getAccountName, administerDO.getAccountName())); .eq(AdministerDO::getAccountName, administerDO.getAccountName()));
redisUtil.set("subsidyAdminister_"+administerDO.getAccountName(),administerDO1);
}
/** /**
* 最近5次都输入失败,5分钟后再验证 * 最近5次都输入失败,5分钟后再验证 待优化
*/ */
List<OprAdmDictDO> oprAdmDictDOS = oprAdmDictMapper.getLoginInfo(administerDO1.getId()); List<OprAdmDictDO> oprAdmDictDOS = oprAdmDictMapper.getLoginInfo(administerDO1.getId());
...@@ -268,6 +282,9 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -268,6 +282,9 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
throw new HttpException(20002); throw new HttpException(20002);
} }
this.baseMapper.updateById(administerDO); this.baseMapper.updateById(administerDO);
AdministerDO administerDO1 = this.baseMapper.selectById(administerDO.getId());
//更新redis里该老师的数据
redisUtil.set("subsidyAdminister_"+administerDO1.getAccountName(),administerDO1);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
} }
...@@ -981,6 +998,13 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -981,6 +998,13 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
public void importRedis(){
List<AdministerDO> administerDOS = this.baseMapper.selectList(null);
for (AdministerDO administerDO: administerDOS){
redisUtil.set("subsidyAdmin_"+administerDO.getAccountName(),administerDO);
}
}
public String userName(String originName, int i, Long companyId) { public String userName(String originName, int i, Long companyId) {
i++; i++;
List<MemberDO> memberDOS = memberMapper.selectList(new QueryWrapper<MemberDO>() List<MemberDO> memberDOS = memberMapper.selectList(new QueryWrapper<MemberDO>()
......
...@@ -74,7 +74,7 @@ public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, C ...@@ -74,7 +74,7 @@ public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, C
ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper<ClassHourDictDO>() ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper<ClassHourDictDO>()
.lambda() .lambda()
.eq(ClassHourDictDO::getStatus,1) .eq(ClassHourDictDO::getStatus,1)
.eq(ClassHourDictDO::getCompanyId,memberDO.getCompanyId())); .gt(ClassHourDictDO::getCompanyId,memberDO.getCompanyId()));
if (null == classHourDictDO){ if (null == classHourDictDO){
pollingGetVO.setBool(false); pollingGetVO.setBool(false);
return pollingGetVO; return pollingGetVO;
......
...@@ -13,6 +13,7 @@ import com.subsidy.service.MemberService; ...@@ -13,6 +13,7 @@ import com.subsidy.service.MemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.MathUtil; import com.subsidy.util.MathUtil;
import com.subsidy.util.RedisUtil;
import com.subsidy.vo.administer.UserRoleVO; import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.course.QueryCoursesVO; import com.subsidy.vo.course.QueryCoursesVO;
import com.subsidy.vo.member.*; import com.subsidy.vo.member.*;
...@@ -83,6 +84,9 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -83,6 +84,9 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
@Autowired @Autowired
private OprMemDictMapper oprMemDictMapper; private OprMemDictMapper oprMemDictMapper;
@Autowired
private RedisUtil redisUtil;
public IPage<GetAllVO> getAll(GetAllDTO getAllDTO) { public IPage<GetAllVO> getAll(GetAllDTO getAllDTO) {
Page pager = new Page(getAllDTO.getPageNum(), getAllDTO.getPageSize()); Page pager = new Page(getAllDTO.getPageNum(), getAllDTO.getPageSize());
IPage iPage = this.baseMapper.getMembers(pager, getAllDTO.getDepartmentId(), getAllDTO.getUserName(), getAllDTO.getStatus()); IPage iPage = this.baseMapper.getMembers(pager, getAllDTO.getDepartmentId(), getAllDTO.getUserName(), getAllDTO.getStatus());
...@@ -223,12 +227,14 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -223,12 +227,14 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
} }
BeanUtils.copyProperties(memberDO, userRoleVO); BeanUtils.copyProperties(memberDO, userRoleVO);
SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>() String code = redisUtil.get("subsidySmsCode_"+verifyCodeDTO.getTelephone()).toString();
.lambda()
.eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone()) //SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>()
.eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode()) // .lambda()
.gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L))); // .eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone())
if (smsCodeDO == null) { // .eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode())
// .gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L)));
if (code == null || !verifyCodeDTO.getVerifyCode().equals(code) ) {
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId()); oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录"); oprMemDictDO.setOprType("登录");
...@@ -242,46 +248,63 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -242,46 +248,63 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
oprMemDictDO.setResult(1); oprMemDictDO.setResult(1);
oprMemDictMapper.insert(oprMemDictDO); oprMemDictMapper.insert(oprMemDictDO);
//将学员信息写到redis
redisUtil.set("subsidyMember_"+memberDO.getCompanyId()+":"+memberDO.getAccountName(),memberDO);
return userRoleVO; return userRoleVO;
} }
public UserRoleVO passwordLogin(PasswordLoginDTO passwordLoginDTO) { public MemberDO passwordLogin(PasswordLoginDTO passwordLoginDTO) {
UserRoleVO userRoleVO = this.baseMapper.passwordLogin(passwordLoginDTO); //UserRoleVO userRoleVO = this.baseMapper.passwordLogin(passwordLoginDTO);
if (userRoleVO == null) { /**
* 先从redis里查
*/
MemberDO memberDO = (MemberDO) redisUtil.get("subsidyMember_"+passwordLoginDTO.getCompanyId()+":"+passwordLoginDTO.getAccountName());
if (null==memberDO){
/**
* redis里没有,从数据库里查
*/
memberDO = this.baseMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getCompanyId,passwordLoginDTO.getCompanyId())
.eq(MemberDO::getAccountName,passwordLoginDTO.getAccountName()));
}
if (memberDO == null) {
throw new HttpException(10017); throw new HttpException(10017);
} }
if (!userRoleVO.getPassword().equals(passwordLoginDTO.getPassword())){ if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) {
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(userRoleVO.getId()); oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录"); oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0); oprMemDictDO.setResult(0);
oprMemDictMapper.insert(oprMemDictDO); oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(10016); throw new HttpException(10016);
} }
if (0==userRoleVO.getFirstLogin()){ if (0 == memberDO.getFirstLogin()) {
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(userRoleVO.getId()); oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录"); oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0); oprMemDictDO.setResult(0);
oprMemDictMapper.insert(oprMemDictDO); oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(10015); throw new HttpException(10015);
} }
if ("冻结".equals(userRoleVO.getStatus())) { if ("冻结".equals(memberDO.getStatus())) {
throw new HttpException(10014); throw new HttpException(10014);
} }
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(userRoleVO.getId()); oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录"); oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(1); oprMemDictDO.setResult(1);
oprMemDictMapper.insert(oprMemDictDO); oprMemDictMapper.insert(oprMemDictDO);
return userRoleVO; return memberDO;
} }
public String updatePassword(MemberDO memberDO) { public String updatePassword(MemberDO memberDO) {
this.baseMapper.updateById(memberDO); this.baseMapper.updateById(memberDO);
MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId());
redisUtil.set("subsidyMember_"+memberDO1.getCompanyId()+":"+memberDO.getAccountName(),memberDO);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
} }
...@@ -600,27 +623,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -600,27 +623,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
return ConstantUtils.CHECK_STATUS; return ConstantUtils.CHECK_STATUS;
} }
public void replace(){ public void importRedis() {
List<MemberDO> memberDOS = this.baseMapper.selectList(null); List<MemberDO> memberDOS = this.baseMapper.selectList(null);
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
//拼音小写
format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
//不带声调
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
try {
for (MemberDO memberDO : memberDOS) { for (MemberDO memberDO : memberDOS) {
redisUtil.set("subsidyMember_"+memberDO.getCompanyId()+":"+memberDO.getAccountName(),memberDO);
String accountName = PinyinHelper.toHanYuPinyinString(memberDO.getUserName(), format, "", true);
memberDO.setAccountName(accountName);
this.baseMapper.updateById(memberDO);
}
}catch (Exception e){
} }
} }
} }
...@@ -12,6 +12,7 @@ import com.subsidy.service.SignInRecordService; ...@@ -12,6 +12,7 @@ import com.subsidy.service.SignInRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.MathUtil; import com.subsidy.util.MathUtil;
import com.subsidy.util.RedisUtil;
import com.subsidy.vo.member.GetMemberSignInfoVO; import com.subsidy.vo.member.GetMemberSignInfoVO;
import com.subsidy.vo.sign.ClassSignInfoVO; import com.subsidy.vo.sign.ClassSignInfoVO;
import com.subsidy.vo.sign.SignInStatusVO; import com.subsidy.vo.sign.SignInStatusVO;
...@@ -21,6 +22,7 @@ import org.springframework.stereotype.Service; ...@@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* <p> * <p>
...@@ -48,6 +50,9 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -48,6 +50,9 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
@Autowired @Autowired
private AnsweringQuestionMapper answeringQuestionMapper; private AnsweringQuestionMapper answeringQuestionMapper;
@Autowired
private RedisUtil redisUtil;
public IPage<GetMemberSignInfoVO> getMemberSignInfo(GetMemberSignInfoDTO getMemberSignInfoDTO) { public IPage<GetMemberSignInfoVO> getMemberSignInfo(GetMemberSignInfoDTO getMemberSignInfoDTO) {
Page pager = new Page(getMemberSignInfoDTO.getPageNum(), getMemberSignInfoDTO.getPageSize()); Page pager = new Page(getMemberSignInfoDTO.getPageNum(), getMemberSignInfoDTO.getPageSize());
...@@ -74,6 +79,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -74,6 +79,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
signInRecordDO1.setClassId(classDictDO.getId()); signInRecordDO1.setClassId(classDictDO.getId());
signInRecordDO1.setMemberId(signInRecordDO.getMemberId()); signInRecordDO1.setMemberId(signInRecordDO.getMemberId());
signInRecordDO1.setSignInDate(LocalDateTime.now()); signInRecordDO1.setSignInDate(LocalDateTime.now());
//redisUtil.set("signInStatus"+signInRecordDO.getMemberId()+classDictDO.getId(),LocalDateTime.now());
this.baseMapper.insert(signInRecordDO1); this.baseMapper.insert(signInRecordDO1);
} }
...@@ -122,7 +129,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -122,7 +129,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
} }
} }
} }
classSignInfoVO.setStudyVodCounts(MathUtil.intDivCeil(totalStudyVods, classMemberMappingDOS.size() )); classSignInfoVO.setStudyVodCounts(MathUtil.intDivCeil(totalStudyVods, classMemberMappingDOS.size()));
//平均完成时长 学生观看课程视频的全部时长/总人数 //平均完成时长 学生观看课程视频的全部时长/总人数
int avg = MathUtil.intDivCeil(totalStudyLength, classMemberMappingDOS.size()); int avg = MathUtil.intDivCeil(totalStudyLength, classMemberMappingDOS.size());
...@@ -178,6 +185,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -178,6 +185,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
.eq(SignInRecordDO::getMemberId, signInRecordDO.getMemberId()) .eq(SignInRecordDO::getMemberId, signInRecordDO.getMemberId())
.gt(SignInRecordDO::getSignInDate, LocalDate.now())); .gt(SignInRecordDO::getSignInDate, LocalDate.now()));
//String count = redisUtil.get("signInStatus:"+signInRecordDO.getMemberId()+":"+classDictDO.getId()).toString();
if (count == 0) { if (count == 0) {
flag = false; //没有签到 flag = false; //没有签到
} }
...@@ -188,8 +197,14 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -188,8 +197,14 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
} }
//public static void main(String[] args) { public Object test() {
// System.out.println(LocalDate.now().plusDays(1));
//} Set set = redisUtil.keys("*subsidyMember*");
for (Object str : set) {
System.out.println(str);
}
return null;
}
} }
...@@ -11,6 +11,7 @@ import com.subsidy.service.MemberService; ...@@ -11,6 +11,7 @@ import com.subsidy.service.MemberService;
import com.subsidy.service.SmsVerifyCodeService; import com.subsidy.service.SmsVerifyCodeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.RandomUtil; import com.subsidy.util.RandomUtil;
import com.subsidy.util.RedisUtil;
import com.subsidy.util.SMSUtils; import com.subsidy.util.SMSUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -34,6 +35,9 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S ...@@ -34,6 +35,9 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S
@Autowired @Autowired
private MemberMapper memberMapper; private MemberMapper memberMapper;
@Autowired
private RedisUtil redisUtil;
public void sendVerifyCode(SendVerifyCodeDTO sendVerifyCodeDTO){ public void sendVerifyCode(SendVerifyCodeDTO sendVerifyCodeDTO){
MemberDO memberDO =memberMapper.selectOne(new QueryWrapper<MemberDO>() MemberDO memberDO =memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda() .lambda()
...@@ -45,10 +49,15 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S ...@@ -45,10 +49,15 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S
String code = RandomUtil.getRandomCode(6); String code = RandomUtil.getRandomCode(6);
smsUtils.send(sendVerifyCodeDTO.getTelephone(), code); smsUtils.send(sendVerifyCodeDTO.getTelephone(), code);
SmsVerifyCodeDO smsCodeDO = new SmsVerifyCodeDO(); //SmsVerifyCodeDO smsCodeDO = new SmsVerifyCodeDO();
smsCodeDO.setVerifyCode(code); //smsCodeDO.setVerifyCode(code);
smsCodeDO.setTelephone(sendVerifyCodeDTO.getTelephone()); //smsCodeDO.setTelephone(sendVerifyCodeDTO.getTelephone());
this.baseMapper.insert(smsCodeDO); //this.baseMapper.insert(smsCodeDO);
/**
* 验证码存在redis
*/
redisUtil.set("subsidySmsCode_"+sendVerifyCodeDTO.getTelephone(),code,30*60);
} }
......
...@@ -25,3 +25,10 @@ spring.datasource.druid.useGlobalDataSourceStat=true ...@@ -25,3 +25,10 @@ spring.datasource.druid.useGlobalDataSourceStat=true
# 控制台日志打印 # 控制台日志打印
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
spring.redis.host=47.97.19.66
spring.redis.password=Ykhl@208
spring.redis.port=6389
spring.redis.lettuce.pool.max-idle=16
spring.redis.lettuce.pool.max-active=32
spring.redis.lettuce.pool.min-idle=8
\ No newline at end of file
...@@ -31,3 +31,9 @@ spring.servlet.multipart.max-request-size=4098KB ...@@ -31,3 +31,9 @@ spring.servlet.multipart.max-request-size=4098KB
#wechat.appSecret= 25d57cad61fc1b45b3afa46d4c35e8f6 #wechat.appSecret= 25d57cad61fc1b45b3afa46d4c35e8f6
#wechat.msgUrl= https://teachai.youkehulian.com/login #wechat.msgUrl= https://teachai.youkehulian.com/login
#wechat.templateId= Z1HNPLOrKiHEjfR1KMP-cC-uH3BWqDJIHv365Ev20yQ #wechat.templateId= Z1HNPLOrKiHEjfR1KMP-cC-uH3BWqDJIHv365Ev20yQ
spring.redis.cluster.nodes=47.97.19.66:6377,47.97.19.66:6378,47.97.16.66:6379
spring.redis.password=Ykhl@208
spring.redis.lettuce.pool.max-idle=16
spring.redis.lettuce.pool.max-active=32
spring.redis.lettuce.pool.min-idle=8
\ No newline at end of file
...@@ -63,3 +63,19 @@ spring.quartz.overwrite-existing-jobs=false ...@@ -63,3 +63,19 @@ spring.quartz.overwrite-existing-jobs=false
# 自动建表,如果已经存在表请勿使用,会覆盖数据表 # 自动建表,如果已经存在表请勿使用,会覆盖数据表
#spring.quartz.jdbc.initialize-schema=always #spring.quartz.jdbc.initialize-schema=always
#spring.datasource.initialization-mode=embedded #spring.datasource.initialization-mode=embedded
#spring.redis.cluster.nodes=47.97.19.66:6377,47.97.19.66:6378,47.97.19.66:6379
##spring.redis.port=6379
#spring.redis.password=Ykhl@208
## spring.redis.cluster.max-redirects=3
#spring.redis.lettuce.pool.max-idle=16
#spring.redis.lettuce.pool.max-active=32
#spring.redis.lettuce.pool.min-idle=8
#spring.redis.host=47.97.19.66
#spring.redis.password=Ykhl@208
#spring.redis.port=6389
#spring.redis.lettuce.pool.max-idle=16
#spring.redis.lettuce.pool.max-active=32
#spring.redis.lettuce.pool.min-idle=8
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!