|
|
|
@ -6,6 +6,7 @@ import com.gyf.csams.module.* |
|
|
|
|
import io.ktor.application.* |
|
|
|
|
import io.ktor.http.content.* |
|
|
|
|
import io.ktor.util.* |
|
|
|
|
import org.jetbrains.exposed.dao.IntEntityClass |
|
|
|
|
import org.jetbrains.exposed.dao.id.EntityID |
|
|
|
|
import org.jetbrains.exposed.dao.id.IntIdTable |
|
|
|
|
import org.jetbrains.exposed.sql.* |
|
|
|
@ -46,16 +47,16 @@ object AccountService : AbstractService() { |
|
|
|
|
/** |
|
|
|
|
* 注册 |
|
|
|
|
*/ |
|
|
|
|
fun register(userVo: UserRegVo): UserResDto? { |
|
|
|
|
fun register(userVo: UserRegVo): String? { |
|
|
|
|
try { |
|
|
|
|
return transaction { |
|
|
|
|
val originPassword = if (environment.developmentMode) "12345678" else randomNum(8) |
|
|
|
|
val originPassword = randomNum(8) |
|
|
|
|
User.new { |
|
|
|
|
studentId = userVo.studentId |
|
|
|
|
name = userVo.name |
|
|
|
|
password = originPassword.md5() |
|
|
|
|
} |
|
|
|
|
return@transaction UserResDto(password = originPassword) |
|
|
|
|
return@transaction originPassword |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
log.error("注册失败,发生异常:$e") |
|
|
|
@ -248,10 +249,10 @@ object AccountService : AbstractService() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun <T : ClientBaseVo> validToken(vo: T): Boolean { |
|
|
|
|
return if (vo.clientType == ClientType.Foreground) { |
|
|
|
|
validUserToken(vo.token) |
|
|
|
|
} else { |
|
|
|
|
validManagerToken(vo.token) |
|
|
|
|
return when(vo.clientType){ |
|
|
|
|
ClientType.Foreground->validUserToken(vo.token) |
|
|
|
|
ClientType.Background-> validManagerToken(vo.token) |
|
|
|
|
else->throw IllegalArgumentException("不清楚是来自哪个平台的token信息") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -438,7 +439,7 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
* @param receiverId |
|
|
|
|
* @param content |
|
|
|
|
*/ |
|
|
|
|
protected fun foreground(receiverId: Int, content: String) { |
|
|
|
|
private fun foreground(receiverId: Int, content: String) { |
|
|
|
|
Notification.new { |
|
|
|
|
this.title = dataType |
|
|
|
|
this.content = content |
|
|
|
@ -454,7 +455,7 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
* 前台任务通知管理员处理 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
protected fun background(content: String, duty: Duty) { |
|
|
|
|
private fun background(content: String, duty: Duty) { |
|
|
|
|
Manager.find { Managers.duty eq duty.name }.apply { |
|
|
|
|
if (count() == 0L) { |
|
|
|
|
log.warn("找不到适当的${duty.desc}处理此任务") |
|
|
|
@ -481,6 +482,10 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
*/ |
|
|
|
|
abstract fun findEntity(auditId: Int): AbstractAudit |
|
|
|
|
|
|
|
|
|
protected inline fun <reified E:AbstractAudit,reified Row:IntEntityClass<E>,reified Table:AbstractAudits> testFind(table:Table,row:Row,auditId: Int): E { |
|
|
|
|
return row.find { table.auditId eq auditId } .firstOrNull() ?: throw AuditIdError(auditId) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 更新审核结果 |
|
|
|
|
* |
|
|
|
@ -508,7 +513,7 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
* 通过审核后 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
protected abstract fun afterAudit(entity: AbstractAudit) |
|
|
|
|
protected open fun afterAudit(entity: AbstractAudit){} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 资料受理 |
|
|
|
@ -602,19 +607,36 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//过滤完成的审核记录?(可多次提交的资料) |
|
|
|
|
open val isFilter:Boolean=true |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 审核进度查询 |
|
|
|
|
* TODO 审核进度查询 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
open fun read(vo: OnlyToken, table: IntIdTable): F? { |
|
|
|
|
fun read(vo: OnlyToken, table: IntIdTable): F? { |
|
|
|
|
return transaction { |
|
|
|
|
table.innerJoin(AuditLeggings).innerJoin(Users) |
|
|
|
|
.slice(listOf(table.id)) |
|
|
|
|
.select {Users.id eq vo.token.id} |
|
|
|
|
.firstOrNull() |
|
|
|
|
?.let { it -> |
|
|
|
|
getCheckVo(id = it[table.id]) |
|
|
|
|
} |
|
|
|
|
if(isFilter){ |
|
|
|
|
val nextAudit = AuditLeggings.alias("nextAudit") |
|
|
|
|
table.innerJoin(AuditLeggings) |
|
|
|
|
.innerJoin(nextAudit, { AuditLeggings.nextAudit }, { nextAudit[AuditLeggings.id] }) |
|
|
|
|
.innerJoin(Users) |
|
|
|
|
.slice(listOf(table.id)) |
|
|
|
|
.select {Users.id eq vo.token.id and (nextAudit[AuditLeggings.result] neq true)} |
|
|
|
|
.firstOrNull() |
|
|
|
|
?.let { it -> |
|
|
|
|
getCheckVo(id = it[table.id]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
table.innerJoin(AuditLeggings).innerJoin(Users) |
|
|
|
|
.slice(listOf(table.id)) |
|
|
|
|
.select { Users.id eq vo.token.id } |
|
|
|
|
.firstOrNull() |
|
|
|
|
?.let { it -> |
|
|
|
|
getCheckVo(id = it[table.id]) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -625,7 +647,7 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
return AuditCheckVo( |
|
|
|
|
checkStatus = when { |
|
|
|
|
audit.nextAudit == null && audit.manager == null -> CheckStatus.WaitFirst |
|
|
|
|
audit.nextAudit == null && audit.manager != null -> CheckStatus.AcceptFirst |
|
|
|
|
audit.nextAudit == null && audit.manager != null && audit.result==null -> CheckStatus.AcceptFirst |
|
|
|
|
audit.nextAudit != null && audit.nextAudit?.manager == null -> CheckStatus.WaitLast |
|
|
|
|
audit.nextAudit != null && audit.nextAudit?.result == null -> CheckStatus.AcceptLast |
|
|
|
|
else -> CheckStatus.Finish |
|
|
|
@ -647,6 +669,19 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
abstract fun audit(vo: OnlyToken): List<E> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected fun <T : AbstractAudit> createSortedBy(table: IntEntityClass<T>): List<T> { |
|
|
|
|
return table.all().sortedBy { |
|
|
|
|
//按初审受理>等待复审>复审受理>完成审核 排序 |
|
|
|
|
when { |
|
|
|
|
it.audit.nextAudit == null && it.audit.manager == null -> 1 |
|
|
|
|
it.audit.nextAudit == null && it.audit.manager != null -> 2 |
|
|
|
|
it.audit.nextAudit != null && it.audit.nextAudit?.manager == null -> 3 |
|
|
|
|
it.audit.nextAudit != null && it.audit.nextAudit?.result == null -> 4 |
|
|
|
|
else -> 5 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun toAuditLoggingVo(it: AuditLogging?): AuditLoggingVo? { |
|
|
|
|
return it?.let { logging -> |
|
|
|
|
val auditLogging = AuditLoggingVo( |
|
|
|
@ -671,6 +706,17 @@ abstract class AuditService<T, E, F> : AbstractService() { |
|
|
|
|
auditLogging |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun createNotifications(vo:ClientBaseVo,user:User){ |
|
|
|
|
foreground( |
|
|
|
|
receiverId = vo.token.id, |
|
|
|
|
content = "您成功提交了一份${dataType},请耐心等待后台受理" |
|
|
|
|
) |
|
|
|
|
background( |
|
|
|
|
content = "用户${user.name}提交了一份${dataType}需要您进行受理", |
|
|
|
|
duty = Duty.PamphaBhusal |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -681,11 +727,12 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
override val dataType: String = "社团注册资料" |
|
|
|
|
|
|
|
|
|
override fun findEntity(auditId: Int): AbstractAudit { |
|
|
|
|
return Association.find { Associations.auditId eq auditId }.firstOrNull() ?: throw AuditIdError(auditId) |
|
|
|
|
return testFind(Associations,Association,auditId) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun afterAudit(entity: AbstractAudit) { |
|
|
|
|
override val isFilter: Boolean = false |
|
|
|
|
|
|
|
|
|
override fun afterAudit(entity: AbstractAudit) { |
|
|
|
|
AssociationMember.new { |
|
|
|
|
user = entity.audit.user |
|
|
|
|
this.association = Association.find { Associations.auditId eq entity.audit.id }.firstOrNull() |
|
|
|
@ -696,6 +743,35 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun Association.set(vo:AssociationRegVo,user:User){ |
|
|
|
|
name = vo.name |
|
|
|
|
desc = vo.desc |
|
|
|
|
logo = ImageFile.findById(vo.fileId) ?: throw FileIdError(vo.fileId) |
|
|
|
|
this.audit = AuditLogging.new { |
|
|
|
|
this.user = user |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun loadAll():List<AssociationVo>{ |
|
|
|
|
return transaction { |
|
|
|
|
Association.all().map { |
|
|
|
|
toAssociationVo(it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun update(vo:AssociationVo){ |
|
|
|
|
transaction { |
|
|
|
|
Association.findById(vo.associationId).let { |
|
|
|
|
if(it==null){ |
|
|
|
|
throw AssociationIdError(vo.associationId) |
|
|
|
|
}else{ |
|
|
|
|
it.level=vo.level?.name |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 注册社团 |
|
|
|
|
* |
|
|
|
@ -708,15 +784,8 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
val user = User.findById(vo.token.id) ?: throw UserIdError(vo.token.id) |
|
|
|
|
if (vo.associationId != null) { |
|
|
|
|
log.info("再次提交【${vo.name}】注册资料") |
|
|
|
|
val association = Association.findById(vo.associationId!!) ?: throw AuditIdError(vo.associationId!!) |
|
|
|
|
association.apply { |
|
|
|
|
name = vo.name |
|
|
|
|
desc = vo.desc |
|
|
|
|
logo = ImageFile.findById(vo.fileId) ?: throw FileIdError(vo.fileId) |
|
|
|
|
this.audit = AuditLogging.new { |
|
|
|
|
this.user = user |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
(Association.findById(vo.associationId!!) ?: throw AuditIdError(vo.associationId!!)) |
|
|
|
|
.set(vo=vo,user=user) |
|
|
|
|
} else { |
|
|
|
|
val associationMember = AssociationMember.find { AssociationMembers.userId eq user.id }.firstOrNull() |
|
|
|
|
val association: Association? = associationMember?.association |
|
|
|
@ -725,12 +794,7 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
association != null && association.audit.result == null -> throw IllegalArgumentException("您已经提交过${dataType},请耐心等待后台管理员处理") |
|
|
|
|
association == null -> { |
|
|
|
|
Association.new { |
|
|
|
|
name = vo.name |
|
|
|
|
desc = vo.desc |
|
|
|
|
logo = ImageFile.findById(vo.fileId) ?: throw FileIdError(vo.fileId) |
|
|
|
|
this.audit = AuditLogging.new { |
|
|
|
|
this.user = user |
|
|
|
|
} |
|
|
|
|
set(vo=vo,user=user) |
|
|
|
|
faculty = faculty(user.studentId).name |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -738,9 +802,7 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreground(receiverId = vo.token.id, content = "您成功提交了一份${dataType},请耐心等待后台受理") |
|
|
|
|
|
|
|
|
|
background(content = "用户${user.name}提交了一份${dataType}需要您进行受理", duty = Duty.PamphaBhusal) |
|
|
|
|
createNotifications(vo=vo,user=user) |
|
|
|
|
log.info("未审核社团:${vo.name}创建成功") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -777,7 +839,8 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
return (Association.findById(id) ?: throw AssociationIdError(id.value)).let { |
|
|
|
|
AssociationCheckVo( |
|
|
|
|
associationVo = toAssociationVo(it), |
|
|
|
|
auditCheckVo = toCheckVo(it.audit), fileId = it.logo.id.value |
|
|
|
|
auditCheckVo = toCheckVo(it.audit), |
|
|
|
|
fileId = it.logo.id.value |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -790,16 +853,7 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
*/ |
|
|
|
|
override fun audit(vo: OnlyToken): List<AuditAssociationVo> { |
|
|
|
|
return transaction { |
|
|
|
|
return@transaction Association.all().sortedBy { |
|
|
|
|
//按初审受理>等待复审>复审受理>完成审核 排序 |
|
|
|
|
when { |
|
|
|
|
it.audit.nextAudit == null && it.audit.manager == null -> 1 |
|
|
|
|
it.audit.nextAudit == null && it.audit.manager != null -> 2 |
|
|
|
|
it.audit.nextAudit != null && it.audit.nextAudit?.manager == null -> 3 |
|
|
|
|
it.audit.nextAudit != null && it.audit.nextAudit?.result == null -> 4 |
|
|
|
|
else -> 5 |
|
|
|
|
} |
|
|
|
|
}.map { |
|
|
|
|
return@transaction createSortedBy(Association).map { |
|
|
|
|
val audit = toAuditLoggingVo(it.audit) ?: throw IllegalArgumentException("转换审核记录出错!!!!") |
|
|
|
|
AuditAssociationVo(name = it.name, desc = it.desc, logo = it.logo.filepath, audit = audit) |
|
|
|
|
}.apply { |
|
|
|
@ -872,17 +926,44 @@ object AssociationService : AuditService<AssociationRegVo, AuditAssociationVo, A |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 活动服务 |
|
|
|
|
*/ |
|
|
|
|
object ActivityService : AuditService<ActivityApplyVo, AuditActVo,ActivityCheckVo>() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val dataType: String = "活动申请书" |
|
|
|
|
|
|
|
|
|
override fun findEntity(auditId: Int): AbstractAudit { |
|
|
|
|
return Activity.find { Activities.auditId eq auditId }.firstOrNull() ?: throw AuditIdError(auditId) |
|
|
|
|
return testFind(Activities,Activity,auditId) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun afterAudit(entity: AbstractAudit) { |
|
|
|
|
/** |
|
|
|
|
* 查看活动信息 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
fun listAll():List<ManagerActVo>{ |
|
|
|
|
return transaction { |
|
|
|
|
Activity.all().map { |
|
|
|
|
ManagerActVo(association = AssociationService.toAssociationVo(it.association), |
|
|
|
|
score = (1..5).random(),activityVo = toActivityVo(it)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 主页活动图片 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
fun random():List<MainActivityPhotoVo>{ |
|
|
|
|
return transaction { |
|
|
|
|
PhotoAlbum.all().shuffled().map { |
|
|
|
|
MainActivityPhotoVo(url=it.photo.filepath, |
|
|
|
|
activityVo = toActivityVo(it.activity), |
|
|
|
|
associationVo = AssociationService.toAssociationVo(it.activity.association)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -989,18 +1070,16 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo,ActivityCheckV |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun read(vo: OnlyToken, table: IntIdTable): ActivityCheckVo? { |
|
|
|
|
val nextAudit = AuditLeggings.alias("nextAudit") |
|
|
|
|
return transaction { |
|
|
|
|
table.innerJoin(AuditLeggings) |
|
|
|
|
.innerJoin(nextAudit, { AuditLeggings.nextAudit }, { nextAudit[AuditLeggings.id] }) |
|
|
|
|
.innerJoin(Users) |
|
|
|
|
.slice(listOf(table.id)) |
|
|
|
|
.select {Users.id eq vo.token.id and (nextAudit[AuditLeggings.result] neq true)} |
|
|
|
|
.firstOrNull() |
|
|
|
|
?.let { it -> |
|
|
|
|
getCheckVo(id = it[table.id]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun Activity.set(activityVo:ActivityVo,user:User){ |
|
|
|
|
activityName = activityVo.activityName |
|
|
|
|
activityTime = activityVo.activityTime.toLocalDateTime() |
|
|
|
|
activityAddress = activityVo.activityAddress |
|
|
|
|
activityDesc = activityVo.activityDesc |
|
|
|
|
activitySize = activityVo.activitySize |
|
|
|
|
audit = AuditLogging.new { |
|
|
|
|
this.user = user |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1015,43 +1094,25 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo,ActivityCheckV |
|
|
|
|
if (vo.activityVo.activityId != null) { |
|
|
|
|
//再次提交 |
|
|
|
|
log.info("再次提交【${vo.activityVo.activityName}】${dataType}") |
|
|
|
|
val activity = Activity.findById(vo.activityVo.activityId!!) ?: throw ActivityIdError(vo.activityVo.activityId!!) |
|
|
|
|
activity.apply { |
|
|
|
|
activityName = vo.activityVo.activityName |
|
|
|
|
activityTime = vo.activityVo.activityTime.toLocalDateTime() |
|
|
|
|
activityAddress = vo.activityVo.activityAddress |
|
|
|
|
activityDesc = vo.activityVo.activityDesc |
|
|
|
|
activitySize = vo.activityVo.activitySize |
|
|
|
|
this.audit = AuditLogging.new { |
|
|
|
|
this.user = user |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
(Activity.findById(vo.activityVo.activityId!!) ?: throw ActivityIdError(vo.activityVo.activityId!!)) |
|
|
|
|
.set(activityVo = vo.activityVo,user=user) |
|
|
|
|
} else { |
|
|
|
|
//首次提交 |
|
|
|
|
//申请活动的限制 |
|
|
|
|
val activityMember = AssociationMember.find { AssociationMembers.userId eq user.id }.firstOrNull() |
|
|
|
|
when { |
|
|
|
|
activityMember == null -> throw IllegalArgumentException("非社团成员无法申请活动") |
|
|
|
|
!activityMember.isHead -> throw java.lang.IllegalArgumentException("不是社团团长无法申请活动") |
|
|
|
|
!activityMember.isHead -> throw IllegalArgumentException("不是社团团长无法申请活动") |
|
|
|
|
else -> { |
|
|
|
|
Activity.new { |
|
|
|
|
activityName = vo.activityVo.activityName |
|
|
|
|
activityTime = vo.activityVo.activityTime.toLocalDateTime() |
|
|
|
|
activityAddress = vo.activityVo.activityAddress |
|
|
|
|
activityDesc = vo.activityVo.activityDesc |
|
|
|
|
activitySize = vo.activityVo.activitySize |
|
|
|
|
association = |
|
|
|
|
Association.findById(vo.associationId) ?: throw AssociationIdError(vo.associationId) |
|
|
|
|
audit = AuditLogging.new { |
|
|
|
|
this.user = user |
|
|
|
|
} |
|
|
|
|
set(vo.activityVo,user=user) |
|
|
|
|
association = Association.findById(vo.associationId) ?: throw AssociationIdError(vo.associationId) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreground(receiverId = vo.token.id, content = "您成功提交了一份${dataType},请耐心等待后台受理") |
|
|
|
|
background(content = "用户${user.name}提交了一份${dataType}需要您进行受理", duty = Duty.PamphaBhusal) |
|
|
|
|
createNotifications(vo=vo,user=user) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1066,21 +1127,9 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo,ActivityCheckV |
|
|
|
|
|
|
|
|
|
override fun audit(vo: OnlyToken): List<AuditActVo> { |
|
|
|
|
return transaction { |
|
|
|
|
//TODO sortedBy这一段需要封装 |
|
|
|
|
return@transaction Activity.all().sortedBy { |
|
|
|
|
//按初审受理>等待复审>复审受理>完成审核 排序 |
|
|
|
|
when { |
|
|
|
|
it.audit.nextAudit == null && it.audit.manager == null -> 1 |
|
|
|
|
it.audit.nextAudit == null && it.audit.manager != null -> 2 |
|
|
|
|
it.audit.nextAudit != null && it.audit.nextAudit?.manager == null -> 3 |
|
|
|
|
it.audit.nextAudit != null && it.audit.nextAudit?.result == null -> 4 |
|
|
|
|
else -> 5 |
|
|
|
|
} |
|
|
|
|
}.map { |
|
|
|
|
return@transaction createSortedBy(Activity).map { |
|
|
|
|
val audit = toAuditLoggingVo(it.audit) ?: throw IllegalArgumentException("转换审核记录出错!!!!") |
|
|
|
|
AuditActVo( |
|
|
|
|
activityVo = toActivityVo(activity = it), audit = audit, auditId = it.id.value |
|
|
|
|
) |
|
|
|
|
AuditActVo(activityVo = toActivityVo(activity = it), audit = audit) |
|
|
|
|
}.apply { |
|
|
|
|
log.info("找到${this.size}份${dataType}") |
|
|
|
|
} |
|
|
|
@ -1091,13 +1140,93 @@ object ActivityService : AuditService<ActivityApplyVo, AuditActVo,ActivityCheckV |
|
|
|
|
return (Activity.findById(id) ?: throw ActivityIdError(id.value)).let { |
|
|
|
|
ActivityCheckVo( |
|
|
|
|
activityVo = toActivityVo(activity = it), |
|
|
|
|
auditCheckVo = toCheckVo(it.audit), |
|
|
|
|
activityId = it.id.value |
|
|
|
|
auditCheckVo = toCheckVo(it.audit) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 重命名服务 |
|
|
|
|
*/ |
|
|
|
|
object RenameService : AuditService<RenameApplyVo,AuditRenameVo,RenameCheckVo>(){ |
|
|
|
|
override val dataType: String = "换名申请表" |
|
|
|
|
|
|
|
|
|
fun Rename.set(vo:RenameVo,user:User){ |
|
|
|
|
newName=vo.newName |
|
|
|
|
cause=vo.cause |
|
|
|
|
audit=AuditLogging.new { |
|
|
|
|
this.user = user |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 类型自动转换 |
|
|
|
|
override fun afterAudit(entity: AbstractAudit) { |
|
|
|
|
if(entity is Rename){ |
|
|
|
|
entity.association.name=entity.newName |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun register(vo: RenameApplyVo) { |
|
|
|
|
transaction { |
|
|
|
|
vo.rename.renameId.also { |
|
|
|
|
val user = User.findById(vo.token.id) ?: throw UserIdError(vo.token.id) |
|
|
|
|
if (it != null) { |
|
|
|
|
//再次提交 |
|
|
|
|
(Rename.findById(it) ?: throw IllegalArgumentException("无法根据[id=${it}]找到${dataType}")).set( |
|
|
|
|
vo = vo.rename, |
|
|
|
|
user = user |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
//重新提交 |
|
|
|
|
val activityMember = AssociationMember.find { AssociationMembers.userId eq user.id }.firstOrNull() |
|
|
|
|
when { |
|
|
|
|
activityMember == null -> throw IllegalArgumentException("非社团成员无法申请社团换名") |
|
|
|
|
!activityMember.isHead -> throw IllegalArgumentException("非社团团长无法申请社团换名") |
|
|
|
|
else -> { |
|
|
|
|
Rename.new { |
|
|
|
|
set(vo = vo.rename, user = user) |
|
|
|
|
association = |
|
|
|
|
Association.findById(vo.associationId) ?: throw AssociationIdError(vo.associationId) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
createNotifications(vo = vo, user = user) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun findEntity(auditId: Int): AbstractAudit { |
|
|
|
|
return testFind(Renames,Rename,auditId) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun toRenameVo(rename: Rename):RenameVo{ |
|
|
|
|
return RenameVo(renameId = rename.id.value,newName = rename.newName,cause = rename.cause) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun getCheckVo(id: EntityID<Int>): RenameCheckVo { |
|
|
|
|
return (Rename.findById(id)?:throw IllegalArgumentException("找不到[id=${id}]${dataType}")).let { |
|
|
|
|
RenameCheckVo(renameVo = toRenameVo(it),auditCheckVo = toCheckVo(it.audit)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun audit(vo: OnlyToken): List<AuditRenameVo> { |
|
|
|
|
return transaction { |
|
|
|
|
return@transaction createSortedBy(Rename).map { |
|
|
|
|
val audit = toAuditLoggingVo(it.audit) ?: throw IllegalArgumentException("转换审核记录出错!!!!") |
|
|
|
|
AuditRenameVo(renameVo = toRenameVo(rename = it),audit = audit,associationVo = AssociationService.toAssociationVo(it.association)) |
|
|
|
|
}.apply { |
|
|
|
|
log.info("找到${this.size}份${ActivityService.dataType}") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通知服务 |
|
|
|
|
*/ |
|
|
|
@ -1180,6 +1309,52 @@ object BackgroundService : AbstractService() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun toManagerVo(manager: Manager):ManagerInfoVo{ |
|
|
|
|
return ManagerInfoVo(duty = manager.duty.let { Duty.valueOf(it) },name=manager.name, |
|
|
|
|
headImg = manager.headImg?.filepath,desc = manager.desc) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 加载部门部长,和总人数 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
fun load():ManagerDutySumVo{ |
|
|
|
|
return transaction { |
|
|
|
|
val secretariat=Manager.find { Managers.duty eq Duty.SecretaryOfTheMinister.name }.first() |
|
|
|
|
val secretariatCount=Manager.find{ Managers.duty eq Duty.SecretaryDepartmentOfficer.name }.count() |
|
|
|
|
val propaganda=Manager.find {Managers.duty eq Duty.PropagandaDepartment.name }.first() |
|
|
|
|
val propagandaCount=Manager.find{ Managers.duty eq Duty.PublicityDepartmentOfficer.name }.count() |
|
|
|
|
val publicRelationsDepartment=Manager.find{ Managers.duty eq Duty.LiaisonMinister.name }.first() |
|
|
|
|
val publicRelationsDepartmentCount=Manager.find{ Managers.duty eq Duty.LiaisonOfficer.name }.count() |
|
|
|
|
ManagerDutySumVo(secretariat = ManagerDutyVo(manager = toManagerVo(secretariat),people = secretariatCount.toInt()), |
|
|
|
|
propaganda = ManagerDutyVo(manager = toManagerVo(propaganda),people = propagandaCount.toInt()), |
|
|
|
|
publicRelationsDepartment = ManagerDutyVo(manager = toManagerVo(publicRelationsDepartment), |
|
|
|
|
people=publicRelationsDepartmentCount.toInt())) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 加载部门详细信息 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
fun loadDetail():AllOfficerVo{ |
|
|
|
|
return transaction { |
|
|
|
|
val secretariat=Manager.find{ Managers.duty eq Duty.SecretaryDepartmentOfficer.name }.map { |
|
|
|
|
toManagerVo(it) |
|
|
|
|
} |
|
|
|
|
val propaganda=Manager.find {Managers.duty eq Duty.PublicityDepartmentOfficer.name }.map { |
|
|
|
|
toManagerVo(it) |
|
|
|
|
} |
|
|
|
|
val publicRelationsDepartment=Manager.find { Managers.duty eq Duty.LiaisonOfficer.name }.map { |
|
|
|
|
toManagerVo(it) |
|
|
|
|
} |
|
|
|
|
AllOfficerVo(secretariat=secretariat,propaganda = propaganda,publicRelationsDepartment=publicRelationsDepartment) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun createManager(duty: Duty, num: Int = 1): MutableList<InitManagerDto> { |
|
|
|
|
val managerList = mutableListOf<InitManagerDto>() |
|
|
|
|
repeat(num) { |
|
|
|
|