Refactor(KtWrapper): Simplify KtWrapper #24
@@ -106,7 +106,7 @@ class UserServiceImpl(
|
|||||||
if (!passwordEncoder.matches(userChangePasswordParam.originalPassword, user.password)) {
|
if (!passwordEncoder.matches(userChangePasswordParam.originalPassword, user.password)) {
|
||||||
throw BadCredentialsException("Passwords do not match")
|
throw BadCredentialsException("Passwords do not match")
|
||||||
}
|
}
|
||||||
val wrapper = KtUpdateWrapper(User())
|
val wrapper = ktUpdate()
|
||||||
.eq(User::id, user.id)
|
.eq(User::id, user.id)
|
||||||
.set(User::password, passwordEncoder.encode(userChangePasswordParam.newPassword))
|
.set(User::password, passwordEncoder.encode(userChangePasswordParam.newPassword))
|
||||||
.set(User::credentialsExpiration, null)
|
.set(User::credentialsExpiration, null)
|
||||||
@@ -220,7 +220,7 @@ class UserServiceImpl(
|
|||||||
|
|
||||||
this.updateById(user)
|
this.updateById(user)
|
||||||
this.update(
|
this.update(
|
||||||
KtUpdateWrapper(User()).eq(User::id, user.id)
|
ktUpdate().eq(User::id, user.id)
|
||||||
.set(
|
.set(
|
||||||
User::verify,
|
User::verify,
|
||||||
if (userUpdateParam.verified || userUpdateParam.id == 0L) null else "${
|
if (userUpdateParam.verified || userUpdateParam.id == 0L) null else "${
|
||||||
@@ -282,7 +282,7 @@ class UserServiceImpl(
|
|||||||
|
|
||||||
val user = this.getById(userUpdatePasswordParam.id)
|
val user = this.getById(userUpdatePasswordParam.id)
|
||||||
user?.let {
|
user?.let {
|
||||||
val wrapper = KtUpdateWrapper(User())
|
val wrapper = ktUpdate()
|
||||||
.eq(User::id, user.id)
|
.eq(User::id, user.id)
|
||||||
.set(User::password, passwordEncoder.encode(userUpdatePasswordParam.password))
|
.set(User::password, passwordEncoder.encode(userUpdatePasswordParam.password))
|
||||||
.set(
|
.set(
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package top.fatweb.oxygen.api.service.system.impl
|
package top.fatweb.oxygen.api.service.system.impl
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
|
|
||||||
import com.baomidou.mybatisplus.extension.kotlin.KtUpdateWrapper
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.transaction.annotation.Propagation
|
import org.springframework.transaction.annotation.Propagation
|
||||||
@@ -38,9 +36,9 @@ class SensitiveWordServiceImpl : ServiceImpl<SensitiveWordMapper, SensitiveWord>
|
|||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
override fun update(sensitiveWordUpdateParam: SensitiveWordUpdateParam) {
|
override fun update(sensitiveWordUpdateParam: SensitiveWordUpdateParam) {
|
||||||
this.update(KtUpdateWrapper(SensitiveWord()).set(SensitiveWord::enable, false))
|
this.update(ktUpdate().set(SensitiveWord::enable, false))
|
||||||
this.update(
|
this.update(
|
||||||
KtUpdateWrapper(SensitiveWord()).`in`(SensitiveWord::id, sensitiveWordUpdateParam.ids)
|
ktUpdate().`in`(SensitiveWord::id, sensitiveWordUpdateParam.ids)
|
||||||
.set(SensitiveWord::enable, true)
|
.set(SensitiveWord::enable, true)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -52,7 +50,7 @@ class SensitiveWordServiceImpl : ServiceImpl<SensitiveWordMapper, SensitiveWord>
|
|||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
override fun checkSensitiveWord(str: String) {
|
override fun checkSensitiveWord(str: String) {
|
||||||
this.list(KtQueryWrapper(SensitiveWord()).eq(SensitiveWord::enable, 1)).map(SensitiveWord::word).forEach {
|
this.list(ktQuery().eq(SensitiveWord::enable, 1)).map(SensitiveWord::word).forEach {
|
||||||
it ?: return@forEach
|
it ?: return@forEach
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package top.fatweb.oxygen.api.service.tool.impl
|
package top.fatweb.oxygen.api.service.tool.impl
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
|
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
|
||||||
import com.baomidou.mybatisplus.extension.kotlin.KtUpdateWrapper
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||||
import org.springframework.dao.DuplicateKeyException
|
import org.springframework.dao.DuplicateKeyException
|
||||||
@@ -64,7 +63,7 @@ class EditServiceImpl(
|
|||||||
override fun create(toolCreateParam: ToolCreateParam): ToolVo {
|
override fun create(toolCreateParam: ToolCreateParam): ToolVo {
|
||||||
val template = this.getTemplate(toolCreateParam.templateId!!)
|
val template = this.getTemplate(toolCreateParam.templateId!!)
|
||||||
baseMapper.selectOne(
|
baseMapper.selectOne(
|
||||||
KtQueryWrapper(Tool())
|
ktQuery()
|
||||||
.eq(Tool::toolId, toolCreateParam.toolId!!)
|
.eq(Tool::toolId, toolCreateParam.toolId!!)
|
||||||
.eq(Tool::authorId, WebUtil.getLoginUserId()!!)
|
.eq(Tool::authorId, WebUtil.getLoginUserId()!!)
|
||||||
.eq(Tool::platform, template.platform)
|
.eq(Tool::platform, template.platform)
|
||||||
@@ -245,7 +244,7 @@ class EditServiceImpl(
|
|||||||
throw ToolHasBeenPublishedException()
|
throw ToolHasBeenPublishedException()
|
||||||
}
|
}
|
||||||
|
|
||||||
return update(KtUpdateWrapper(Tool()).eq(Tool::id, id).set(Tool::review, Tool.ReviewType.PROCESSING))
|
return update(ktUpdate().eq(Tool::id, id).set(Tool::review, Tool.ReviewType.PROCESSING))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cancel(id: Long): Boolean {
|
override fun cancel(id: Long): Boolean {
|
||||||
@@ -257,13 +256,13 @@ class EditServiceImpl(
|
|||||||
throw ToolNotUnderReviewException()
|
throw ToolNotUnderReviewException()
|
||||||
}
|
}
|
||||||
|
|
||||||
return update(KtUpdateWrapper(Tool()).eq(Tool::id, id).set(Tool::review, Tool.ReviewType.NONE))
|
return update(ktUpdate().eq(Tool::id, id).set(Tool::review, Tool.ReviewType.NONE))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
override fun delete(id: Long): Boolean {
|
override fun delete(id: Long): Boolean {
|
||||||
val tool = baseMapper.selectOne(
|
val tool = baseMapper.selectOne(
|
||||||
KtQueryWrapper(Tool()).eq(Tool::id, id)
|
ktQuery().eq(Tool::id, id)
|
||||||
.eq(Tool::authorId, WebUtil.getLoginUserId()!!)
|
.eq(Tool::authorId, WebUtil.getLoginUserId()!!)
|
||||||
) ?: throw NoRecordFoundException()
|
) ?: throw NoRecordFoundException()
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class ManagementServiceImpl(
|
|||||||
)
|
)
|
||||||
|
|
||||||
this.update(
|
this.update(
|
||||||
KtUpdateWrapper(Tool())
|
ktUpdate()
|
||||||
.eq(Tool::id, id)
|
.eq(Tool::id, id)
|
||||||
.set(Tool::review, Tool.ReviewType.PASS)
|
.set(Tool::review, Tool.ReviewType.PASS)
|
||||||
.set(Tool::publish, LocalDateTime.now(ZoneOffset.UTC).toInstant(ZoneOffset.UTC).toEpochMilli())
|
.set(Tool::publish, LocalDateTime.now(ZoneOffset.UTC).toInstant(ZoneOffset.UTC).toEpochMilli())
|
||||||
@@ -93,7 +93,7 @@ class ManagementServiceImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.update(
|
this.update(
|
||||||
KtUpdateWrapper(Tool())
|
ktUpdate()
|
||||||
.eq(Tool::id, id)
|
.eq(Tool::id, id)
|
||||||
.set(Tool::review, Tool.ReviewType.REJECT)
|
.set(Tool::review, Tool.ReviewType.REJECT)
|
||||||
)
|
)
|
||||||
@@ -108,7 +108,7 @@ class ManagementServiceImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.update(
|
this.update(
|
||||||
KtUpdateWrapper(Tool())
|
ktUpdate()
|
||||||
.eq(Tool::id, id)
|
.eq(Tool::id, id)
|
||||||
.set(Tool::review, Tool.ReviewType.REJECT)
|
.set(Tool::review, Tool.ReviewType.REJECT)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package top.fatweb.oxygen.api.service.tool.impl
|
package top.fatweb.oxygen.api.service.tool.impl
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
@@ -45,7 +44,7 @@ class ToolBaseServiceImpl(
|
|||||||
return ToolBaseConverter.toolBasePageToToolBasePageVo(
|
return ToolBaseConverter.toolBasePageToToolBasePageVo(
|
||||||
this.page(
|
this.page(
|
||||||
basePage,
|
basePage,
|
||||||
KtQueryWrapper(ToolBase()).`in`(
|
ktQuery().`in`(
|
||||||
!toolBaseGetParam?.platform.isNullOrBlank(),
|
!toolBaseGetParam?.platform.isNullOrBlank(),
|
||||||
ToolBase::platform,
|
ToolBase::platform,
|
||||||
toolBaseGetParam?.platform?.split(",")
|
toolBaseGetParam?.platform?.split(",")
|
||||||
|
|||||||
Reference in New Issue
Block a user