Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangquan wangquan
test
Commits
64d4f18d
Commit
64d4f18d
authored
Aug 26, 2025
by
bing zhang
Browse files
1
parent
539344b2
Changes
869
Hide whitespace changes
Inline
Side-by-side
source/java/src/main/java/com/mindskip/xzs/service/impl/TaskExamCustomerAnswerImpl.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.service.impl
;
import
com.mindskip.xzs.domain.ExamPaper
;
import
com.mindskip.xzs.domain.ExamPaperAnswer
;
import
com.mindskip.xzs.domain.TaskExamCustomerAnswer
;
import
com.mindskip.xzs.domain.TextContent
;
import
com.mindskip.xzs.domain.task.TaskItemAnswerObject
;
import
com.mindskip.xzs.repository.TaskExamCustomerAnswerMapper
;
import
com.mindskip.xzs.service.TaskExamCustomerAnswerService
;
import
com.mindskip.xzs.service.TextContentService
;
import
com.mindskip.xzs.utility.JsonUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
@Service
public
class
TaskExamCustomerAnswerImpl
extends
BaseServiceImpl
<
TaskExamCustomerAnswer
>
implements
TaskExamCustomerAnswerService
{
private
final
TaskExamCustomerAnswerMapper
taskExamCustomerAnswerMapper
;
private
final
TextContentService
textContentService
;
@Autowired
public
TaskExamCustomerAnswerImpl
(
TaskExamCustomerAnswerMapper
taskExamCustomerAnswerMapper
,
TextContentService
textContentService
)
{
super
(
taskExamCustomerAnswerMapper
);
this
.
taskExamCustomerAnswerMapper
=
taskExamCustomerAnswerMapper
;
this
.
textContentService
=
textContentService
;
}
@Override
public
void
insertOrUpdate
(
ExamPaper
examPaper
,
ExamPaperAnswer
examPaperAnswer
,
Date
now
)
{
Integer
taskId
=
examPaper
.
getTaskExamId
();
Integer
userId
=
examPaperAnswer
.
getCreateUser
();
TaskExamCustomerAnswer
taskExamCustomerAnswer
=
taskExamCustomerAnswerMapper
.
getByTUid
(
taskId
,
userId
);
if
(
null
==
taskExamCustomerAnswer
)
{
taskExamCustomerAnswer
=
new
TaskExamCustomerAnswer
();
taskExamCustomerAnswer
.
setCreateTime
(
now
);
taskExamCustomerAnswer
.
setCreateUser
(
userId
);
taskExamCustomerAnswer
.
setTaskExamId
(
taskId
);
List
<
TaskItemAnswerObject
>
taskItemAnswerObjects
=
Arrays
.
asList
(
new
TaskItemAnswerObject
(
examPaperAnswer
.
getExamPaperId
(),
examPaperAnswer
.
getId
(),
examPaperAnswer
.
getStatus
()));
TextContent
textContent
=
textContentService
.
jsonConvertInsert
(
taskItemAnswerObjects
,
now
,
null
);
textContentService
.
insertByFilter
(
textContent
);
taskExamCustomerAnswer
.
setTextContentId
(
textContent
.
getId
());
insertByFilter
(
taskExamCustomerAnswer
);
}
else
{
TextContent
textContent
=
textContentService
.
selectById
(
taskExamCustomerAnswer
.
getTextContentId
());
List
<
TaskItemAnswerObject
>
taskItemAnswerObjects
=
JsonUtil
.
toJsonListObject
(
textContent
.
getContent
(),
TaskItemAnswerObject
.
class
);
taskItemAnswerObjects
.
add
(
new
TaskItemAnswerObject
(
examPaperAnswer
.
getExamPaperId
(),
examPaperAnswer
.
getId
(),
examPaperAnswer
.
getStatus
()));
textContentService
.
jsonConvertUpdate
(
textContent
,
taskItemAnswerObjects
,
null
);
textContentService
.
updateByIdFilter
(
textContent
);
}
}
@Override
public
TaskExamCustomerAnswer
selectByTUid
(
Integer
tid
,
Integer
uid
)
{
return
taskExamCustomerAnswerMapper
.
getByTUid
(
tid
,
uid
);
}
@Override
public
List
<
TaskExamCustomerAnswer
>
selectByTUid
(
List
<
Integer
>
taskIds
,
Integer
uid
)
{
return
taskExamCustomerAnswerMapper
.
selectByTUid
(
taskIds
,
uid
);
}
}
source/java/src/main/java/com/mindskip/xzs/service/impl/TaskExamServiceImpl.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.service.impl
;
import
com.mindskip.xzs.domain.ExamPaper
;
import
com.mindskip.xzs.domain.TaskExam
;
import
com.mindskip.xzs.domain.TextContent
;
import
com.mindskip.xzs.domain.User
;
import
com.mindskip.xzs.domain.task.TaskItemObject
;
import
com.mindskip.xzs.repository.ExamPaperMapper
;
import
com.mindskip.xzs.repository.TaskExamMapper
;
import
com.mindskip.xzs.service.TaskExamService
;
import
com.mindskip.xzs.service.TextContentService
;
import
com.mindskip.xzs.service.enums.ActionEnum
;
import
com.mindskip.xzs.utility.DateTimeUtil
;
import
com.mindskip.xzs.utility.JsonUtil
;
import
com.mindskip.xzs.utility.ModelMapperSingle
;
import
com.mindskip.xzs.viewmodel.exam.ExamResponseVM
;
import
com.mindskip.xzs.viewmodel.task.TaskPageRequestVM
;
import
com.mindskip.xzs.viewmodel.task.TaskRequestVM
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
org.modelmapper.ModelMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
public
class
TaskExamServiceImpl
extends
BaseServiceImpl
<
TaskExam
>
implements
TaskExamService
{
protected
final
static
ModelMapper
modelMapper
=
ModelMapperSingle
.
Instance
();
private
final
TaskExamMapper
taskExamMapper
;
private
final
TextContentService
textContentService
;
private
final
ExamPaperMapper
examPaperMapper
;
@Autowired
public
TaskExamServiceImpl
(
TaskExamMapper
taskExamMapper
,
TextContentService
textContentService
,
ExamPaperMapper
examPaperMapper
)
{
super
(
taskExamMapper
);
this
.
taskExamMapper
=
taskExamMapper
;
this
.
textContentService
=
textContentService
;
this
.
examPaperMapper
=
examPaperMapper
;
}
@Override
public
PageInfo
<
TaskExam
>
page
(
TaskPageRequestVM
requestVM
)
{
return
PageHelper
.
startPage
(
requestVM
.
getPageIndex
(),
requestVM
.
getPageSize
(),
"id desc"
).
doSelectPageInfo
(()
->
taskExamMapper
.
page
(
requestVM
)
);
}
@Override
@Transactional
public
void
edit
(
TaskRequestVM
model
,
User
user
)
{
ActionEnum
actionEnum
=
(
model
.
getId
()
==
null
)
?
ActionEnum
.
ADD
:
ActionEnum
.
UPDATE
;
TaskExam
taskExam
=
null
;
if
(
actionEnum
==
ActionEnum
.
ADD
)
{
Date
now
=
new
Date
();
taskExam
=
modelMapper
.
map
(
model
,
TaskExam
.
class
);
taskExam
.
setCreateUser
(
user
.
getId
());
taskExam
.
setCreateUserName
(
user
.
getUserName
());
taskExam
.
setCreateTime
(
now
);
taskExam
.
setDeleted
(
false
);
//保存任务结构
TextContent
textContent
=
textContentService
.
jsonConvertInsert
(
model
.
getPaperItems
(),
now
,
p
->
{
TaskItemObject
taskItemObject
=
new
TaskItemObject
();
taskItemObject
.
setExamPaperId
(
p
.
getId
());
taskItemObject
.
setExamPaperName
(
p
.
getName
());
return
taskItemObject
;
});
textContentService
.
insertByFilter
(
textContent
);
taskExam
.
setFrameTextContentId
(
textContent
.
getId
());
taskExamMapper
.
insertSelective
(
taskExam
);
}
else
{
taskExam
=
taskExamMapper
.
selectByPrimaryKey
(
model
.
getId
());
modelMapper
.
map
(
model
,
taskExam
);
TextContent
textContent
=
textContentService
.
selectById
(
taskExam
.
getFrameTextContentId
());
//清空试卷任务的试卷Id,后面会统一设置
List
<
Integer
>
paperIds
=
JsonUtil
.
toJsonListObject
(
textContent
.
getContent
(),
TaskItemObject
.
class
)
.
stream
()
.
map
(
d
->
d
.
getExamPaperId
())
.
collect
(
Collectors
.
toList
());
examPaperMapper
.
clearTaskPaper
(
paperIds
);
//更新任务结构
textContentService
.
jsonConvertUpdate
(
textContent
,
model
.
getPaperItems
(),
p
->
{
TaskItemObject
taskItemObject
=
new
TaskItemObject
();
taskItemObject
.
setExamPaperId
(
p
.
getId
());
taskItemObject
.
setExamPaperName
(
p
.
getName
());
return
taskItemObject
;
});
textContentService
.
updateByIdFilter
(
textContent
);
taskExamMapper
.
updateByPrimaryKeySelective
(
taskExam
);
}
//更新试卷的taskId
List
<
Integer
>
paperIds
=
model
.
getPaperItems
().
stream
().
map
(
d
->
d
.
getId
()).
collect
(
Collectors
.
toList
());
examPaperMapper
.
updateTaskPaper
(
taskExam
.
getId
(),
paperIds
);
model
.
setId
(
taskExam
.
getId
());
}
@Override
public
TaskRequestVM
taskExamToVM
(
Integer
id
)
{
TaskExam
taskExam
=
taskExamMapper
.
selectByPrimaryKey
(
id
);
TaskRequestVM
vm
=
modelMapper
.
map
(
taskExam
,
TaskRequestVM
.
class
);
TextContent
textContent
=
textContentService
.
selectById
(
taskExam
.
getFrameTextContentId
());
List
<
ExamResponseVM
>
examResponseVMS
=
JsonUtil
.
toJsonListObject
(
textContent
.
getContent
(),
TaskItemObject
.
class
).
stream
().
map
(
tk
->
{
ExamPaper
examPaper
=
examPaperMapper
.
selectByPrimaryKey
(
tk
.
getExamPaperId
());
ExamResponseVM
examResponseVM
=
modelMapper
.
map
(
examPaper
,
ExamResponseVM
.
class
);
examResponseVM
.
setCreateTime
(
DateTimeUtil
.
dateFormat
(
examPaper
.
getCreateTime
()));
return
examResponseVM
;
}).
collect
(
Collectors
.
toList
());
vm
.
setPaperItems
(
examResponseVMS
);
return
vm
;
}
@Override
public
List
<
TaskExam
>
getByGradeLevel
(
Integer
gradeLevel
)
{
return
taskExamMapper
.
getByGradeLevel
(
gradeLevel
);
}
}
source/java/src/main/java/com/mindskip/xzs/service/impl/TextContentServiceImpl.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.service.impl
;
import
com.mindskip.xzs.domain.TextContent
;
import
com.mindskip.xzs.repository.TextContentMapper
;
import
com.mindskip.xzs.service.TextContentService
;
import
com.mindskip.xzs.utility.JsonUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Service
public
class
TextContentServiceImpl
extends
BaseServiceImpl
<
TextContent
>
implements
TextContentService
{
private
final
static
String
CACHE_NAME
=
"xzs:textcontent"
;
private
final
TextContentMapper
textContentMapper
;
@Autowired
public
TextContentServiceImpl
(
TextContentMapper
textContentMapper
)
{
super
(
textContentMapper
);
this
.
textContentMapper
=
textContentMapper
;
}
@Override
@Cacheable
(
value
=
CACHE_NAME
,
key
=
"#id"
,
unless
=
"#result == null"
)
public
TextContent
selectById
(
Integer
id
)
{
return
super
.
selectById
(
id
);
}
@Override
public
int
insertByFilter
(
TextContent
record
)
{
return
super
.
insertByFilter
(
record
);
}
@Override
@CacheEvict
(
value
=
CACHE_NAME
,
key
=
"#record.id"
)
public
int
updateByIdFilter
(
TextContent
record
)
{
return
super
.
updateByIdFilter
(
record
);
}
@Override
public
<
T
,
R
>
TextContent
jsonConvertInsert
(
List
<
T
>
list
,
Date
now
,
Function
<?
super
T
,
?
extends
R
>
mapper
)
{
String
frameTextContent
=
null
;
if
(
null
==
mapper
)
{
frameTextContent
=
JsonUtil
.
toJsonStr
(
list
);
}
else
{
List
<
R
>
mapList
=
list
.
stream
().
map
(
mapper
).
collect
(
Collectors
.
toList
());
frameTextContent
=
JsonUtil
.
toJsonStr
(
mapList
);
}
TextContent
textContent
=
new
TextContent
(
frameTextContent
,
now
);
//insertByFilter(textContent); cache useless
return
textContent
;
}
@Override
public
<
T
,
R
>
TextContent
jsonConvertUpdate
(
TextContent
textContent
,
List
<
T
>
list
,
Function
<?
super
T
,
?
extends
R
>
mapper
)
{
String
frameTextContent
=
null
;
if
(
null
==
mapper
)
{
frameTextContent
=
JsonUtil
.
toJsonStr
(
list
);
}
else
{
List
<
R
>
mapList
=
list
.
stream
().
map
(
mapper
).
collect
(
Collectors
.
toList
());
frameTextContent
=
JsonUtil
.
toJsonStr
(
mapList
);
}
textContent
.
setContent
(
frameTextContent
);
//this.updateByIdFilter(textContent); cache useless
return
textContent
;
}
}
source/java/src/main/java/com/mindskip/xzs/service/impl/UserEventLogServiceImpl.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.service.impl
;
import
com.mindskip.xzs.domain.UserEventLog
;
import
com.mindskip.xzs.domain.other.KeyValue
;
import
com.mindskip.xzs.repository.UserEventLogMapper
;
import
com.mindskip.xzs.service.UserEventLogService
;
import
com.mindskip.xzs.utility.DateTimeUtil
;
import
com.mindskip.xzs.viewmodel.user.UserEventPageRequestVM
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
public
class
UserEventLogServiceImpl
extends
BaseServiceImpl
<
UserEventLog
>
implements
UserEventLogService
{
private
final
UserEventLogMapper
userEventLogMapper
;
@Autowired
public
UserEventLogServiceImpl
(
UserEventLogMapper
userEventLogMapper
)
{
super
(
userEventLogMapper
);
this
.
userEventLogMapper
=
userEventLogMapper
;
}
@Override
public
List
<
UserEventLog
>
getUserEventLogByUserId
(
Integer
id
)
{
return
userEventLogMapper
.
getUserEventLogByUserId
(
id
);
}
@Override
public
PageInfo
<
UserEventLog
>
page
(
UserEventPageRequestVM
requestVM
)
{
return
PageHelper
.
startPage
(
requestVM
.
getPageIndex
(),
requestVM
.
getPageSize
(),
"id desc"
).
doSelectPageInfo
(()
->
userEventLogMapper
.
page
(
requestVM
)
);
}
@Override
public
List
<
Integer
>
selectMothCount
()
{
Date
startTime
=
DateTimeUtil
.
getMonthStartDay
();
Date
endTime
=
DateTimeUtil
.
getMonthEndDay
();
List
<
KeyValue
>
mouthCount
=
userEventLogMapper
.
selectCountByDate
(
startTime
,
endTime
);
List
<
String
>
mothStartToNowFormat
=
DateTimeUtil
.
MothStartToNowFormat
();
return
mothStartToNowFormat
.
stream
().
map
(
md
->
{
KeyValue
keyValue
=
mouthCount
.
stream
().
filter
(
kv
->
kv
.
getName
().
equals
(
md
)).
findAny
().
orElse
(
null
);
return
null
==
keyValue
?
0
:
keyValue
.
getValue
();
}).
collect
(
Collectors
.
toList
());
}
}
source/java/src/main/java/com/mindskip/xzs/service/impl/UserServiceImpl.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.service.impl
;
import
com.mindskip.xzs.domain.other.KeyValue
;
import
com.mindskip.xzs.exception.BusinessException
;
import
com.mindskip.xzs.domain.User
;
import
com.mindskip.xzs.event.OnRegistrationCompleteEvent
;
import
com.mindskip.xzs.repository.UserMapper
;
import
com.mindskip.xzs.service.UserService
;
import
com.mindskip.xzs.viewmodel.user.UserPageRequestVM
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
UserServiceImpl
extends
BaseServiceImpl
<
User
>
implements
UserService
{
private
final
static
String
CACHE_NAME
=
"xzs:user"
;
private
final
UserMapper
userMapper
;
private
final
ApplicationEventPublisher
eventPublisher
;
@Autowired
public
UserServiceImpl
(
UserMapper
userMapper
,
ApplicationEventPublisher
eventPublisher
)
{
super
(
userMapper
);
this
.
userMapper
=
userMapper
;
this
.
eventPublisher
=
eventPublisher
;
}
@Override
public
List
<
User
>
getUsers
()
{
return
userMapper
.
getAllUser
();
}
@Override
public
User
getUserById
(
Integer
id
)
{
return
userMapper
.
getUserById
(
id
);
}
@Override
@Cacheable
(
value
=
CACHE_NAME
,
key
=
"#username"
,
unless
=
"#result == null"
)
public
User
getUserByUserName
(
String
username
)
{
return
userMapper
.
getUserByUserName
(
username
);
}
@Override
@CacheEvict
(
value
=
CACHE_NAME
,
key
=
"#record.userName"
)
public
int
insertByFilter
(
User
record
)
{
return
super
.
insertByFilter
(
record
);
}
@Override
@CacheEvict
(
value
=
CACHE_NAME
,
key
=
"#record.userName"
)
public
int
updateByIdFilter
(
User
record
)
{
return
super
.
updateByIdFilter
(
record
);
}
@Override
@CacheEvict
(
value
=
CACHE_NAME
,
key
=
"#record.userName"
)
public
int
updateById
(
User
record
)
{
return
super
.
updateById
(
record
);
}
@Override
public
User
getUserByUserNamePwd
(
String
username
,
String
pwd
)
{
return
userMapper
.
getUserByUserNamePwd
(
username
,
pwd
);
}
@Override
public
User
getUserByUuid
(
String
uuid
)
{
return
userMapper
.
getUserByUuid
(
uuid
);
}
@Override
public
List
<
User
>
userPageList
(
String
name
,
Integer
pageIndex
,
Integer
pageSize
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
3
);
map
.
put
(
"name"
,
name
);
map
.
put
(
"offset"
,
((
int
)
pageIndex
)
*
pageSize
);
map
.
put
(
"limit"
,
pageSize
);
return
userMapper
.
userPageList
(
map
);
}
@Override
public
Integer
userPageCount
(
String
name
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
1
);
map
.
put
(
"name"
,
name
);
return
userMapper
.
userPageCount
(
map
);
}
@Override
public
PageInfo
<
User
>
userPage
(
UserPageRequestVM
requestVM
)
{
return
PageHelper
.
startPage
(
requestVM
.
getPageIndex
(),
requestVM
.
getPageSize
(),
"id desc"
).
doSelectPageInfo
(()
->
userMapper
.
userPage
(
requestVM
)
);
}
@Override
public
void
insertUser
(
User
user
)
{
userMapper
.
insertSelective
(
user
);
eventPublisher
.
publishEvent
(
new
OnRegistrationCompleteEvent
(
user
));
}
@Override
@Transactional
(
rollbackFor
=
BusinessException
.
class
)
public
void
insertUsers
(
List
<
User
>
users
)
{
userMapper
.
insertUsers
(
users
);
throw
new
BusinessException
(
"test BusinessException roll back"
);
}
@Override
public
void
updateUser
(
User
user
)
{
userMapper
.
updateUser
(
user
);
}
@Override
public
void
updateUsersAge
(
Integer
age
,
List
<
Integer
>
ids
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
2
);
map
.
put
(
"idslist"
,
ids
);
map
.
put
(
"age"
,
age
);
userMapper
.
updateUsersAge
(
map
);
}
@Override
public
void
deleteUserByIds
(
List
<
Integer
>
ids
)
{
userMapper
.
deleteUsersByIds
(
ids
);
}
@Override
public
Integer
selectAllCount
()
{
return
userMapper
.
selectAllCount
();
}
@Override
public
List
<
KeyValue
>
selectByUserName
(
String
userName
)
{
return
userMapper
.
selectByUserName
(
userName
);
}
@Override
public
List
<
User
>
selectByIds
(
List
<
Integer
>
ids
)
{
return
userMapper
.
selectByIds
(
ids
);
}
@Override
public
User
selectByWxOpenId
(
String
wxOpenId
)
{
return
userMapper
.
selectByWxOpenId
(
wxOpenId
);
}
@Override
@CacheEvict
(
value
=
CACHE_NAME
,
key
=
"#user.userName"
)
@Transactional
public
void
changePicture
(
User
user
,
String
imagePath
)
{
User
changePictureUser
=
new
User
();
changePictureUser
.
setId
(
user
.
getId
());
changePictureUser
.
setImagePath
(
imagePath
);
userMapper
.
updateByPrimaryKeySelective
(
changePictureUser
);
}
}
source/java/src/main/java/com/mindskip/xzs/service/impl/UserTokenServiceImpl.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.service.impl
;
import
com.mindskip.xzs.configuration.property.SystemConfig
;
import
com.mindskip.xzs.domain.User
;
import
com.mindskip.xzs.domain.UserToken
;
import
com.mindskip.xzs.repository.UserTokenMapper
;
import
com.mindskip.xzs.service.UserService
;
import
com.mindskip.xzs.service.UserTokenService
;
import
com.mindskip.xzs.utility.DateTimeUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.UUID
;
@Service
public
class
UserTokenServiceImpl
extends
BaseServiceImpl
<
UserToken
>
implements
UserTokenService
{
private
final
static
String
CACHE_NAME
=
"xzs:token"
;
private
final
UserTokenMapper
userTokenMapper
;
private
final
UserService
userService
;
private
final
SystemConfig
systemConfig
;
@Autowired
public
UserTokenServiceImpl
(
UserTokenMapper
userTokenMapper
,
UserService
userService
,
SystemConfig
systemConfig
)
{
super
(
userTokenMapper
);
this
.
userTokenMapper
=
userTokenMapper
;
this
.
userService
=
userService
;
this
.
systemConfig
=
systemConfig
;
}
@Override
@Transactional
public
UserToken
bind
(
User
user
)
{
user
.
setModifyTime
(
new
Date
());
userService
.
updateByIdFilter
(
user
);
return
insertUserToken
(
user
);
}
@Override
public
UserToken
checkBind
(
String
openId
)
{
User
user
=
userService
.
selectByWxOpenId
(
openId
);
if
(
null
!=
user
)
{
return
insertUserToken
(
user
);
}
return
null
;
}
@Override
@Cacheable
(
value
=
CACHE_NAME
,
key
=
"#token"
,
unless
=
"#result == null"
)
public
UserToken
getToken
(
String
token
)
{
return
userTokenMapper
.
getToken
(
token
);
}
@Override
@Cacheable
(
value
=
CACHE_NAME
,
key
=
"#result.token"
,
unless
=
"#result == null"
)
public
UserToken
insertUserToken
(
User
user
)
{
Date
startTime
=
new
Date
();
Date
endTime
=
DateTimeUtil
.
addDuration
(
startTime
,
systemConfig
.
getWx
().
getTokenToLive
());
UserToken
userToken
=
new
UserToken
();
userToken
.
setToken
(
UUID
.
randomUUID
().
toString
());
userToken
.
setUserId
(
user
.
getId
());
userToken
.
setWxOpenId
(
user
.
getWxOpenId
());
userToken
.
setCreateTime
(
startTime
);
userToken
.
setEndTime
(
endTime
);
userToken
.
setUserName
(
user
.
getUserName
());
userService
.
updateByIdFilter
(
user
);
userTokenMapper
.
insertSelective
(
userToken
);
return
userToken
;
}
@Override
@CacheEvict
(
value
=
CACHE_NAME
,
key
=
"#userToken.token"
)
public
void
unBind
(
UserToken
userToken
)
{
User
user
=
userService
.
selectById
(
userToken
.
getUserId
());
user
.
setModifyTime
(
new
Date
());
user
.
setWxOpenId
(
null
);
userService
.
updateById
(
user
);
userTokenMapper
.
deleteByPrimaryKey
(
userToken
.
getId
());
}
}
source/java/src/main/java/com/mindskip/xzs/utility/DateTimeUtil.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.Duration
;
import
java.util.*
;
/**
* @version 3.5.0
* @description: The type Date time util.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
DateTimeUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DateTimeUtil
.
class
);
/**
* The constant STANDER_FORMAT.
*/
public
static
final
String
STANDER_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* The constant STANDER_SHORT_FORMAT.
*/
public
static
final
String
STANDER_SHORT_FORMAT
=
"yyyy-MM-dd"
;
/**
* Add duration date.
*
* @param date the date
* @param duration the duration
* @return the date
*/
public
static
Date
addDuration
(
Date
date
,
Duration
duration
)
{
Calendar
ca
=
Calendar
.
getInstance
();
ca
.
setTime
(
date
);
ca
.
add
(
Calendar
.
SECOND
,
(
int
)
duration
.
getSeconds
());
return
ca
.
getTime
();
}
/**
* Date format string.
*
* @param date the date
* @return the string
*/
public
static
String
dateFormat
(
Date
date
)
{
if
(
null
==
date
)
{
return
""
;
}
DateFormat
dateFormat
=
new
SimpleDateFormat
(
STANDER_FORMAT
);
return
dateFormat
.
format
(
date
);
}
/**
* Date short format string.
*
* @param date the date
* @return the string
*/
public
static
String
dateShortFormat
(
Date
date
)
{
if
(
null
==
date
)
{
return
""
;
}
DateFormat
dateFormat
=
new
SimpleDateFormat
(
STANDER_SHORT_FORMAT
);
return
dateFormat
.
format
(
date
);
}
/**
* Parse date.
*
* @param dateStr the date str
* @param format the format
* @return the date
*/
public
static
Date
parse
(
String
dateStr
,
String
format
)
{
try
{
return
new
SimpleDateFormat
(
format
).
parse
(
dateStr
);
}
catch
(
ParseException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
/**
* Gets month start day.
*
* @return the month start day
*/
public
static
Date
getMonthStartDay
()
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd 00:00:00"
);
Calendar
cale
=
Calendar
.
getInstance
();
cale
.
add
(
Calendar
.
MONTH
,
0
);
cale
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
String
dateStr
=
formatter
.
format
(
cale
.
getTime
());
return
parse
(
dateStr
,
"yyyy-MM-dd HH:mm:ss"
);
}
/**
* Gets month end day.
*
* @return the month end day
*/
public
static
Date
getMonthEndDay
()
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd 23:59:59"
);
Calendar
cale
=
Calendar
.
getInstance
();
cale
.
add
(
Calendar
.
MONTH
,
1
);
cale
.
set
(
Calendar
.
DAY_OF_MONTH
,
0
);
String
dateStr
=
formatter
.
format
(
cale
.
getTime
());
return
parse
(
dateStr
,
STANDER_FORMAT
);
}
/**
* Moth start to now format list.
*
* @return the list
*/
public
static
List
<
String
>
MothStartToNowFormat
()
{
Date
startTime
=
getMonthStartDay
();
Calendar
nowCalendar
=
Calendar
.
getInstance
();
nowCalendar
.
setTime
(
new
Date
());
int
mothDayCount
=
nowCalendar
.
get
(
Calendar
.
DAY_OF_MONTH
);
List
<
String
>
mothDays
=
new
ArrayList
<>(
mothDayCount
);
Calendar
startCalendar
=
new
GregorianCalendar
();
startCalendar
.
setTime
(
startTime
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
mothDays
.
add
(
formatter
.
format
(
startTime
));
for
(
int
i
=
0
;
i
<
mothDayCount
-
1
;
i
++)
{
startCalendar
.
add
(
Calendar
.
DATE
,
1
);
Date
end_date
=
startCalendar
.
getTime
();
mothDays
.
add
(
formatter
.
format
(
end_date
));
}
return
mothDays
;
}
/**
* Moth day list.
*
* @return the list
*/
public
static
List
<
String
>
MothDay
()
{
Calendar
endCalendar
=
Calendar
.
getInstance
();
endCalendar
.
setTime
(
getMonthEndDay
());
int
endMothDay
=
endCalendar
.
get
(
Calendar
.
DAY_OF_MONTH
);
List
<
String
>
list
=
new
ArrayList
<>(
endMothDay
);
for
(
int
i
=
1
;
i
<=
endMothDay
;
i
++)
{
list
.
add
(
String
.
valueOf
(
i
));
}
return
list
;
}
}
source/java/src/main/java/com/mindskip/xzs/utility/ErrorUtil.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
/**
* @version 3.5.0
* @description: The type Error util.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
ErrorUtil
{
/**
* Parameter error format string.
*
* @param field the field
* @param msg the msg
* @return the string
*/
public
static
String
parameterErrorFormat
(
String
field
,
String
msg
)
{
return
"【"
+
field
+
" : "
+
msg
+
"】"
;
}
}
source/java/src/main/java/com/mindskip/xzs/utility/ExamUtil.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @version 3.5.0
* @description: The type Exam util.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
ExamUtil
{
/**
* Score to vm string.
*
* @param score the score
* @return the string
*/
public
static
String
scoreToVM
(
Integer
score
)
{
if
(
score
%
10
==
0
)
{
return
String
.
valueOf
(
score
/
10
);
}
else
{
return
String
.
format
(
"%.1f"
,
score
/
10.0
);
}
}
/**
* Score from vm integer.
*
* @param score the score
* @return the integer
*/
public
static
Integer
scoreFromVM
(
String
score
)
{
if
(
score
==
null
)
{
return
null
;
}
else
{
return
(
int
)
(
Float
.
parseFloat
(
score
)
*
10
);
}
}
/**
* Second to vm string.
*
* @param second the second
* @return the string
*/
public
static
String
secondToVM
(
Integer
second
)
{
String
dateTimes
;
long
days
=
second
/
(
60
*
60
*
24
);
long
hours
=
(
second
%
(
60
*
60
*
24
))
/
(
60
*
60
);
long
minutes
=
(
second
%
(
60
*
60
))
/
60
;
long
seconds
=
second
%
60
;
if
(
days
>
0
)
{
dateTimes
=
days
+
"天 "
+
hours
+
"时 "
+
minutes
+
"分 "
+
seconds
+
"秒"
;
}
else
if
(
hours
>
0
)
{
dateTimes
=
hours
+
"时 "
+
minutes
+
"分 "
+
seconds
+
"秒"
;
}
else
if
(
minutes
>
0
)
{
dateTimes
=
minutes
+
"分 "
+
seconds
+
"秒"
;
}
else
{
dateTimes
=
seconds
+
" 秒"
;
}
return
dateTimes
;
}
private
static
final
String
ANSWER_SPLIT
=
","
;
/**
* Content to string string.
*
* @param contentArray the content array
* @return the string
*/
public
static
String
contentToString
(
List
<
String
>
contentArray
)
{
return
contentArray
.
stream
().
sorted
().
collect
(
Collectors
.
joining
(
ANSWER_SPLIT
));
}
/**
* Content to array list.
*
* @param contentArray the content array
* @return the list
*/
public
static
List
<
String
>
contentToArray
(
String
contentArray
)
{
return
Arrays
.
asList
(
contentArray
.
split
(
ANSWER_SPLIT
));
}
private
static
final
String
FORM_ANSWER_SPLIT
=
"_"
;
/**
* Last num integer.
*
* @param str the str
* @return the integer
*/
public
static
Integer
lastNum
(
String
str
)
{
Integer
start
=
str
.
lastIndexOf
(
FORM_ANSWER_SPLIT
);
return
Integer
.
parseInt
(
str
.
substring
(
start
+
1
));
}
}
source/java/src/main/java/com/mindskip/xzs/utility/HtmlUtil.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* @version 3.5.0
* @description: The type Html util.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
HtmlUtil
{
/**
* Clear string.
*
* @param htmlStr the html str
* @return the string
*/
public
static
String
clear
(
String
htmlStr
)
{
String
regEx_script
=
"<script[^>]*?>[\\s\\S]*?<\\/script>"
;
String
regEx_style
=
"<style[^>]*?>[\\s\\S]*?<\\/style>"
;
String
regEx_html
=
"<[^>]+>"
;
Pattern
p_script
=
Pattern
.
compile
(
regEx_script
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m_script
=
p_script
.
matcher
(
htmlStr
);
htmlStr
=
m_script
.
replaceAll
(
""
);
Pattern
p_style
=
Pattern
.
compile
(
regEx_style
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m_style
=
p_style
.
matcher
(
htmlStr
);
htmlStr
=
m_style
.
replaceAll
(
""
);
Pattern
p_html
=
Pattern
.
compile
(
regEx_html
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m_html
=
p_html
.
matcher
(
htmlStr
);
htmlStr
=
m_html
.
replaceAll
(
""
);
return
htmlStr
.
trim
();
}
}
source/java/src/main/java/com/mindskip/xzs/utility/JsonUtil.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.JavaType
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
/**
* @version 3.5.0
* @description: The type Json util.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
JsonUtil
{
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
();
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
JsonUtil
.
class
);
static
{
MAPPER
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
}
/**
* To json str string.
*
* @param <T> the type parameter
* @param o the o
* @return the string
*/
public
static
<
T
>
String
toJsonStr
(
T
o
)
{
try
{
return
MAPPER
.
writeValueAsString
(
o
);
}
catch
(
JsonProcessingException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
/**
* To json object t.
*
* @param <T> the type parameter
* @param json the json
* @param valueType the value type
* @return the t
*/
public
static
<
T
>
T
toJsonObject
(
String
json
,
Class
<
T
>
valueType
)
{
try
{
return
MAPPER
.<
T
>
readValue
(
json
,
valueType
);
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
/**
* To json list object list.
*
* @param <T> the type parameter
* @param json the json
* @param valueType the value type
* @return the list
*/
public
static
<
T
>
List
<
T
>
toJsonListObject
(
String
json
,
Class
<
T
>
valueType
)
{
try
{
JavaType
getCollectionType
=
MAPPER
.
getTypeFactory
().
constructParametricType
(
List
.
class
,
valueType
);
List
<
T
>
list
=
MAPPER
.
readValue
(
json
,
getCollectionType
);
return
list
;
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
/**
* To json object t.
*
* @param <T> the type parameter
* @param stream the stream
* @param valueType the value type
* @return the t
*/
public
static
<
T
>
T
toJsonObject
(
InputStream
stream
,
Class
<
T
>
valueType
)
{
try
{
T
object
=
MAPPER
.<
T
>
readValue
(
stream
,
valueType
);
return
object
;
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
}
source/java/src/main/java/com/mindskip/xzs/utility/ModelMapperSingle.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
org.modelmapper.ModelMapper
;
import
org.modelmapper.convention.MatchingStrategies
;
/**
* @version 3.5.0
* @description: The type Model mapper single.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
ModelMapperSingle
{
/**
* The constant modelMapper.
*/
protected
final
static
ModelMapper
modelMapper
=
new
ModelMapper
();
private
final
static
ModelMapperSingle
modelMapperSingle
=
new
ModelMapperSingle
();
static
{
modelMapper
.
getConfiguration
().
setFullTypeMatchingRequired
(
true
);
modelMapper
.
getConfiguration
().
setMatchingStrategy
(
MatchingStrategies
.
STRICT
);
}
/**
* Instance model mapper.
*
* @return the model mapper
*/
public
static
ModelMapper
Instance
()
{
return
modelMapperSingle
.
modelMapper
;
}
}
source/java/src/main/java/com/mindskip/xzs/utility/PageInfoHelper.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
com.github.pagehelper.PageInfo
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* @version 3.5.0
* @description: The type Page info helper.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
PageInfoHelper
{
/**
* Copy map page info.
*
* @param <T> the type parameter
* @param <J> the type parameter
* @param source the source
* @param mapper the mapper
* @return the page info
*/
public
static
<
T
,
J
>
PageInfo
<
J
>
copyMap
(
PageInfo
<
T
>
source
,
Function
<?
super
T
,
?
extends
J
>
mapper
)
{
PageInfo
<
J
>
newPage
=
new
PageInfo
<>();
newPage
.
setPageNum
(
source
.
getPageNum
());
newPage
.
setPageSize
(
source
.
getPageSize
());
newPage
.
setSize
(
source
.
getSize
());
newPage
.
setStartRow
(
source
.
getStartRow
());
newPage
.
setEndRow
(
source
.
getEndRow
());
newPage
.
setTotal
(
source
.
getTotal
());
newPage
.
setPages
(
source
.
getPages
());
newPage
.
setList
(
source
.
getList
().
stream
().
map
(
mapper
).
collect
(
Collectors
.
toList
()));
newPage
.
setPrePage
(
source
.
getPrePage
());
newPage
.
setNextPage
(
source
.
getNextPage
());
newPage
.
setIsFirstPage
(
source
.
isIsFirstPage
());
newPage
.
setIsLastPage
(
source
.
isIsLastPage
());
newPage
.
setHasPreviousPage
(
source
.
isHasPreviousPage
());
newPage
.
setHasNextPage
(
source
.
isHasNextPage
());
newPage
.
setNavigatePages
(
source
.
getNavigatePages
());
newPage
.
setNavigatepageNums
(
source
.
getNavigatepageNums
());
newPage
.
setNavigateFirstPage
(
source
.
getNavigateFirstPage
());
newPage
.
setNavigateLastPage
(
source
.
getNavigateLastPage
());
return
newPage
;
}
}
source/java/src/main/java/com/mindskip/xzs/utility/RsaUtil.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.crypto.Cipher
;
import
java.security.KeyFactory
;
import
java.security.PrivateKey
;
import
java.security.PublicKey
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.Base64
;
/**
* @version 3.5.0
* @description: The type Rsa util.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
RsaUtil
{
/**
* String to hold name of the encryption algorithm.
*/
private
static
final
String
ALGORITHM
=
"RSA"
;
private
static
final
String
CHAR_SET
=
"utf-8"
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RsaUtil
.
class
);
/**
* Rsa encode string.
*
* @param publicCertificate the public certificate
* @param text the text
* @return the string
*/
public
static
String
rsaEncode
(
String
publicCertificate
,
String
text
)
{
try
{
byte
[]
publicBytes
=
baseStrToByte
(
publicCertificate
);
X509EncodedKeySpec
keySpec
=
new
X509EncodedKeySpec
(
publicBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
ALGORITHM
);
PublicKey
pubKey
=
keyFactory
.
generatePublic
(
keySpec
);
// get an RSA cipher object and print the provider
final
Cipher
cipher
=
Cipher
.
getInstance
(
ALGORITHM
);
// encrypt the plain text using the public key
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
pubKey
);
byte
[]
cipherBytes
=
cipher
.
doFinal
(
text
.
getBytes
(
CHAR_SET
));
return
baseByteToStr
(
cipherBytes
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"publicCertificate:{} \r\n text:{}"
,
publicCertificate
,
text
,
e
);
}
return
null
;
}
/**
* Rsa decode string.
*
* @param privateCertificate the private certificate
* @param text the text
* @return the string
*/
public
static
String
rsaDecode
(
String
privateCertificate
,
String
text
)
{
try
{
byte
[]
privateBytes
=
baseStrToByte
(
privateCertificate
);
PKCS8EncodedKeySpec
keySpec
=
new
PKCS8EncodedKeySpec
(
privateBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
ALGORITHM
);
PrivateKey
priKey
=
keyFactory
.
generatePrivate
(
keySpec
);
byte
[]
cipherText
;
// get an RSA cipher object and print the provider
final
Cipher
cipher
=
Cipher
.
getInstance
(
ALGORITHM
);
// encrypt the plain text using the public key
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
priKey
);
byte
[]
textbyte
=
baseStrToByte
(
text
);
cipherText
=
cipher
.
doFinal
(
textbyte
);
return
new
String
(
cipherText
,
CHAR_SET
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"privateCertificate:{} \r\n text:{}"
,
privateCertificate
,
text
,
e
);
}
return
null
;
}
/**
* @param str str
* @return byte[]
*/
private
static
byte
[]
baseStrToByte
(
String
str
)
{
return
Base64
.
getDecoder
().
decode
(
str
);
}
/**
* @param bytes bytes
* @return String
*/
private
static
String
baseByteToStr
(
byte
[]
bytes
)
{
return
Base64
.
getEncoder
().
encodeToString
(
bytes
);
}
}
source/java/src/main/java/com/mindskip/xzs/utility/WxResponse.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
java.io.Serializable
;
/**
* @version 3.5.0
* @description: The type Wx response.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
WxResponse
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
8496869159673561976L
;
private
String
session_key
;
private
String
openid
;
/**
* Gets serial version uid.
*
* @return the serial version uid
*/
public
static
long
getSerialVersionUID
()
{
return
serialVersionUID
;
}
/**
* Gets session key.
*
* @return the session key
*/
public
String
getSession_key
()
{
return
session_key
;
}
/**
* Sets session key.
*
* @param session_key the session key
*/
public
void
setSession_key
(
String
session_key
)
{
this
.
session_key
=
session_key
;
}
/**
* Gets openid.
*
* @return the openid
*/
public
String
getOpenid
()
{
return
openid
;
}
/**
* Sets openid.
*
* @param openid the openid
*/
public
void
setOpenid
(
String
openid
)
{
this
.
openid
=
openid
;
}
}
source/java/src/main/java/com/mindskip/xzs/utility/WxUtil.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.utility
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.util.EntityUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
/**
* @version 3.5.0
* @description: The type Wx util.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
WxUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
WxUtil
.
class
);
private
static
final
String
openIdUrl
=
"https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code"
;
/**
* Gets open id.
*
* @param appId the app id
* @param secret the secret
* @param code the code
* @return the open id
*/
public
static
String
getOpenId
(
String
appId
,
String
secret
,
String
code
)
{
try
(
CloseableHttpClient
httpClient
=
HttpClientBuilder
.
create
().
build
())
{
String
requestUrl
=
String
.
format
(
openIdUrl
,
appId
,
secret
,
code
);
HttpGet
httpGet
=
new
HttpGet
(
requestUrl
);
HttpEntity
responseEntity
=
httpClient
.
execute
(
httpGet
).
getEntity
();
if
(
responseEntity
!=
null
)
{
String
responseStr
=
EntityUtils
.
toString
(
responseEntity
);
if
(
responseStr
.
contains
(
"openid"
))
{
WxResponse
wxResponse
=
JsonUtil
.
toJsonObject
(
responseStr
,
WxResponse
.
class
);
return
wxResponse
.
getOpenid
();
}
}
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
}
source/java/src/main/java/com/mindskip/xzs/viewmodel/BaseVM.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.viewmodel
;
import
com.mindskip.xzs.utility.ModelMapperSingle
;
import
org.modelmapper.ModelMapper
;
/**
* @version 3.5.0
* @description: The type Base vm.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public
class
BaseVM
{
/**
* The constant modelMapper.
*/
protected
static
ModelMapper
modelMapper
=
ModelMapperSingle
.
Instance
();
/**
* Gets model mapper.
*
* @return the model mapper
*/
public
static
ModelMapper
getModelMapper
()
{
return
modelMapper
;
}
/**
* Sets model mapper.
*
* @param modelMapper the model mapper
*/
public
static
void
setModelMapper
(
ModelMapper
modelMapper
)
{
BaseVM
.
modelMapper
=
modelMapper
;
}
}
source/java/src/main/java/com/mindskip/xzs/viewmodel/dashboard/IndexVM.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.viewmodel.dashboard
;
import
java.util.List
;
public
class
IndexVM
{
private
Integer
examPaperCount
;
private
Integer
questionCount
;
private
Integer
doExamPaperCount
;
private
Integer
doQuestionCount
;
private
List
<
Integer
>
mothDayUserActionValue
;
private
List
<
Integer
>
mothDayDoExamQuestionValue
;
private
List
<
String
>
mothDayText
;
public
Integer
getExamPaperCount
()
{
return
examPaperCount
;
}
public
void
setExamPaperCount
(
Integer
examPaperCount
)
{
this
.
examPaperCount
=
examPaperCount
;
}
public
Integer
getQuestionCount
()
{
return
questionCount
;
}
public
void
setQuestionCount
(
Integer
questionCount
)
{
this
.
questionCount
=
questionCount
;
}
public
Integer
getDoExamPaperCount
()
{
return
doExamPaperCount
;
}
public
void
setDoExamPaperCount
(
Integer
doExamPaperCount
)
{
this
.
doExamPaperCount
=
doExamPaperCount
;
}
public
Integer
getDoQuestionCount
()
{
return
doQuestionCount
;
}
public
void
setDoQuestionCount
(
Integer
doQuestionCount
)
{
this
.
doQuestionCount
=
doQuestionCount
;
}
public
List
<
Integer
>
getMothDayUserActionValue
()
{
return
mothDayUserActionValue
;
}
public
void
setMothDayUserActionValue
(
List
<
Integer
>
mothDayUserActionValue
)
{
this
.
mothDayUserActionValue
=
mothDayUserActionValue
;
}
public
List
<
Integer
>
getMothDayDoExamQuestionValue
()
{
return
mothDayDoExamQuestionValue
;
}
public
void
setMothDayDoExamQuestionValue
(
List
<
Integer
>
mothDayDoExamQuestionValue
)
{
this
.
mothDayDoExamQuestionValue
=
mothDayDoExamQuestionValue
;
}
public
List
<
String
>
getMothDayText
()
{
return
mothDayText
;
}
public
void
setMothDayText
(
List
<
String
>
mothDayText
)
{
this
.
mothDayText
=
mothDayText
;
}
}
source/java/src/main/java/com/mindskip/xzs/viewmodel/education/SubjectEditRequestVM.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.viewmodel.education
;
import
com.mindskip.xzs.viewmodel.BaseVM
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
public
class
SubjectEditRequestVM
extends
BaseVM
{
private
Integer
id
;
@NotBlank
private
String
name
;
@NotNull
private
Integer
level
;
@NotBlank
private
String
levelName
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Integer
getLevel
()
{
return
level
;
}
public
void
setLevel
(
Integer
level
)
{
this
.
level
=
level
;
}
public
String
getLevelName
()
{
return
levelName
;
}
public
void
setLevelName
(
String
levelName
)
{
this
.
levelName
=
levelName
;
}
}
source/java/src/main/java/com/mindskip/xzs/viewmodel/education/SubjectPageRequestVM.java
0 → 100644
View file @
64d4f18d
package
com.mindskip.xzs.viewmodel.education
;
import
com.mindskip.xzs.base.BasePage
;
public
class
SubjectPageRequestVM
extends
BasePage
{
private
Integer
id
;
private
Integer
level
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
Integer
getLevel
()
{
return
level
;
}
public
void
setLevel
(
Integer
level
)
{
this
.
level
=
level
;
}
}
Prev
1
…
3
4
5
6
7
8
9
10
11
…
44
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment