Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
涂亚平
/
subsidy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a91e9ad7
authored
Dec 21, 2021
by
涂亚平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis
vod_play_history新加字段
1 parent
93b423e7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
294 additions
and
52 deletions
pom.xml
src/main/java/com/subsidy/common/configure/RedisConfig.java
src/main/java/com/subsidy/controller/AdministerController.java
src/main/java/com/subsidy/controller/MemberController.java
src/main/java/com/subsidy/controller/SignInRecordController.java
src/main/java/com/subsidy/model/VodPlayHistoryDO.java
src/main/java/com/subsidy/service/AdministerService.java
src/main/java/com/subsidy/service/MemberService.java
src/main/java/com/subsidy/service/SignInRecordService.java
src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java
src/main/java/com/subsidy/service/impl/ClassHourDictServiceImpl.java
src/main/java/com/subsidy/service/impl/MemberServiceImpl.java
src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java
src/main/java/com/subsidy/service/impl/SmsVerifyCodeServiceImpl.java
src/main/java/com/subsidy/util/RedisUtil.java
src/main/resources/application-dev.properties
src/main/resources/application-prod.properties
src/main/resources/application.properties
pom.xml
View file @
a91e9ad
...
...
@@ -31,6 +31,7 @@
<itext-asian.version>
5.2.0
</itext-asian.version>
<itextpdf.version>
5.4.1
</itextpdf.version>
<java-jwt.version>
3.10.3
</java-jwt.version>
<jedis.version>
3.3.0
</jedis.version>
</properties>
<dependencies>
...
...
@@ -190,6 +191,18 @@
<artifactId>
jlatexmath
</artifactId>
<version>
1.0.7
</version>
</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>
<build>
...
...
src/main/java/com/subsidy/common/configure/RedisConfig.java
0 → 100644
View file @
a91e9ad
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
src/main/java/com/subsidy/controller/AdministerController.java
View file @
a91e9ad
...
...
@@ -103,14 +103,14 @@ public class AdministerController {
@PostMapping
(
"classDetail"
)
@ApiOperation
(
"** 班级管理--班级成员 id 班级id userName"
)
//
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@LoginRequired
(
value
=
{
ConstantUtils
.
ADMINISTER_TERMINATE
})
public
ResponseVO
classDetail
(
@RequestBody
ClassDetailDTO
classDetailDTO
){
return
ResponseData
.
generateCreatedResponse
(
0
,
administerService
.
classDetail
(
classDetailDTO
));
}
@PostMapping
(
"exportClassDetail"
)
@ApiOperation
(
"** 班级管理--班级成员--导出 id 班级id userName"
)
//
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@LoginRequired
(
value
=
{
ConstantUtils
.
ADMINISTER_TERMINATE
})
public
void
exportClassDetail
(
@RequestBody
ClassDetailDTO
classDetailDTO
)
throws
Exception
{
classDetailDTO
.
setFlag
(
true
);
administerService
.
exportClassDetail
(
classDetailDTO
);
...
...
@@ -200,6 +200,11 @@ public class AdministerController {
return
ResponseData
.
generateCreatedResponse
(
0
,
administerService
.
importMember
(
companyId
,
file
));
}
@PostMapping
(
"importRedis"
)
@ApiOperation
(
"导入老师账号到redis"
)
public
void
importRedis
(){
administerService
.
importRedis
();
}
}
src/main/java/com/subsidy/controller/MemberController.java
View file @
a91e9ad
...
...
@@ -137,9 +137,11 @@ public class MemberController {
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
checkTimes
(
exerciseDoneResultDO
));
}
@PostMapping
(
"replace"
)
public
void
replace
(){
memberService
.
replace
();
@PostMapping
(
"importRedis"
)
@ApiOperation
(
"导入学生账号到redis"
)
public
void
importRedis
(){
memberService
.
importRedis
();
}
}
src/main/java/com/subsidy/controller/SignInRecordController.java
View file @
a91e9ad
...
...
@@ -61,4 +61,9 @@ public class SignInRecordController {
return
ResponseData
.
generateCreatedResponse
(
0
,
signInRecordService
.
signInStatus
(
signInRecordDO
));
}
@PostMapping
(
"getRedisData"
)
public
ResponseVO
test
(){
return
ResponseData
.
generateCreatedResponse
(
0
,
signInRecordService
.
test
());
}
}
src/main/java/com/subsidy/model/VodPlayHistoryDO.java
View file @
a91e9ad
...
...
@@ -50,5 +50,10 @@ public class VodPlayHistoryDO extends BaseModel {
*/
private
Integer
playRecord
;
/**
* 聚合
*/
private
Integer
playCount
;
}
src/main/java/com/subsidy/service/AdministerService.java
View file @
a91e9ad
...
...
@@ -68,4 +68,5 @@ public interface AdministerService extends IService<AdministerDO> {
String
importMember
(
Long
companyId
,
MultipartFile
multipartFile
);
void
importRedis
();
}
src/main/java/com/subsidy/service/MemberService.java
View file @
a91e9ad
...
...
@@ -11,6 +11,7 @@ import com.subsidy.vo.administer.UserRoleVO;
import
com.subsidy.vo.member.*
;
import
com.subsidy.vo.paper.QueryPapersVO
;
import
java.lang.reflect.Member
;
import
java.util.List
;
/**
...
...
@@ -33,7 +34,7 @@ public interface MemberService extends IService<MemberDO> {
UserRoleVO
login
(
VerifyCodeDTO
verifyCodeDTO
);
UserRoleV
O
passwordLogin
(
PasswordLoginDTO
passwordLoginDTO
);
MemberD
O
passwordLogin
(
PasswordLoginDTO
passwordLoginDTO
);
String
updatePassword
(
MemberDO
memberDO
);
...
...
@@ -55,5 +56,6 @@ public interface MemberService extends IService<MemberDO> {
String
checkTimes
(
ExerciseDoneResultDO
exerciseDoneResultDO
);
void
replace
();
void
importRedis
();
}
src/main/java/com/subsidy/service/SignInRecordService.java
View file @
a91e9ad
...
...
@@ -28,4 +28,6 @@ public interface SignInRecordService extends IService<SignInRecordDO> {
IPage
classSignInfo
(
ClassSignInfoDTO
classSignInfoDTO
);
SignInStatusVO
signInStatus
(
SignInRecordDO
signInRecordDO
);
Object
test
();
}
src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java
View file @
a91e9ad
...
...
@@ -39,6 +39,7 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
import
org.apache.poi.xssf.streaming.SXSSFWorkbook
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
...
...
@@ -110,16 +111,29 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
@Autowired
private
OprAdmDictMapper
oprAdmDictMapper
;
@Autowired
private
RedisUtil
redisUtil
;
public
LoginVO
login
(
AdministerDO
administerDO
)
{
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
()
.
eq
(
AdministerDO:
:
getAccountName
,
administerDO
.
getAccountName
()));
redisUtil
.
set
(
"subsidyAdminister_"
+
administerDO
.
getAccountName
(),
administerDO1
);
}
/**
* 最近5次都输入失败,5分钟后再验证
* 最近5次都输入失败,5分钟后再验证
待优化
*/
List
<
OprAdmDictDO
>
oprAdmDictDOS
=
oprAdmDictMapper
.
getLoginInfo
(
administerDO1
.
getId
());
...
...
@@ -268,6 +282,9 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
throw
new
HttpException
(
20002
);
}
this
.
baseMapper
.
updateById
(
administerDO
);
AdministerDO
administerDO1
=
this
.
baseMapper
.
selectById
(
administerDO
.
getId
());
//更新redis里该老师的数据
redisUtil
.
set
(
"subsidyAdminister_"
+
administerDO1
.
getAccountName
(),
administerDO1
);
return
ConstantUtils
.
SET_SUCCESS
;
}
...
...
@@ -981,6 +998,13 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
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
)
{
i
++;
List
<
MemberDO
>
memberDOS
=
memberMapper
.
selectList
(
new
QueryWrapper
<
MemberDO
>()
...
...
src/main/java/com/subsidy/service/impl/ClassHourDictServiceImpl.java
View file @
a91e9ad
...
...
@@ -74,7 +74,7 @@ public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, C
ClassHourDictDO
classHourDictDO
=
classHourDictMapper
.
selectOne
(
new
QueryWrapper
<
ClassHourDictDO
>()
.
lambda
()
.
eq
(
ClassHourDictDO:
:
getStatus
,
1
)
.
eq
(
ClassHourDictDO:
:
getCompanyId
,
memberDO
.
getCompanyId
()));
.
gt
(
ClassHourDictDO:
:
getCompanyId
,
memberDO
.
getCompanyId
()));
if
(
null
==
classHourDictDO
){
pollingGetVO
.
setBool
(
false
);
return
pollingGetVO
;
...
...
src/main/java/com/subsidy/service/impl/MemberServiceImpl.java
View file @
a91e9ad
...
...
@@ -13,6 +13,7 @@ import com.subsidy.service.MemberService;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.subsidy.util.ConstantUtils
;
import
com.subsidy.util.MathUtil
;
import
com.subsidy.util.RedisUtil
;
import
com.subsidy.vo.administer.UserRoleVO
;
import
com.subsidy.vo.course.QueryCoursesVO
;
import
com.subsidy.vo.member.*
;
...
...
@@ -83,6 +84,9 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
@Autowired
private
OprMemDictMapper
oprMemDictMapper
;
@Autowired
private
RedisUtil
redisUtil
;
public
IPage
<
GetAllVO
>
getAll
(
GetAllDTO
getAllDTO
)
{
Page
pager
=
new
Page
(
getAllDTO
.
getPageNum
(),
getAllDTO
.
getPageSize
());
IPage
iPage
=
this
.
baseMapper
.
getMembers
(
pager
,
getAllDTO
.
getDepartmentId
(),
getAllDTO
.
getUserName
(),
getAllDTO
.
getStatus
());
...
...
@@ -223,12 +227,14 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
}
BeanUtils
.
copyProperties
(
memberDO
,
userRoleVO
);
SmsVerifyCodeDO
smsCodeDO
=
smsVerifyCodeMapper
.
selectOne
(
new
QueryWrapper
<
SmsVerifyCodeDO
>()
.
lambda
()
.
eq
(
SmsVerifyCodeDO:
:
getTelephone
,
verifyCodeDTO
.
getTelephone
())
.
eq
(
SmsVerifyCodeDO:
:
getVerifyCode
,
verifyCodeDTO
.
getVerifyCode
())
.
gt
(
SmsVerifyCodeDO:
:
getCreateDate
,
LocalDateTime
.
now
().
minusMinutes
(
30L
)));
if
(
smsCodeDO
==
null
)
{
String
code
=
redisUtil
.
get
(
"subsidySmsCode_"
+
verifyCodeDTO
.
getTelephone
()).
toString
();
//SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>()
// .lambda()
// .eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone())
// .eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode())
// .gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L)));
if
(
code
==
null
||
!
verifyCodeDTO
.
getVerifyCode
().
equals
(
code
)
)
{
OprMemDictDO
oprMemDictDO
=
new
OprMemDictDO
();
oprMemDictDO
.
setUserId
(
memberDO
.
getId
());
oprMemDictDO
.
setOprType
(
"登录"
);
...
...
@@ -242,46 +248,63 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
oprMemDictDO
.
setResult
(
1
);
oprMemDictMapper
.
insert
(
oprMemDictDO
);
//将学员信息写到redis
redisUtil
.
set
(
"subsidyMember_"
+
memberDO
.
getCompanyId
()+
":"
+
memberDO
.
getAccountName
(),
memberDO
);
return
userRoleVO
;
}
public
UserRoleVO
passwordLogin
(
PasswordLoginDTO
passwordLoginDTO
)
{
UserRoleVO
userRoleVO
=
this
.
baseMapper
.
passwordLogin
(
passwordLoginDTO
);
if
(
userRoleVO
==
null
)
{
public
MemberDO
passwordLogin
(
PasswordLoginDTO
passwordLoginDTO
)
{
//UserRoleVO userRoleVO = this.baseMapper.passwordLogin(passwordLoginDTO);
/**
* 先从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
);
}
if
(!
userRoleVO
.
getPassword
().
equals
(
passwordLoginDTO
.
getPassword
()))
{
if
(!
memberDO
.
getPassword
().
equals
(
passwordLoginDTO
.
getPassword
()))
{
OprMemDictDO
oprMemDictDO
=
new
OprMemDictDO
();
oprMemDictDO
.
setUserId
(
userRoleV
O
.
getId
());
oprMemDictDO
.
setUserId
(
memberD
O
.
getId
());
oprMemDictDO
.
setOprType
(
"登录"
);
oprMemDictDO
.
setResult
(
0
);
oprMemDictMapper
.
insert
(
oprMemDictDO
);
throw
new
HttpException
(
10016
);
}
if
(
0
==
userRoleVO
.
getFirstLogin
())
{
if
(
0
==
memberDO
.
getFirstLogin
())
{
OprMemDictDO
oprMemDictDO
=
new
OprMemDictDO
();
oprMemDictDO
.
setUserId
(
userRoleV
O
.
getId
());
oprMemDictDO
.
setUserId
(
memberD
O
.
getId
());
oprMemDictDO
.
setOprType
(
"登录"
);
oprMemDictDO
.
setResult
(
0
);
oprMemDictMapper
.
insert
(
oprMemDictDO
);
throw
new
HttpException
(
10015
);
}
if
(
"冻结"
.
equals
(
userRoleV
O
.
getStatus
()))
{
if
(
"冻结"
.
equals
(
memberD
O
.
getStatus
()))
{
throw
new
HttpException
(
10014
);
}
OprMemDictDO
oprMemDictDO
=
new
OprMemDictDO
();
oprMemDictDO
.
setUserId
(
userRoleV
O
.
getId
());
oprMemDictDO
.
setUserId
(
memberD
O
.
getId
());
oprMemDictDO
.
setOprType
(
"登录"
);
oprMemDictDO
.
setResult
(
1
);
oprMemDictMapper
.
insert
(
oprMemDictDO
);
return
userRoleV
O
;
return
memberD
O
;
}
public
String
updatePassword
(
MemberDO
memberDO
)
{
this
.
baseMapper
.
updateById
(
memberDO
);
MemberDO
memberDO1
=
this
.
baseMapper
.
selectById
(
memberDO
.
getId
());
redisUtil
.
set
(
"subsidyMember_"
+
memberDO1
.
getCompanyId
()+
":"
+
memberDO
.
getAccountName
(),
memberDO
);
return
ConstantUtils
.
SET_SUCCESS
;
}
...
...
@@ -600,27 +623,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
return
ConstantUtils
.
CHECK_STATUS
;
}
public
void
replace
(){
public
void
importRedis
()
{
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
)
{
String
accountName
=
PinyinHelper
.
toHanYuPinyinString
(
memberDO
.
getUserName
(),
format
,
""
,
true
);
memberDO
.
setAccountName
(
accountName
);
this
.
baseMapper
.
updateById
(
memberDO
);
}
}
catch
(
Exception
e
){
redisUtil
.
set
(
"subsidyMember_"
+
memberDO
.
getCompanyId
()+
":"
+
memberDO
.
getAccountName
(),
memberDO
);
}
}
}
src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java
View file @
a91e9ad
...
...
@@ -12,6 +12,7 @@ import com.subsidy.service.SignInRecordService;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.subsidy.util.ConstantUtils
;
import
com.subsidy.util.MathUtil
;
import
com.subsidy.util.RedisUtil
;
import
com.subsidy.vo.member.GetMemberSignInfoVO
;
import
com.subsidy.vo.sign.ClassSignInfoVO
;
import
com.subsidy.vo.sign.SignInStatusVO
;
...
...
@@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.Set
;
/**
* <p>
...
...
@@ -48,6 +50,9 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
@Autowired
private
AnsweringQuestionMapper
answeringQuestionMapper
;
@Autowired
private
RedisUtil
redisUtil
;
public
IPage
<
GetMemberSignInfoVO
>
getMemberSignInfo
(
GetMemberSignInfoDTO
getMemberSignInfoDTO
)
{
Page
pager
=
new
Page
(
getMemberSignInfoDTO
.
getPageNum
(),
getMemberSignInfoDTO
.
getPageSize
());
...
...
@@ -74,6 +79,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
signInRecordDO1
.
setClassId
(
classDictDO
.
getId
());
signInRecordDO1
.
setMemberId
(
signInRecordDO
.
getMemberId
());
signInRecordDO1
.
setSignInDate
(
LocalDateTime
.
now
());
//redisUtil.set("signInStatus"+signInRecordDO.getMemberId()+classDictDO.getId(),LocalDateTime.now());
this
.
baseMapper
.
insert
(
signInRecordDO1
);
}
...
...
@@ -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
());
...
...
@@ -178,6 +185,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
.
eq
(
SignInRecordDO:
:
getMemberId
,
signInRecordDO
.
getMemberId
())
.
gt
(
SignInRecordDO:
:
getSignInDate
,
LocalDate
.
now
()));
//String count = redisUtil.get("signInStatus:"+signInRecordDO.getMemberId()+":"+classDictDO.getId()).toString();
if
(
count
==
0
)
{
flag
=
false
;
//没有签到
}
...
...
@@ -188,8 +197,14 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
}
//public static void main(String[] args) {
// System.out.println(LocalDate.now().plusDays(1));
//}
public
Object
test
()
{
Set
set
=
redisUtil
.
keys
(
"*subsidyMember*"
);
for
(
Object
str
:
set
)
{
System
.
out
.
println
(
str
);
}
return
null
;
}
}
src/main/java/com/subsidy/service/impl/SmsVerifyCodeServiceImpl.java
View file @
a91e9ad
...
...
@@ -11,6 +11,7 @@ import com.subsidy.service.MemberService;
import
com.subsidy.service.SmsVerifyCodeService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.subsidy.util.RandomUtil
;
import
com.subsidy.util.RedisUtil
;
import
com.subsidy.util.SMSUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -34,6 +35,9 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S
@Autowired
private
MemberMapper
memberMapper
;
@Autowired
private
RedisUtil
redisUtil
;
public
void
sendVerifyCode
(
SendVerifyCodeDTO
sendVerifyCodeDTO
){
MemberDO
memberDO
=
memberMapper
.
selectOne
(
new
QueryWrapper
<
MemberDO
>()
.
lambda
()
...
...
@@ -45,10 +49,15 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S
String
code
=
RandomUtil
.
getRandomCode
(
6
);
smsUtils
.
send
(
sendVerifyCodeDTO
.
getTelephone
(),
code
);
SmsVerifyCodeDO
smsCodeDO
=
new
SmsVerifyCodeDO
();
smsCodeDO
.
setVerifyCode
(
code
);
smsCodeDO
.
setTelephone
(
sendVerifyCodeDTO
.
getTelephone
());
this
.
baseMapper
.
insert
(
smsCodeDO
);
//SmsVerifyCodeDO smsCodeDO = new SmsVerifyCodeDO();
//smsCodeDO.setVerifyCode(code);
//smsCodeDO.setTelephone(sendVerifyCodeDTO.getTelephone());
//this.baseMapper.insert(smsCodeDO);
/**
* 验证码存在redis
*/
redisUtil
.
set
(
"subsidySmsCode_"
+
sendVerifyCodeDTO
.
getTelephone
(),
code
,
30
*
60
);
}
...
...
src/main/java/com/subsidy/util/RedisUtil.java
0 → 100644
View file @
a91e9ad
This diff is collapsed.
Click to expand it.
src/main/resources/application-dev.properties
View file @
a91e9ad
...
...
@@ -25,3 +25,10 @@ spring.datasource.druid.useGlobalDataSourceStat=true
# 控制台日志打印
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
src/main/resources/application-prod.properties
View file @
a91e9ad
...
...
@@ -31,3 +31,9 @@ spring.servlet.multipart.max-request-size=4098KB
#wechat.appSecret= 25d57cad61fc1b45b3afa46d4c35e8f6
#wechat.msgUrl= https://teachai.youkehulian.com/login
#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
src/main/resources/application.properties
View file @
a91e9ad
...
...
@@ -63,3 +63,19 @@ spring.quartz.overwrite-existing-jobs=false
# 自动建表,如果已经存在表请勿使用,会覆盖数据表
#spring.quartz.jdbc.initialize-schema=always
#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
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment