|
|
|
@ -44,7 +44,7 @@ object AccountService : AbstractService() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun toUserInfo(user: User):UserInfoVo{ |
|
|
|
|
fun toUserInfo(user: User): UserInfoVo { |
|
|
|
|
return UserInfoVo(name = user.name, headImg = user.headImg?.filepath, desc = user.desc) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -55,7 +55,7 @@ object AccountService : AbstractService() { |
|
|
|
|
try { |
|
|
|
|
return transaction { |
|
|
|
|
|
|
|
|
|
val originPassword = if(environment.developmentMode) (1..8).joinToString("") else randomNum(8) |
|
|
|
|
val originPassword = if (environment.developmentMode) (1..8).joinToString("") else randomNum(8) |
|
|
|
|
log.info("密码:${originPassword}") |
|
|
|
|
User.new { |
|
|
|
|
studentId = userVo.studentId |
|
|
|
@ -156,15 +156,15 @@ object AccountService : AbstractService() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun uploadHeadImg(data: List<PartData>){ |
|
|
|
|
val userId=data.getFormParam("id").toInt() |
|
|
|
|
fun uploadHeadImg(data: List<PartData>) { |
|
|
|
|
val userId = data.getFormParam("id").toInt() |
|
|
|
|
transaction { |
|
|
|
|
val fileIds =FileService.storeFile(data) |
|
|
|
|
if(fileIds?.isNotEmpty()==true){ |
|
|
|
|
val fileId=fileIds.first() |
|
|
|
|
val user=User.findById(userId)?:throw UserIdError(userId) |
|
|
|
|
val fileIds = FileService.storeFile(data) |
|
|
|
|
if (fileIds?.isNotEmpty() == true) { |
|
|
|
|
val fileId = fileIds.first() |
|
|
|
|
val user = User.findById(userId) ?: throw UserIdError(userId) |
|
|
|
|
user.apply { |
|
|
|
|
headImg=ImageFile.findById(fileId)?:throw FileIdError(fileId) |
|
|
|
|
headImg = ImageFile.findById(fileId) ?: throw FileIdError(fileId) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -172,34 +172,34 @@ object AccountService : AbstractService() { |
|
|
|
|
|
|
|
|
|
fun refreshInfo(vo: InfoUpdateVo): PersonInfoVo { |
|
|
|
|
return transaction { |
|
|
|
|
when(vo.clientType){ |
|
|
|
|
ClientType.Foreground->{ |
|
|
|
|
when (vo.clientType) { |
|
|
|
|
ClientType.Foreground -> { |
|
|
|
|
val matchUser = User.findById(vo.token.id) ?: throw UserIdError(vo.token.id) |
|
|
|
|
matchUser.apply { |
|
|
|
|
vo.name?.let { |
|
|
|
|
matchUser.name=it |
|
|
|
|
matchUser.name = it |
|
|
|
|
} |
|
|
|
|
vo.desc?.let { |
|
|
|
|
matchUser.desc=it |
|
|
|
|
matchUser.desc = it |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
val token = UserToken.find { UserTokens.userId eq matchUser.id }.firstOrNull() |
|
|
|
|
?: throw IllegalArgumentException("无法根据[userId=${matchUser.id}]找到token") |
|
|
|
|
tokenRes(token=token,matchUser = matchUser) |
|
|
|
|
tokenRes(token = token, matchUser = matchUser) |
|
|
|
|
} |
|
|
|
|
ClientType.Background->{ |
|
|
|
|
val matchManager = Manager.findById(vo.token.id)?:throw ManagerIdError(vo.token.id) |
|
|
|
|
ClientType.Background -> { |
|
|
|
|
val matchManager = Manager.findById(vo.token.id) ?: throw ManagerIdError(vo.token.id) |
|
|
|
|
matchManager.apply { |
|
|
|
|
vo.name?.let { |
|
|
|
|
matchManager.name=it |
|
|
|
|
matchManager.name = it |
|
|
|
|
} |
|
|
|
|
vo.desc?.let { |
|
|
|
|
matchManager.desc=it |
|
|
|
|
matchManager.desc = it |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
val token=ManagerToken.find { ManagerTokens.managerId eq matchManager.id }.firstOrNull() |
|
|
|
|
val token = ManagerToken.find { ManagerTokens.managerId eq matchManager.id }.firstOrNull() |
|
|
|
|
?: throw IllegalArgumentException("无法根据[matchId=${matchManager.id}]找到token") |
|
|
|
|
tokenRes(token=token,matchManager=matchManager) |
|
|
|
|
tokenRes(token = token, matchManager = matchManager) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -658,19 +658,23 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
return transaction { |
|
|
|
|
if (isFilter) { |
|
|
|
|
// val nextAudit = AuditLeggings.alias("nextAudit") |
|
|
|
|
val c=table.innerJoin(AuditLeggings) |
|
|
|
|
val c = table.innerJoin(AuditLeggings) |
|
|
|
|
// .innerJoin(nextAudit, { AuditLeggings.nextAudit }, { nextAudit[AuditLeggings.id] }) |
|
|
|
|
.innerJoin(Users) |
|
|
|
|
.slice(listOf(table.id,AuditLeggings.result,AuditLeggings.nextAudit)) |
|
|
|
|
.select { Users.id eq vo.token.id} |
|
|
|
|
.slice(listOf(table.id, AuditLeggings.result, AuditLeggings.nextAudit)) |
|
|
|
|
.select { Users.id eq vo.token.id } |
|
|
|
|
.filter { |
|
|
|
|
log.info("it[AuditLeggings.result]=${it[AuditLeggings.result]},it[AuditLeggings.nextAudit]=${it[AuditLeggings.nextAudit]}") |
|
|
|
|
it[AuditLeggings.result]==null|| it[AuditLeggings.nextAudit]?.let { it1 -> AuditLogging.findById(it1)?.result } ==null |
|
|
|
|
it[AuditLeggings.result] == null || it[AuditLeggings.nextAudit]?.let { it1 -> |
|
|
|
|
AuditLogging.findById( |
|
|
|
|
it1 |
|
|
|
|
)?.result |
|
|
|
|
} == null |
|
|
|
|
} |
|
|
|
|
log.info("size:${c.size}") |
|
|
|
|
if(c.size==1){ |
|
|
|
|
if (c.size == 1) { |
|
|
|
|
getCheckVo(c.first()[table.id]) |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
null |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -809,9 +813,16 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun toExamVo(question:Question):ExamVo{ |
|
|
|
|
return ExamVo(questionId = question.id.value,question=question.question,optionsA = question.optionsA, |
|
|
|
|
optionsB = question.optionsB,optionsC = question.optionsC,optionsD = question.optionsD,rightOption = question.answer) |
|
|
|
|
private fun toExamVo(question: Question): ExamVo { |
|
|
|
|
return ExamVo( |
|
|
|
|
questionId = question.id.value, |
|
|
|
|
question = question.question, |
|
|
|
|
optionsA = question.optionsA, |
|
|
|
|
optionsB = question.optionsB, |
|
|
|
|
optionsC = question.optionsC, |
|
|
|
|
optionsD = question.optionsD, |
|
|
|
|
rightOption = question.answer |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -820,7 +831,7 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
* @param vo |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
fun loadExam(vo:SearchExamVo):List<ExamVo>{ |
|
|
|
|
fun loadExam(vo: SearchExamVo): List<ExamVo> { |
|
|
|
|
return transaction { |
|
|
|
|
Question.find { Questions.associationId eq vo.associationId }.map { |
|
|
|
|
toExamVo(question = it) |
|
|
|
@ -832,32 +843,34 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
* 提交答卷 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
fun applyAnswer(vo:AddAnswerVo){ |
|
|
|
|
fun applyAnswer(vo: AddAnswerVo) { |
|
|
|
|
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 join=createJoin(association=association,user = user) |
|
|
|
|
val association = Association.findById(vo.associationId) ?: throw AssociationIdError(vo.associationId) |
|
|
|
|
val join = createJoin(association = association, user = user) |
|
|
|
|
|
|
|
|
|
vo.answers.forEach { |
|
|
|
|
val id=it.examVo.questionId?:throw IllegalArgumentException("问题id不存在") |
|
|
|
|
val id = it.examVo.questionId ?: throw IllegalArgumentException("问题id不存在") |
|
|
|
|
|
|
|
|
|
val question=Question.findById(id)?:throw IllegalArgumentException("不存在[id=${id}]的问题") |
|
|
|
|
val question = Question.findById(id) ?: throw IllegalArgumentException("不存在[id=${id}]的问题") |
|
|
|
|
|
|
|
|
|
Answer.new { |
|
|
|
|
this.question=question |
|
|
|
|
answer= it.answer |
|
|
|
|
this.join=join |
|
|
|
|
this.question = question |
|
|
|
|
answer = it.answer |
|
|
|
|
this.join = join |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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()) |
|
|
|
|
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() |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -866,11 +879,11 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
* @param vo |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
fun showAnswer(vo:ShowAnswerVo):List<ApplyAnswerVo>{ |
|
|
|
|
fun showAnswer(vo: ShowAnswerVo): List<ApplyAnswerVo> { |
|
|
|
|
return transaction { |
|
|
|
|
val join=JoinAssociation.findById(vo.joinId)?:throw IllegalArgumentException("找不到[id=${vo.joinId}]申请记录") |
|
|
|
|
Answer.find{ Answers.joinId eq join.id }.map { |
|
|
|
|
ApplyAnswerVo(examVo = toExamVo(it.question),answer = it.answer) |
|
|
|
|
val join = JoinAssociation.findById(vo.joinId) ?: throw IllegalArgumentException("找不到[id=${vo.joinId}]申请记录") |
|
|
|
|
Answer.find { Answers.joinId eq join.id }.map { |
|
|
|
|
ApplyAnswerVo(examVo = toExamVo(it.question), answer = it.answer) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -882,10 +895,10 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
* @param association |
|
|
|
|
* @param user |
|
|
|
|
*/ |
|
|
|
|
private fun createJoin(association: Association,user:User):JoinAssociation{ |
|
|
|
|
private fun createJoin(association: Association, user: User): JoinAssociation { |
|
|
|
|
return JoinAssociation.new { |
|
|
|
|
this.association=association |
|
|
|
|
this.user=user |
|
|
|
|
this.association = association |
|
|
|
|
this.user = user |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -895,9 +908,9 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
* @param vo |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
fun createPaper(vo:SearchExamVo):List<ExamVo>{ |
|
|
|
|
fun createPaper(vo: SearchExamVo): List<ExamVo> { |
|
|
|
|
return transaction { |
|
|
|
|
val association= Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
|
val association = Association.findById(vo.associationId) ?: throw AssociationIdError(vo.associationId) |
|
|
|
|
Question.find { Questions.associationId eq association.id }.let { it -> |
|
|
|
|
it.shuffled().map { |
|
|
|
|
toExamVo(question = it) |
|
|
|
@ -907,9 +920,11 @@ 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 { |
|
|
|
|
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}申请加入社团" |
|
|
|
@ -923,26 +938,27 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
* 申请入团 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
fun applyAssociation(vo:SearchExamVo):ApplyAssociationResultVo{ |
|
|
|
|
fun applyAssociation(vo: SearchExamVo): ApplyAssociationResultVo { |
|
|
|
|
return transaction { |
|
|
|
|
val user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
|
val association= Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
|
JoinAssociation.find { JoinAssociations.userId eq vo.token.id and (JoinAssociations.result eq null) }.firstOrNull().let { |
|
|
|
|
if(it!=null){ |
|
|
|
|
val user = User.findById(vo.token.id) ?: throw UserIdError(vo.token.id) |
|
|
|
|
val association = Association.findById(vo.associationId) ?: throw AssociationIdError(vo.associationId) |
|
|
|
|
JoinAssociation.find { JoinAssociations.userId eq vo.token.id and (JoinAssociations.result eq null) } |
|
|
|
|
.firstOrNull().let { |
|
|
|
|
if (it != null) { |
|
|
|
|
return@transaction ApplyAssociationResultVo(associationVo = toAssociationVo(it.association)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Question.find { Questions.associationId eq association.id }.let { it -> |
|
|
|
|
//题库需要满足最少题目数才能生成试卷 |
|
|
|
|
if(it.count()>=QUESTION_MIN_SIZE){ |
|
|
|
|
ApplyAssociationResultVo(result = true,hasPaper = true) |
|
|
|
|
if (it.count() >= QUESTION_MIN_SIZE) { |
|
|
|
|
ApplyAssociationResultVo(result = true, hasPaper = true) |
|
|
|
|
} |
|
|
|
|
//免试入团申请 |
|
|
|
|
else{ |
|
|
|
|
createJoin(association=association,user=user) |
|
|
|
|
createJoinNotification(association=association,user=user) |
|
|
|
|
ApplyAssociationResultVo(result = true,hasPaper = false) |
|
|
|
|
else { |
|
|
|
|
createJoin(association = association, user = user) |
|
|
|
|
createJoinNotification(association = association, user = user) |
|
|
|
|
ApplyAssociationResultVo(result = true, hasPaper = false) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -952,11 +968,12 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
* 入团申请记录 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
fun joinAssociation(vo:SearchExamVo):List<JoinAssociationVo>{ |
|
|
|
|
fun joinAssociation(vo: SearchExamVo): List<JoinAssociationVo> { |
|
|
|
|
return transaction { |
|
|
|
|
val association=Association.findById(vo.associationId)?:throw AssociationIdError(vo.associationId) |
|
|
|
|
JoinAssociation.find { JoinAssociations.associationId eq association.id }.sortedByDescending { it.applyTime }.map { |
|
|
|
|
toJoinVo(join=it) |
|
|
|
|
val association = Association.findById(vo.associationId) ?: throw AssociationIdError(vo.associationId) |
|
|
|
|
JoinAssociation.find { JoinAssociations.associationId eq association.id } |
|
|
|
|
.sortedByDescending { it.applyTime }.map { |
|
|
|
|
toJoinVo(join = it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -965,16 +982,16 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
* 审核入团申请 |
|
|
|
|
* @param vo |
|
|
|
|
*/ |
|
|
|
|
fun auditJoin(vo:AuditJoinVo){ |
|
|
|
|
fun auditJoin(vo: AuditJoinVo) { |
|
|
|
|
transaction { |
|
|
|
|
val join=JoinAssociation.findById(vo.joinId)?:throw IllegalArgumentException("审核记录不存在") |
|
|
|
|
join.result=vo.result |
|
|
|
|
join.auditTime= LocalDateTime.now() |
|
|
|
|
if(vo.result){ |
|
|
|
|
val join = JoinAssociation.findById(vo.joinId) ?: throw IllegalArgumentException("审核记录不存在") |
|
|
|
|
join.result = vo.result |
|
|
|
|
join.auditTime = LocalDateTime.now() |
|
|
|
|
if (vo.result) { |
|
|
|
|
AssociationMember.new { |
|
|
|
|
user=join.user |
|
|
|
|
association=join.association |
|
|
|
|
isHead=false |
|
|
|
|
user = join.user |
|
|
|
|
association = join.association |
|
|
|
|
isHead = false |
|
|
|
|
} |
|
|
|
|
//入团申请通过,通知社团其他人 |
|
|
|
|
AssociationMember.find { AssociationMembers.associationId eq join.association.id }.forEach { |
|
|
|
@ -989,11 +1006,11 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//把审核结果发送给申请人 |
|
|
|
|
Notification.new{ |
|
|
|
|
this.title="入团审核结果" |
|
|
|
|
this.content="您申请加入${join.association.name}社团审核${if(vo.result)"通过" else "不通过"}" |
|
|
|
|
this.receiverId=join.user.id.value |
|
|
|
|
receiverClient=ClientType.Foreground.name |
|
|
|
|
Notification.new { |
|
|
|
|
this.title = "入团审核结果" |
|
|
|
|
this.content = "您申请加入${join.association.name}社团审核${if (vo.result) "通过" else "不通过"}" |
|
|
|
|
this.receiverId = join.user.id.value |
|
|
|
|
receiverClient = ClientType.Foreground.name |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1005,18 +1022,17 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
*/ |
|
|
|
|
fun updateExam(vo: AddExamVo) { |
|
|
|
|
transaction { |
|
|
|
|
val association=Association.findById(vo.associationId)?:throw IllegalArgumentException("找不到社团信息") |
|
|
|
|
val association = Association.findById(vo.associationId) ?: throw IllegalArgumentException("找不到社团信息") |
|
|
|
|
|
|
|
|
|
vo.deleteIds?.let { |
|
|
|
|
//删除社团题目 |
|
|
|
|
Question.find { Questions.associationId eq association.id and (Questions.id inList it ) }.forEach { |
|
|
|
|
Question.find { Questions.associationId eq association.id and (Questions.id inList it) }.forEach { |
|
|
|
|
log.info("删除[id=${it.id}]题目") |
|
|
|
|
it.delete() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vo.questions.forEach { |
|
|
|
|
exam-> |
|
|
|
|
vo.questions.forEach { exam -> |
|
|
|
|
exam.questionId.let { |
|
|
|
|
if (it == null) { |
|
|
|
|
Question.new { |
|
|
|
@ -1228,6 +1244,52 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo, ActivityCheck |
|
|
|
|
return testFind(Activities, Activity, auditId) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun checkTendency(userId:Int, activityId:Int, type:TendencyType): SizedIterable<Tendency> { |
|
|
|
|
val user=User.findById(userId)?:throw UserIdError(userId) |
|
|
|
|
val activity=Activity.findById(activityId)?:throw ActivityIdError(activityId) |
|
|
|
|
return Tendency.find { Tendencies.userId eq user.id and (Tendencies.activityId eq activity.id) and |
|
|
|
|
(Tendencies.type eq type.ordinal) } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun checkTendency(vo: CheckTendencyVo):CheckTendencyResVo{ |
|
|
|
|
return transaction { |
|
|
|
|
val hasLike= checkTendency(userId = vo.token.id,activityId = vo.activityId,type = TendencyType.Like).count()==1L |
|
|
|
|
val hasCollect=checkTendency(userId = vo.token.id,activityId = vo.activityId,type = TendencyType.Collect).count()==1L |
|
|
|
|
CheckTendencyResVo(hasLike=hasLike,hasCollect=hasCollect) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun findTendency(vo:FindTendencyVo):List<ActivityVo>{ |
|
|
|
|
return transaction { |
|
|
|
|
val user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
|
Tendency.find { Tendencies.userId eq user.id and (Tendencies.type eq vo.type.ordinal) }.map { |
|
|
|
|
toActivityVo(activity = it.activity) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 活动倾向 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
fun tendency(vo: TendencyVo) { |
|
|
|
|
transaction { |
|
|
|
|
checkTendency(userId = vo.token.id,activityId = vo.activityId,type = vo.type).apply { |
|
|
|
|
if (count() == 1L) { |
|
|
|
|
first().delete() |
|
|
|
|
} else { |
|
|
|
|
Tendency.new { |
|
|
|
|
this.user= User[vo.token.id] |
|
|
|
|
this.activity= Activity[vo.activityId] |
|
|
|
|
this.type=vo.type.ordinal |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查看活动信息 |
|
|
|
|
* |
|
|
|
|