|
|
@ -44,13 +44,19 @@ object AccountService : AbstractService() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun toUserInfo(user: User):UserInfoVo{ |
|
|
|
|
|
|
|
return UserInfoVo(name = user.name, headImg = user.headImg?.filepath, desc = user.desc) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 注册 |
|
|
|
* 注册 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun register(userVo: UserRegVo): String? { |
|
|
|
fun register(userVo: UserRegVo): String? { |
|
|
|
try { |
|
|
|
try { |
|
|
|
return transaction { |
|
|
|
return transaction { |
|
|
|
val originPassword = randomNum(8) |
|
|
|
|
|
|
|
|
|
|
|
val originPassword = if(environment.developmentMode) (1..8).joinToString("") else randomNum(8) |
|
|
|
|
|
|
|
log.info("密码:${originPassword}") |
|
|
|
User.new { |
|
|
|
User.new { |
|
|
|
studentId = userVo.studentId |
|
|
|
studentId = userVo.studentId |
|
|
|
name = userVo.name |
|
|
|
name = userVo.name |
|
|
@ -324,7 +330,7 @@ object MainService : AbstractService() { |
|
|
|
return@transaction LeaveMessage.all().toList().map { |
|
|
|
return@transaction LeaveMessage.all().toList().map { |
|
|
|
LeaveMessageDto( |
|
|
|
LeaveMessageDto( |
|
|
|
message = "${it.user.name}说:${it.message}", |
|
|
|
message = "${it.user.name}说:${it.message}", |
|
|
|
user = UserInfoVo(name = it.user.name, headImg = it.user.headImg?.filepath, desc = it.user.desc) |
|
|
|
user = AccountService.toUserInfo(user = it.user) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -342,8 +348,10 @@ object FileService : AbstractService() { |
|
|
|
super.init(environment) |
|
|
|
super.init(environment) |
|
|
|
this.uploadDir = environment.config.property("ktor.deployment.filePath").getString() |
|
|
|
this.uploadDir = environment.config.property("ktor.deployment.filePath").getString() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info(this::class.java.classLoader.getResource("")?.path) |
|
|
|
|
|
|
|
|
|
|
|
filePath = |
|
|
|
filePath = |
|
|
|
this::class.java.classLoader.getResource(uploadDir)?.path ?: throw IllegalArgumentException("初始化资源目录失败") |
|
|
|
environment.classLoader.getResource(uploadDir)?.path ?: throw IllegalArgumentException("初始化资源目录失败") |
|
|
|
File(filePath).let { |
|
|
|
File(filePath).let { |
|
|
|
when { |
|
|
|
when { |
|
|
|
it.exists() -> log.info("上传路径[${filePath}]已存在") |
|
|
|
it.exists() -> log.info("上传路径[${filePath}]已存在") |
|
|
@ -690,12 +698,7 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
return it?.let { logging -> |
|
|
|
return it?.let { logging -> |
|
|
|
val auditLogging = AuditLoggingVo( |
|
|
|
val auditLogging = AuditLoggingVo( |
|
|
|
id = logging.id.value, |
|
|
|
id = logging.id.value, |
|
|
|
user = |
|
|
|
user = AccountService.toUserInfo(user = logging.user), |
|
|
|
UserInfoVo( |
|
|
|
|
|
|
|
name = logging.user.name, |
|
|
|
|
|
|
|
headImg = logging.user.headImg?.filepath, |
|
|
|
|
|
|
|
desc = logging.user.desc |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
applyTime = logging.applyTime.toLong(), |
|
|
|
applyTime = logging.applyTime.toLong(), |
|
|
|
manager = logging.manager?.let { |
|
|
|
manager = logging.manager?.let { |
|
|
|
ManagerInfoVo( |
|
|
|
ManagerInfoVo( |
|
|
@ -775,7 +778,7 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
|
|
|
|
|
|
|
private fun toExamVo(question:Question):ExamVo{ |
|
|
|
private fun toExamVo(question:Question):ExamVo{ |
|
|
|
return ExamVo(questionId = question.id.value,question=question.question,optionsA = question.optionsA, |
|
|
|
return ExamVo(questionId = question.id.value,question=question.question,optionsA = question.optionsA, |
|
|
|
optionsB = question.optionsB,optionsC = question.optionsC,optionsD = question.optionsD,answer = question.answer) |
|
|
|
optionsB = question.optionsB,optionsC = question.optionsC,optionsD = question.optionsD,rightOption = question.answer) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -798,37 +801,43 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun applyAnswer(vo:AddAnswerVo){ |
|
|
|
fun applyAnswer(vo:AddAnswerVo){ |
|
|
|
transaction { |
|
|
|
transaction { |
|
|
|
val association= Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
|
|
|
|
val user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
val user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val association=Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
|
|
|
|
val join=createJoin(association=association,user = user) |
|
|
|
|
|
|
|
|
|
|
|
vo.answers.forEach { |
|
|
|
vo.answers.forEach { |
|
|
|
val question=Question.findById(it.questionId)?:throw IllegalArgumentException("不存在[id=${it.questionId}]的问题") |
|
|
|
val id=it.examVo.questionId?:throw IllegalArgumentException("问题id不存在") |
|
|
|
val paper=TestPaper.findById(it.paperId)?:throw IllegalArgumentException("不存在[id=${it.paperId}]的问题") |
|
|
|
|
|
|
|
|
|
|
|
val question=Question.findById(id)?:throw IllegalArgumentException("不存在[id=${id}]的问题") |
|
|
|
|
|
|
|
|
|
|
|
Answer.new { |
|
|
|
Answer.new { |
|
|
|
this.question=question |
|
|
|
this.question=question |
|
|
|
answer=it.answer |
|
|
|
answer= it.answer |
|
|
|
this.paper=paper |
|
|
|
this.join=join |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
createJoin(association = association,user=user) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun toJoinVo(join:JoinAssociation):JoinAssociationVo{ |
|
|
|
|
|
|
|
val hasPaper=Answer.find { Answers.joinId eq join.id.value }.count()>0 |
|
|
|
|
|
|
|
return JoinAssociationVo(id=join.id.value,user = AccountService.toUserInfo(join.user), |
|
|
|
|
|
|
|
associationVo = toAssociationVo(join.association),hasPaper = hasPaper,result = join.result, |
|
|
|
|
|
|
|
applyTime = join.applyTime.toLong(),auditTime = join.auditTime?.toLong()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 显示答卷 |
|
|
|
* 显示答卷 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param vo |
|
|
|
* @param vo |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun showAnswer(vo:ShowAnswerVo):List<AnswerVo>{ |
|
|
|
fun showAnswer(vo:ShowAnswerVo):List<ApplyAnswerVo>{ |
|
|
|
return transaction { |
|
|
|
return transaction { |
|
|
|
val join=JoinAssociation.findById(vo.joinId)?:throw IllegalArgumentException("找不到[id=${vo.joinId}]申请记录") |
|
|
|
val join=JoinAssociation.findById(vo.joinId)?:throw IllegalArgumentException("找不到[id=${vo.joinId}]申请记录") |
|
|
|
val paperId= join.paper?.id?:throw IllegalArgumentException("[id=${join.id}]没有关联试卷") |
|
|
|
Answer.find{ Answers.joinId eq join.id }.map { |
|
|
|
val paper=TestPaper.findById(paperId)?:throw IllegalArgumentException("[id=${paperId}]关联的试卷不存在") |
|
|
|
ApplyAnswerVo(examVo = toExamVo(it.question),answer = it.answer) |
|
|
|
Answer.find { Answers.paperId eq paperId}.map { |
|
|
|
|
|
|
|
AnswerVo(examVo = toExamVo(it.question),answer = it.answer,paperVo = |
|
|
|
|
|
|
|
TestPaperVo(user = UserInfoVo(name=join.user.name,headImg = join.user.headImg?.filepath,desc=join.user.desc), |
|
|
|
|
|
|
|
createTime = paper.createTime.toLong(),applyTime = paper.applyTime?.toLong())) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -840,21 +849,10 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
* @param association |
|
|
|
* @param association |
|
|
|
* @param user |
|
|
|
* @param user |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun createJoin(association: Association,user:User){ |
|
|
|
private fun createJoin(association: Association,user:User):JoinAssociation{ |
|
|
|
JoinAssociation.new { |
|
|
|
return JoinAssociation.new { |
|
|
|
this.association=association |
|
|
|
this.association=association |
|
|
|
this.user=user |
|
|
|
this.user=user |
|
|
|
}.apply { |
|
|
|
|
|
|
|
//通知团长处理 |
|
|
|
|
|
|
|
AssociationMember.find { AssociationMembers.associationId eq association.id and |
|
|
|
|
|
|
|
(AssociationMembers.isHead eq true) }.firstOrNull()?.apply { |
|
|
|
|
|
|
|
Notification.new { |
|
|
|
|
|
|
|
this.title = "入团申请通知" |
|
|
|
|
|
|
|
this.content = "用户${user.name}申请加入社团" |
|
|
|
|
|
|
|
this.receiverId = user.id.value |
|
|
|
|
|
|
|
receiverClient = ClientType.Foreground.name |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -864,23 +862,11 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
* @param vo |
|
|
|
* @param vo |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun createPaper(vo:ApplyAssociationVo):List<ExamVo>{ |
|
|
|
fun createPaper(vo:SearchExamVo):List<ExamVo>{ |
|
|
|
return transaction { |
|
|
|
return transaction { |
|
|
|
val association= Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
val association= Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
val user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
|
|
|
|
Question.find { Questions.associationId eq association.id }.let { it -> |
|
|
|
Question.find { Questions.associationId eq association.id }.let { it -> |
|
|
|
val paper=TestPaper.new { |
|
|
|
it.shuffled().map { |
|
|
|
this.user=user |
|
|
|
|
|
|
|
this.applyTime= LocalDateTime.now() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
it.shuffled().apply { |
|
|
|
|
|
|
|
forEach { |
|
|
|
|
|
|
|
Answer.new { |
|
|
|
|
|
|
|
this.paper=paper |
|
|
|
|
|
|
|
this.question=it |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.map { |
|
|
|
|
|
|
|
toExamVo(question = it) |
|
|
|
toExamVo(question = it) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -888,11 +874,23 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun createJoinNotification(user:User, association:Association){ |
|
|
|
|
|
|
|
AssociationMember.find { AssociationMembers.associationId eq association.id and |
|
|
|
|
|
|
|
(AssociationMembers.isHead eq true) }.firstOrNull()?.apply { |
|
|
|
|
|
|
|
Notification.new { |
|
|
|
|
|
|
|
this.title = "入团申请通知" |
|
|
|
|
|
|
|
this.content = "用户${user.name}申请加入社团" |
|
|
|
|
|
|
|
this.receiverId = user.id.value |
|
|
|
|
|
|
|
receiverClient = ClientType.Foreground.name |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 申请入团 |
|
|
|
* 申请入团 |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun applyAssociation(vo:ApplyAssociationVo):ApplyAssociationResultVo{ |
|
|
|
fun applyAssociation(vo:SearchExamVo):ApplyAssociationResultVo{ |
|
|
|
return transaction { |
|
|
|
return transaction { |
|
|
|
val user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
val user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
val association= Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
val association= Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
@ -910,6 +908,7 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
//免试入团申请 |
|
|
|
//免试入团申请 |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
createJoin(association=association,user=user) |
|
|
|
createJoin(association=association,user=user) |
|
|
|
|
|
|
|
createJoinNotification(association=association,user=user) |
|
|
|
ApplyAssociationResultVo(result = true,hasPaper = false) |
|
|
|
ApplyAssociationResultVo(result = true,hasPaper = false) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -920,19 +919,11 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
* 入团申请记录 |
|
|
|
* 入团申请记录 |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun joinAssociation(vo:ApplyAssociationVo):List<JoinAssociationVo>{ |
|
|
|
fun joinAssociation(vo:SearchExamVo):List<JoinAssociationVo>{ |
|
|
|
return transaction { |
|
|
|
return transaction { |
|
|
|
val association=Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
val association=Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
val user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
JoinAssociation.find { JoinAssociations.associationId eq association.id }.sortedByDescending { it.applyTime }.map { |
|
|
|
|
|
|
|
toJoinVo(join=it) |
|
|
|
JoinAssociation.find { JoinAssociations.associationId eq association.id }.map { |
|
|
|
|
|
|
|
val userInfoVo=UserInfoVo(name = user.name,headImg = user.headImg?.filepath,desc=user.desc) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JoinAssociationVo(user = userInfoVo, |
|
|
|
|
|
|
|
associationVo = toAssociationVo(it.association), |
|
|
|
|
|
|
|
hasPaper = it.paper!=null,result = it.result, |
|
|
|
|
|
|
|
applyTime = it.applyTime.toLong(), |
|
|
|
|
|
|
|
auditTime = it.auditTime?.toLong(),id = it.id.value) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1001,7 +992,7 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
optionsB = exam.optionsB |
|
|
|
optionsB = exam.optionsB |
|
|
|
optionsC = exam.optionsC |
|
|
|
optionsC = exam.optionsC |
|
|
|
optionsD = exam.optionsD |
|
|
|
optionsD = exam.optionsD |
|
|
|
this.answer = exam.answer |
|
|
|
this.answer = exam.rightOption |
|
|
|
this.association = association |
|
|
|
this.association = association |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -1012,7 +1003,7 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
optionsB = exam.optionsB |
|
|
|
optionsB = exam.optionsB |
|
|
|
optionsC = exam.optionsC |
|
|
|
optionsC = exam.optionsC |
|
|
|
optionsD = exam.optionsD |
|
|
|
optionsD = exam.optionsD |
|
|
|
this.answer = exam.answer |
|
|
|
this.answer = exam.rightOption |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1286,7 +1277,7 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo, ActivityCheck |
|
|
|
return transaction { |
|
|
|
return transaction { |
|
|
|
ActivityComment.find { ActivityComments.activityId eq vo.activityId }.map { |
|
|
|
ActivityComment.find { ActivityComments.activityId eq vo.activityId }.map { |
|
|
|
BBSVo( |
|
|
|
BBSVo( |
|
|
|
user = UserInfoVo(name = it.user.name, headImg = it.user.headImg?.filepath, desc = it.user.desc), |
|
|
|
user = AccountService.toUserInfo(it.user), |
|
|
|
createTime = it.createTime.toLong(), content = it.content |
|
|
|
createTime = it.createTime.toLong(), content = it.content |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|