Skip to content

Commit

Permalink
fix: correct all kinds of issues
Browse files Browse the repository at this point in the history
1. SQL script
2. OpenAPI info
3. Mybatis mapper's script
  • Loading branch information
johnnymillergh committed Jun 26, 2022
1 parent e4a52e0 commit 34448d6
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OpenApiConfiguration(
.info(
Info()
.title("API for $projectArtifactId@$version")
.description("$mafProjectProperties.description, artifact ID: $projectArtifactId, environment: ${mafProjectProperties.environment}")
.description("${mafProjectProperties.description}, artifact ID: $projectArtifactId, environment: ${mafProjectProperties.environment}")
.contact(
Contact()
.name(mafProjectProperties.developerName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.jmsoftware.maf.authcenter.user.service.impl

import cn.hutool.core.collection.ListUtil
import cn.hutool.core.util.ObjectUtil
import cn.hutool.core.util.RandomUtil
import cn.hutool.core.util.StrUtil
import cn.hutool.json.JSONUtil
import com.baomidou.mybatisplus.core.metadata.OrderItem
import com.baomidou.mybatisplus.core.toolkit.Wrappers
import com.baomidou.mybatisplus.core.toolkit.support.SFunction
import com.baomidou.mybatisplus.core.metadata.OrderItem.desc
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.jmsoftware.maf.authcenter.security.service.JwtService
Expand Down Expand Up @@ -119,18 +115,16 @@ class UserDomainServiceImpl(
}

override fun getUserPageList(payload: GetUserPageListPayload): PageResponseBodyBean<User> {
logger.info("$payload")
val page = Page<User>(
payload.currentPage.toLong(), payload.pageSize.toLong()
)
val queryWrapper = Wrappers.lambdaQuery(
User::class.java
)
if (StrUtil.isNotBlank(payload.username)) {
queryWrapper.like(SFunction<User, Any> { obj: User -> obj.username }, payload.username)
val page = Page<User>(payload.currentPage.toLong(), payload.pageSize.toLong())
.apply { this.orders = listOf(desc(payload.orderBy)) }
this.ktQuery().apply {
payload.username?.let {
if (it.isNotBlank()) {
this.like(User::username, payload.username)
}
}
}
page.orders = ListUtil.of(OrderItem.desc(payload.orderBy))
this.page(page, queryWrapper)
.page(page)
return PageResponseBodyBean.ofSuccess(page.records, page.total)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.jmsoftware.maf.authcenter.user.payload

import com.jmsoftware.maf.common.bean.PaginationBase
import java.time.LocalDateTime
import javax.validation.constraints.NotEmpty
import javax.validation.constraints.NotNull

/**
* # GetUserPageListPayload
Expand All @@ -10,10 +12,11 @@ import java.time.LocalDateTime
*
* @author Johnny Miller (锺俊), e-mail: johnnysviva@outlook.com, date: 4/12/22 12:46 PM
*/
class GetUserPageListPayload : PaginationBase() {
var username: String? = null

var startTime: LocalDateTime? = null

var endTime: LocalDateTime? = null
}
data class GetUserPageListPayload(
@field:NotEmpty
val username: String,
@field:NotNull
val startTime: LocalDateTime,
@field:NotNull
val endTime: LocalDateTime
) : PaginationBase()
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.jmsoftware.maf.common.bean

import cn.hutool.core.util.NumberUtil
import com.fasterxml.jackson.annotation.JsonIgnore
import org.hibernate.validator.constraints.Range
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
Expand All @@ -14,52 +13,41 @@ import javax.validation.constraints.Pattern
*
* @author Johnny Miller (锺俊), e-mail: johnnysviva@outlook.com, date: 4/16/22 11:13 AM
*/
@Suppress("MemberVisibilityCanBePrivate")
open class PaginationBase {
/**
* The current page. Default: 1
*/
@JsonIgnore
@NotNull(message = "The current page is required!")
@Min(value = 1L, message = "The current page is not less then 1!")
var currentPage: Int = 1
var currentPage: Int = 0

/**
* The page size. Default: 10
*/
@JsonIgnore
@NotNull(message = "The page size is required!")
@Range(min = 10L, max = 100L, message = "The rage of page size: 10 <= page size <= 100!")
var pageSize: Int = 10
val pageSize: Int = 10

/**
* The order-by. (for table's field)
*/
@JsonIgnore
var orderBy: String? = null
val orderBy: String? = null

/**
* The order rule. Default: DESC
*/
@JsonIgnore
@Pattern(regexp = "^(ASC|DESC)$")
var orderRule: String = "DESC"
val orderRule: String = "DESC"

/**
* The order-by statement needs to be joined.
*/
@JsonIgnore
var orderByStatement: String? = null

/**
* The order-by statement needs to be joined.
*/
@JsonIgnore
fun orderByStatement(): String {
orderByStatement?.isBlank()
if (orderBy?.isNotBlank() == true) {
return "ORDER BY `$orderBy` $orderRule"
}
return orderByStatement!!
return ""
}

/**
Expand Down
Loading

0 comments on commit 34448d6

Please sign in to comment.