kotlin⾥String和LocalDate互转controller
package com.umh.ller
import com.umh.del.*
import com.umh.del.ReferralCasesSearchDto
import com.odel.doctorreferralcase.ReferralCasesSearchParam
import com.umh.doctorreferral.api.service.ApiDoctorReferralCaseService
import io.swagger.annotations.ApiResponse
import io.swagger.annotations.ApiResponses
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.web.bind.annotation.*
import java.util.*
/**
* @Description
* @Author hunagzp
* @Date 2021/7/22 16:01
*
*/
@RestController
@Tag(name = "医⽣转介API", description = "医⽣转介API")
class DoctorReferralCaseController {
@Autowired
private lateinit var doctorReferralCaseService : ApiDoctorReferralCaseService
@Operation(summary = "交易记录搜索+转介单清单", description = "交易记录搜索+转介单清单")
@GetMapping("/referral-cases-search", params = ["page", "size"])
@ApiResponses(
ApiResponse(code = 200,message = "OK",response = ReferralCasesSearchDto::class)
)
fun referralCasesSearch(param: ReferralCasesSearchParam, pageable : Pageable): Page<ReferralCasesSearchDto> { ferralCasesSearch(param, pageable)
}
}
service
package com.umh.doctorreferral.api.service
import com.umh.del.*
import com.odel.doctorreferralcase.DoctorReferralCase
import com.odel.doctorreferralcase.DoctorReferralCaseRepository
import com.odel.doctorreferralcase.ReferralCasesSearchParam
import com.odel.file.ApplicationFileRepository
import com.service.ApplicationFileService
import io.swagger.v3.oas.annotations.Operation
import org.apachemons.lang3.StringUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.BeanUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.domain.Pageable
import org.springframework.data.domain.Pageable
import org.springframework.data.domain.*
import org.pository.findByIdOrNull
import org.springframework.stereotype.Service
import ansaction.annotation.Transactional
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.util.*
import javax.persistence.EntityManager
import javax.persistence.PersistenceContext
/**
* @Description
* @Author hunagzp
* @Date 2021/7/22 16:04
*
*/
@Service
class ApiDoctorReferralCaseService {
private val logger = Logger(this.javaClass)
@Autowired
private lateinit var applicationFileService: ApplicationFileService
@Autowired
private lateinit var doctorReferralCaseRepository:DoctorReferralCaseRepository
@Autowired
private lateinit var applicationFileRepository : ApplicationFileRepository
@Autowired
private lateinit var referralCasesWrapper: ReferralCasesWrapper
@Operation(summary = "交易记录搜索+转介单清单", description = "交易记录搜索+转介单清单")
fun referralCasesSearch(param: ReferralCasesSearchParam, pageable: Pageable): Page<ReferralCasesSearchDto> {
val page : Pageable
val referralCase = DoctorReferralCase()
referralCase.apply { pyProperties(param, this) }
string转date的方法//定义时间格式
val df = DateTimeFormatter.ofPattern("yyyy-MM-dd")
//把传参string类型的ferralDate转成localdate
orders.add(Sort.Order(Sort.Direction.DESC, "createdDate"))
page = PageRequest.of(pageable.pageNumber, pageable.pageSize, Sort.by(orders))
val result = doctorReferralCaseRepository.pageReferralCase(param, page)
//将分页数据封装到⾃定义的传参类⾥
return result.map { vertToReferralCasesSearchDto(it) }
}
}
package com.umh.del
import com.odel.doctorreferralcase.DoctorReferralCase
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Component
import java.time.format.DateTimeFormatter
/**
* @author hunagzp
* @date 2021/8/2 14:10
* @description
*
*/
@Component
class ReferralCasesWrapper {
fun convertToReferralCasesSearchDto(doctorReferralCase: DoctorReferralCase): ReferralCasesSearchDto { val df = DateTimeFormatter.ofPattern("yyyy/MM/dd")
return ReferralCasesSearchDto().apply {
//TODO IN/OUT, referralNo, referrer, referee, member
//把localdate类型转换成string类型保存,ferralDate为string类型
}
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论