|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.gyf.csams |
|
|
|
package com.gyf.csams |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.gyf.csams.FileService.getFormParam |
|
|
|
import com.gyf.csams.module.* |
|
|
|
import com.gyf.csams.module.* |
|
|
|
import io.ktor.application.* |
|
|
|
import io.ktor.application.* |
|
|
|
import io.ktor.http.content.* |
|
|
|
import io.ktor.http.content.* |
|
|
@ -373,24 +374,26 @@ object FileService : AbstractService() { |
|
|
|
throw IllegalArgumentException("找不到key:${key}") |
|
|
|
throw IllegalArgumentException("找不到key:${key}") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun List<PartData>.getFormParam(key:String):String{ |
|
|
|
|
|
|
|
forEach { |
|
|
|
|
|
|
|
if(it.name==key && it is PartData.FormItem){ |
|
|
|
|
|
|
|
return it.value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
throw IllegalArgumentException("没有找到[key=${key}]的表单参数") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun storeFile(data: List<PartData>): List<Int>? { |
|
|
|
fun storeFile(data: List<PartData>): List<Int>? { |
|
|
|
val map = data.associateBy { |
|
|
|
val userId = data.getFormParam(key="id") |
|
|
|
it.name |
|
|
|
val token = data.getFormParam(key="token") |
|
|
|
}.toMutableMap() |
|
|
|
val createTime = data.getFormParam(key="createTime") |
|
|
|
log.info("map=${map}") |
|
|
|
|
|
|
|
val userId = getPartData<PartData.FormItem>(map, "id").value |
|
|
|
|
|
|
|
val token = getPartData<PartData.FormItem>(map, "token").value |
|
|
|
|
|
|
|
val createTime = getPartData<PartData.FormItem>(map, "createTime").value |
|
|
|
|
|
|
|
val tokenVo = Token(token = token, id = userId.toInt(), createTime = createTime.toLong()) |
|
|
|
val tokenVo = Token(token = token, id = userId.toInt(), createTime = createTime.toLong()) |
|
|
|
if (AccountService.validUserToken(tokenVo)) { |
|
|
|
if (AccountService.validUserToken(tokenVo)) { |
|
|
|
map.remove("id") |
|
|
|
|
|
|
|
map.remove("token") |
|
|
|
|
|
|
|
val fileIds = mutableListOf<Int>() |
|
|
|
val fileIds = mutableListOf<Int>() |
|
|
|
map.forEach { |
|
|
|
data.forEach { |
|
|
|
val value = it.value |
|
|
|
if (it is PartData.FileItem) { |
|
|
|
if (value is PartData.FileItem) { |
|
|
|
val fileBytes = it.streamProvider().readBytes() |
|
|
|
val fileBytes = value.streamProvider().readBytes() |
|
|
|
val fileName = it.originalFileName ?: throw IllegalArgumentException("参数异常") |
|
|
|
val fileName = value.originalFileName ?: throw IllegalArgumentException("参数异常") |
|
|
|
|
|
|
|
val format = fileBytes.getFormat() |
|
|
|
val format = fileBytes.getFormat() |
|
|
|
val fullFileName = "${fileName}.${format.format}" |
|
|
|
val fullFileName = "${fileName}.${format.format}" |
|
|
|
log.info("fullFileName=$fullFileName") |
|
|
|
log.info("fullFileName=$fullFileName") |
|
|
@ -573,7 +576,7 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
foreground( |
|
|
|
foreground( |
|
|
|
receiverId = matchUser.id.value, |
|
|
|
receiverId = matchUser.id.value, |
|
|
|
content = "您提交的【${entity.notificationName()}】${this@AuditService.dataType}初审不通过,可根据初审意见,重新申请\n" + |
|
|
|
content = "您提交的【${entity.notificationName()}】${this@AuditService.dataType}初审不通过,可根据初审意见,重新申请\n" + |
|
|
|
"【初审意见:${vo.cause},审核人:${entity.audit.manager?.desc ?: ""}】" |
|
|
|
"【初审意见:${vo.cause},审核人:${entity.audit.manager?.duty ?: ""}】" |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
entity.audit.nextAudit != null && vo.result -> { |
|
|
|
entity.audit.nextAudit != null && vo.result -> { |
|
|
@ -587,7 +590,7 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
foreground( |
|
|
|
foreground( |
|
|
|
receiverId = matchUser.id.value, |
|
|
|
receiverId = matchUser.id.value, |
|
|
|
content = "您提交的【${entity.notificationName()}】${this@AuditService.dataType}复审不通过,可根据复审意见,重新申请\n" + |
|
|
|
content = "您提交的【${entity.notificationName()}】${this@AuditService.dataType}复审不通过,可根据复审意见,重新申请\n" + |
|
|
|
"【复审意见:${vo.cause},审核人:${entity.audit.nextAudit?.manager?.desc ?: ""}】" |
|
|
|
"【复审意见:${vo.cause},审核人:${entity.audit.nextAudit?.manager?.duty ?: ""}】" |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -756,23 +759,12 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
val nextAudit = AuditLeggings.alias("nextAudit") |
|
|
|
val nextAudit = AuditLeggings.alias("nextAudit") |
|
|
|
return@transaction Associations.innerJoin(otherTable = AuditLeggings) |
|
|
|
return@transaction Associations.innerJoin(otherTable = AuditLeggings) |
|
|
|
.innerJoin(nextAudit, { AuditLeggings.nextAudit }, { nextAudit[AuditLeggings.id] }) |
|
|
|
.innerJoin(nextAudit, { AuditLeggings.nextAudit }, { nextAudit[AuditLeggings.id] }) |
|
|
|
.slice(Associations.columns) |
|
|
|
.slice(listOf(Associations.id)) |
|
|
|
.select { |
|
|
|
.select { |
|
|
|
nextAudit[AuditLeggings.result] eq true and (Associations.name like "%${vo.name}%") and (Associations.desc like "%${vo.desc}%") |
|
|
|
nextAudit[AuditLeggings.result] eq true and (Associations.name like "%${vo.name}%") and (Associations.desc like "%${vo.desc}%") |
|
|
|
}.map { |
|
|
|
}.map { |
|
|
|
val imageFile = |
|
|
|
val association=Association.findById(it[Associations.id])?:throw AssociationIdError(it[Associations.id].value) |
|
|
|
ImageFile.findById(it[Associations.logo]) ?: throw FileIdError(it[Associations.logo].value) |
|
|
|
toAssociationVo(association) |
|
|
|
|
|
|
|
|
|
|
|
AssociationVo(name = it[Associations.name], |
|
|
|
|
|
|
|
associationId = it[Associations.id].value, |
|
|
|
|
|
|
|
logo = imageFile.filepath, |
|
|
|
|
|
|
|
desc = it[Associations.desc], |
|
|
|
|
|
|
|
faculty = it[Associations.faculty].let { it1 -> |
|
|
|
|
|
|
|
AssociationFaculty.valueOf( |
|
|
|
|
|
|
|
it1 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
level = it[Associations.level]?.let { it1 -> AssociationLevel.valueOf(it1) }) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -893,6 +885,110 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo,ActivityCheckV |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 上传照片 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun upload(data: List<PartData>){ |
|
|
|
|
|
|
|
val activityId=data.getFormParam("activityId") |
|
|
|
|
|
|
|
val name=data.getFormParam("name") |
|
|
|
|
|
|
|
transaction { |
|
|
|
|
|
|
|
(Activity.findById(activityId.toInt())?:throw IllegalArgumentException("活动id参数有误:${activityId}")).apply { |
|
|
|
|
|
|
|
val fileId=FileService.storeFile(data) |
|
|
|
|
|
|
|
//保存到相册 |
|
|
|
|
|
|
|
fileId?.forEach { |
|
|
|
|
|
|
|
PhotoAlbum.new { |
|
|
|
|
|
|
|
activity=this@apply |
|
|
|
|
|
|
|
photo=ImageFile.findById(it)?:throw FileIdError(it) |
|
|
|
|
|
|
|
this.name=name |
|
|
|
|
|
|
|
}.let { |
|
|
|
|
|
|
|
log.info("保存照片:${it.name}") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 发送评论 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param vo |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun sendComment(vo:SendBBSVo){ |
|
|
|
|
|
|
|
transaction { |
|
|
|
|
|
|
|
ActivityComment.new { |
|
|
|
|
|
|
|
content=vo.content |
|
|
|
|
|
|
|
user=User.findById(vo.token.id)?:throw UserIdError(vo.token.id) |
|
|
|
|
|
|
|
activity=Activity.findById(vo.activityId)?:throw ActivityIdError(vo.activityId) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 加载评论 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param vo |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun loadComment(vo: SearchCommentVo):List<BBSVo>{ |
|
|
|
|
|
|
|
return transaction { |
|
|
|
|
|
|
|
ActivityComment.find { ActivityComments.activityId eq vo.activityId }.map { |
|
|
|
|
|
|
|
BBSVo(user = UserInfoVo(name=it.user.name,headImg = it.user.headImg?.filepath,desc = it.user.desc), |
|
|
|
|
|
|
|
createTime = it.createTime.toLong(),content = it.content) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 加载活动照片 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param vo |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun load(vo:SearchActivityPhotoVo):List<ActivityPhotoVo>{ |
|
|
|
|
|
|
|
return transaction { |
|
|
|
|
|
|
|
PhotoAlbum.find { PhotoAlbums.activityId eq vo.activityId }.map { |
|
|
|
|
|
|
|
ActivityPhotoVo(name = it.name,url=it.photo.filepath) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 活动列表 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun load(vo:SearchActivityVo):List<ActivityVo>{ |
|
|
|
|
|
|
|
return transaction { |
|
|
|
|
|
|
|
val nextAudit = AuditLeggings.alias("nextAudit") |
|
|
|
|
|
|
|
return@transaction Activities.innerJoin(otherTable = AuditLeggings) |
|
|
|
|
|
|
|
.innerJoin(nextAudit, { AuditLeggings.nextAudit }, { nextAudit[AuditLeggings.id] }) |
|
|
|
|
|
|
|
.slice(listOf(Activities.id)) |
|
|
|
|
|
|
|
.select { |
|
|
|
|
|
|
|
nextAudit[AuditLeggings.result] eq true and (Activities.associationId eq vo.associationId) |
|
|
|
|
|
|
|
}.map { |
|
|
|
|
|
|
|
val activity=Activity.findById(it[Activities.id])?:throw ActivityIdError(it[Activities.id].value) |
|
|
|
|
|
|
|
toActivityVo(activity = activity) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 活动详情 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param vo |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun show(vo:ShowActivityVo):ActivityDetailVo{ |
|
|
|
|
|
|
|
return transaction { |
|
|
|
|
|
|
|
(Activity.findById(vo.activityId)?:throw ActivityIdError(vo.activityId)).let { |
|
|
|
|
|
|
|
ActivityDetailVo(activityVo = toActivityVo(it),associationVo = AssociationService.toAssociationVo(it.association)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun read(vo: OnlyToken, table: IntIdTable): ActivityCheckVo? { |
|
|
|
override fun read(vo: OnlyToken, table: IntIdTable): ActivityCheckVo? { |
|
|
|
val nextAudit = AuditLeggings.alias("nextAudit") |
|
|
|
val nextAudit = AuditLeggings.alias("nextAudit") |
|
|
|
return transaction { |
|
|
|
return transaction { |
|
|
@ -916,10 +1012,10 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo,ActivityCheckV |
|
|
|
transaction { |
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
if (vo.activityId != null) { |
|
|
|
if (vo.activityVo.activityId != null) { |
|
|
|
//再次提交 |
|
|
|
//再次提交 |
|
|
|
log.info("再次提交【${vo.activityVo.activityName}】${dataType}") |
|
|
|
log.info("再次提交【${vo.activityVo.activityName}】${dataType}") |
|
|
|
val activity = Activity.findById(vo.activityId!!) ?: throw ActivityIdError(vo.activityId!!) |
|
|
|
val activity = Activity.findById(vo.activityVo.activityId!!) ?: throw ActivityIdError(vo.activityVo.activityId!!) |
|
|
|
activity.apply { |
|
|
|
activity.apply { |
|
|
|
activityName = vo.activityVo.activityName |
|
|
|
activityName = vo.activityVo.activityName |
|
|
|
activityTime = vo.activityVo.activityTime.toLocalDateTime() |
|
|
|
activityTime = vo.activityVo.activityTime.toLocalDateTime() |
|
|
@ -963,7 +1059,8 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo,ActivityCheckV |
|
|
|
return ActivityVo( |
|
|
|
return ActivityVo( |
|
|
|
activityName = activity.activityName, activityTime = activity.activityTime.toLong(), |
|
|
|
activityName = activity.activityName, activityTime = activity.activityTime.toLong(), |
|
|
|
activityAddress = activity.activityAddress, activityDesc = activity.activityDesc, |
|
|
|
activityAddress = activity.activityAddress, activityDesc = activity.activityDesc, |
|
|
|
activitySize = activity.activitySize |
|
|
|
activitySize = activity.activitySize, |
|
|
|
|
|
|
|
activityId = activity.id.value |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1059,7 +1156,7 @@ object NotificationService : AbstractService() { |
|
|
|
return@transaction Notification.find { |
|
|
|
return@transaction Notification.find { |
|
|
|
(Notifications.receiverId eq vo.receiverId) and |
|
|
|
(Notifications.receiverId eq vo.receiverId) and |
|
|
|
(Notifications.receiverClient eq vo.receiverClient.name) |
|
|
|
(Notifications.receiverClient eq vo.receiverClient.name) |
|
|
|
}.map { |
|
|
|
}.sortedByDescending { it.createTime }.map { |
|
|
|
NotificationVo( |
|
|
|
NotificationVo( |
|
|
|
title = it.title, |
|
|
|
title = it.title, |
|
|
|
id = it.id.value, |
|
|
|
id = it.id.value, |
|
|
|