forked from ITStudio_OUC/itstudio_manager
feat: serviceImpl
This commit is contained in:
+54
-2
@@ -1,10 +1,62 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.Attachment
|
||||
import club.itstudio.itmanager.mapper.AttachmentMapper
|
||||
import club.itstudio.itmanager.service.AttachmentService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class AttachmentServiceImpl : ServiceImpl<AttachmentMapper, Attachment>(), AttachmentService
|
||||
class AttachmentServiceImpl : ServiceImpl<AttachmentMapper, Attachment>(), AttachmentService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getAttachmentById(id: Long): Mono<Attachment> =
|
||||
blockingCall {
|
||||
logger.info("Searching attachment by id")
|
||||
ktQuery().eq(Attachment::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("Attachment not found")))
|
||||
|
||||
override fun listByRelated(relatedTable: String, relatedId: Long): Mono<List<Attachment>> =
|
||||
blockingCall {
|
||||
logger.info("Searching attachments by related table and id")
|
||||
ktQuery().eq(Attachment::relatedTable, relatedTable).eq(Attachment::relatedId, relatedId).list()
|
||||
}
|
||||
|
||||
override fun listByUploader(uploadedBy: Long): Mono<List<Attachment>> =
|
||||
blockingCall {
|
||||
logger.info("Searching attachments by uploader")
|
||||
ktQuery().eq(Attachment::uploadedBy, uploadedBy).list()
|
||||
}
|
||||
|
||||
override fun createAttachment(attachment: Attachment): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating attachment")
|
||||
save(attachment)
|
||||
}
|
||||
|
||||
override fun deleteAttachment(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting attachment by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun deleteByRelated(relatedTable: String, relatedId: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting attachments by related table and id")
|
||||
remove(ktQuery().eq(Attachment::relatedTable, relatedTable).eq(Attachment::relatedId, relatedId))
|
||||
}
|
||||
|
||||
override fun exportAllAttachments(): Mono<List<Attachment>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all attachments")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+66
-2
@@ -1,10 +1,74 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.BorrowRecord
|
||||
import club.itstudio.itmanager.mapper.BorrowRecordMapper
|
||||
import club.itstudio.itmanager.service.BorrowRecordService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class BorrowRecordServiceImpl : ServiceImpl<BorrowRecordMapper, BorrowRecord>(), BorrowRecordService
|
||||
class BorrowRecordServiceImpl : ServiceImpl<BorrowRecordMapper, BorrowRecord>(), BorrowRecordService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getBorrowRecordById(id: Long): Mono<BorrowRecord> =
|
||||
blockingCall {
|
||||
logger.info("Searching borrow record by id")
|
||||
ktQuery().eq(BorrowRecord::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("BorrowRecord not found")))
|
||||
|
||||
override fun listByItem(itemId: Long): Mono<List<BorrowRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Searching borrow records by item id")
|
||||
ktQuery().eq(BorrowRecord::itemId, itemId).list()
|
||||
}
|
||||
|
||||
override fun listByBorrower(borrowerId: Long): Mono<List<BorrowRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Searching borrow records by borrower id")
|
||||
ktQuery().eq(BorrowRecord::borrowerId, borrowerId).list()
|
||||
}
|
||||
|
||||
override fun listByStatus(status: String): Mono<List<BorrowRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Searching borrow records by status")
|
||||
ktQuery().eq(BorrowRecord::status, status).list()
|
||||
}
|
||||
|
||||
override fun listOverdueRecords(): Mono<List<BorrowRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Searching overdue borrow records")
|
||||
ktQuery().eq(BorrowRecord::status, "OVERDUE").list()
|
||||
}
|
||||
|
||||
override fun createBorrowRecord(record: BorrowRecord): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating borrow record")
|
||||
save(record)
|
||||
}
|
||||
|
||||
override fun updateBorrowRecord(record: BorrowRecord): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating borrow record")
|
||||
updateById(record)
|
||||
}
|
||||
|
||||
override fun deleteBorrowRecord(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting borrow record by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun exportAllBorrowRecords(): Mono<List<BorrowRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all borrow records")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+54
-2
@@ -1,10 +1,62 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.Category
|
||||
import club.itstudio.itmanager.mapper.CategoryMapper
|
||||
import club.itstudio.itmanager.service.CategoryService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class CategoryServiceImpl : ServiceImpl<CategoryMapper, Category>(), CategoryService
|
||||
class CategoryServiceImpl : ServiceImpl<CategoryMapper, Category>(), CategoryService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getCategoryById(id: Long): Mono<Category> =
|
||||
blockingCall {
|
||||
logger.info("Searching category by id")
|
||||
ktQuery().eq(Category::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("Category not found")))
|
||||
|
||||
override fun listAllCategories(): Mono<List<Category>> =
|
||||
blockingCall {
|
||||
logger.info("Listing all categories")
|
||||
list()
|
||||
}
|
||||
|
||||
override fun listByParentId(parentId: Long): Mono<List<Category>> =
|
||||
blockingCall {
|
||||
logger.info("Searching categories by parent id")
|
||||
ktQuery().eq(Category::parentId, parentId).list()
|
||||
}
|
||||
|
||||
override fun createCategory(category: Category): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating category")
|
||||
save(category)
|
||||
}
|
||||
|
||||
override fun updateCategory(category: Category): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating category")
|
||||
updateById(category)
|
||||
}
|
||||
|
||||
override fun deleteCategory(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting category by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun exportAllCategories(): Mono<List<Category>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all categories")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+54
-2
@@ -1,10 +1,62 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.Department
|
||||
import club.itstudio.itmanager.mapper.DepartmentMapper
|
||||
import club.itstudio.itmanager.service.DepartmentService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class DepartmentServiceImpl : ServiceImpl<DepartmentMapper, Department>(), DepartmentService
|
||||
class DepartmentServiceImpl : ServiceImpl<DepartmentMapper, Department>(), DepartmentService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getDepartmentById(id: Long): Mono<Department> =
|
||||
blockingCall {
|
||||
logger.info("Searching department by id")
|
||||
ktQuery().eq(Department::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("Department not found")))
|
||||
|
||||
override fun listAllDepartments(): Mono<List<Department>> =
|
||||
blockingCall {
|
||||
logger.info("Listing all departments")
|
||||
list()
|
||||
}
|
||||
|
||||
override fun listByParentId(parentId: Long): Mono<List<Department>> =
|
||||
blockingCall {
|
||||
logger.info("Searching departments by parent id")
|
||||
ktQuery().eq(Department::parentId, parentId).list()
|
||||
}
|
||||
|
||||
override fun createDepartment(department: Department): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating department")
|
||||
save(department)
|
||||
}
|
||||
|
||||
override fun updateDepartment(department: Department): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating department")
|
||||
updateById(department)
|
||||
}
|
||||
|
||||
override fun deleteDepartment(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting department by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun exportAllDepartments(): Mono<List<Department>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all departments")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+64
-2
@@ -1,10 +1,72 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.EmailNotice
|
||||
import club.itstudio.itmanager.mapper.EmailNoticeMapper
|
||||
import club.itstudio.itmanager.service.EmailNoticeService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class EmailNoticeServiceImpl : ServiceImpl<EmailNoticeMapper, EmailNotice>(), EmailNoticeService
|
||||
class EmailNoticeServiceImpl : ServiceImpl<EmailNoticeMapper, EmailNotice>(), EmailNoticeService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getEmailNoticeById(id: Long): Mono<EmailNotice> =
|
||||
blockingCall {
|
||||
logger.info("Searching email notice by id")
|
||||
ktQuery().eq(EmailNotice::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("EmailNotice not found")))
|
||||
|
||||
override fun listAllNotices(): Mono<List<EmailNotice>> =
|
||||
blockingCall {
|
||||
logger.info("Listing all email notices")
|
||||
list()
|
||||
}
|
||||
|
||||
override fun listEnabledNotices(): Mono<List<EmailNotice>> =
|
||||
blockingCall {
|
||||
logger.info("Listing enabled email notices")
|
||||
ktQuery().eq(EmailNotice::enabled, true).list()
|
||||
}
|
||||
|
||||
override fun createEmailNotice(notice: EmailNotice): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating email notice")
|
||||
save(notice)
|
||||
}
|
||||
|
||||
override fun updateEmailNotice(notice: EmailNotice): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating email notice")
|
||||
updateById(notice)
|
||||
}
|
||||
|
||||
override fun deleteEmailNotice(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting email notice by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun toggleEnabled(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
val notice = ktQuery().eq(EmailNotice::id, id).one()
|
||||
if (notice != null) {
|
||||
updateById(notice.copy(enabled = !notice.enabled))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun exportAllEmailNotices(): Mono<List<EmailNotice>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all email notices")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+66
-2
@@ -1,10 +1,74 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.Evaluation
|
||||
import club.itstudio.itmanager.mapper.EvaluationMapper
|
||||
import club.itstudio.itmanager.service.EvaluationService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class EvaluationServiceImpl : ServiceImpl<EvaluationMapper, Evaluation>(), EvaluationService
|
||||
class EvaluationServiceImpl : ServiceImpl<EvaluationMapper, Evaluation>(), EvaluationService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getEvaluationById(id: Long): Mono<Evaluation> =
|
||||
blockingCall {
|
||||
logger.info("Searching evaluation by id")
|
||||
ktQuery().eq(Evaluation::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("Evaluation not found")))
|
||||
|
||||
override fun listByEvaluator(evaluatorId: Long): Mono<List<Evaluation>> =
|
||||
blockingCall {
|
||||
logger.info("Searching evaluations by evaluator id")
|
||||
ktQuery().eq(Evaluation::evaluatorId, evaluatorId).list()
|
||||
}
|
||||
|
||||
override fun listByRelatedItem(itemId: Long): Mono<List<Evaluation>> =
|
||||
blockingCall {
|
||||
logger.info("Searching evaluations by related item id")
|
||||
ktQuery().eq(Evaluation::relatedItemId, itemId).list()
|
||||
}
|
||||
|
||||
override fun listByScore(score: Short): Mono<List<Evaluation>> =
|
||||
blockingCall {
|
||||
logger.info("Searching evaluations by score")
|
||||
ktQuery().eq(Evaluation::score, score).list()
|
||||
}
|
||||
|
||||
override fun createEvaluation(evaluation: Evaluation): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating evaluation")
|
||||
save(evaluation)
|
||||
}
|
||||
|
||||
override fun updateEvaluation(evaluation: Evaluation): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating evaluation")
|
||||
updateById(evaluation)
|
||||
}
|
||||
|
||||
override fun deleteEvaluation(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting evaluation by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun deleteByEvaluator(evaluatorId: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting evaluations by evaluator id")
|
||||
remove(ktQuery().eq(Evaluation::evaluatorId, evaluatorId))
|
||||
}
|
||||
|
||||
override fun exportAllEvaluations(): Mono<List<Evaluation>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all evaluations")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+66
-2
@@ -1,10 +1,74 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.FinanceRecord
|
||||
import club.itstudio.itmanager.mapper.FinanceRecordMapper
|
||||
import club.itstudio.itmanager.service.FinanceRecordService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class FinanceRecordServiceImpl : ServiceImpl<FinanceRecordMapper, FinanceRecord>(), FinanceRecordService
|
||||
class FinanceRecordServiceImpl : ServiceImpl<FinanceRecordMapper, FinanceRecord>(), FinanceRecordService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getFinanceRecordById(id: Long): Mono<FinanceRecord> =
|
||||
blockingCall {
|
||||
logger.info("Searching finance record by id")
|
||||
ktQuery().eq(FinanceRecord::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("FinanceRecord not found")))
|
||||
|
||||
override fun listByType(type: String): Mono<List<FinanceRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Searching finance records by type")
|
||||
ktQuery().eq(FinanceRecord::type, type).list()
|
||||
}
|
||||
|
||||
override fun listByDateRange(start: String, end: String): Mono<List<FinanceRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Searching finance records by date range")
|
||||
ktQuery().apply("occurred_at BETWEEN {0} AND {1}", start, end).list()
|
||||
}
|
||||
|
||||
override fun listByVendor(vendor: String): Mono<List<FinanceRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Searching finance records by vendor")
|
||||
ktQuery().eq(FinanceRecord::vendor, vendor).list()
|
||||
}
|
||||
|
||||
override fun listByRelatedItem(itemId: Long): Mono<List<FinanceRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Searching finance records by related item id")
|
||||
ktQuery().eq(FinanceRecord::relatedItemId, itemId).list()
|
||||
}
|
||||
|
||||
override fun createFinanceRecord(record: FinanceRecord): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating finance record")
|
||||
save(record)
|
||||
}
|
||||
|
||||
override fun updateFinanceRecord(record: FinanceRecord): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating finance record")
|
||||
updateById(record)
|
||||
}
|
||||
|
||||
override fun deleteFinanceRecord(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting finance record by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun exportAllFinanceRecords(): Mono<List<FinanceRecord>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all finance records")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+115
-2
@@ -1,10 +1,123 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.Item
|
||||
import club.itstudio.itmanager.mapper.ItemMapper
|
||||
import club.itstudio.itmanager.service.ItemService
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class ItemServiceImpl : ServiceImpl<ItemMapper, Item>(), ItemService
|
||||
class ItemServiceImpl : ServiceImpl<ItemMapper, Item>(), ItemService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun pageItems(page: Page<Item>, keyword: String?, status: String?): Mono<Page<Item>> =
|
||||
blockingCall {
|
||||
logger.info("Paging items with keyword and status")
|
||||
val wrapper = ktQuery()
|
||||
if (!keyword.isNullOrBlank()) {
|
||||
wrapper.and {
|
||||
it.like(Item::name, keyword).or().like(Item::code, keyword)
|
||||
}
|
||||
}
|
||||
if (!status.isNullOrBlank()) {
|
||||
wrapper.eq(Item::status, status)
|
||||
}
|
||||
page(page, wrapper)
|
||||
}
|
||||
|
||||
override fun getItemById(id: Long): Mono<Item> =
|
||||
blockingCall {
|
||||
logger.info("Searching item by id")
|
||||
ktQuery().eq(Item::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("Item not found")))
|
||||
|
||||
override fun listAvailableItems(): Mono<List<Item>> =
|
||||
blockingCall {
|
||||
logger.info("Listing available items")
|
||||
ktQuery().gt(Item::availableQuantity, 0).eq(Item::status, "normal").list()
|
||||
}
|
||||
|
||||
override fun listInUseItems(): Mono<List<Item>> =
|
||||
blockingCall {
|
||||
logger.info("Listing in-use items")
|
||||
ktQuery().apply("total_quantity - available_quantity > 0").list()
|
||||
}
|
||||
|
||||
override fun listItemsByCategory(categoryId: Long): Mono<List<Item>> =
|
||||
blockingCall {
|
||||
logger.info("Listing items by category")
|
||||
ktQuery().eq(Item::categoryId, categoryId).list()
|
||||
}
|
||||
|
||||
override fun createItem(item: Item): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating item")
|
||||
save(item)
|
||||
}
|
||||
|
||||
override fun updateItem(item: Item): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating item")
|
||||
updateById(item)
|
||||
}
|
||||
|
||||
override fun removeItemById(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Removing item by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun setPrimaryImage(id: Long, imagePath: String): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Setting primary image for item")
|
||||
ktUpdate().eq(Item::id, id).set(Item::imagePath, imagePath).update()
|
||||
}
|
||||
|
||||
override fun borrowItem(id: Long, quantity: Int): Mono<Boolean> =
|
||||
blockingCall {
|
||||
val item = ktQuery().eq(Item::id, id).one()
|
||||
if (item != null && item.availableQuantity >= quantity) {
|
||||
ktUpdate().eq(Item::id, id).set(Item::availableQuantity, item.availableQuantity - quantity).update()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun returnItem(id: Long, quantity: Int): Mono<Boolean> =
|
||||
blockingCall {
|
||||
val item = ktQuery().eq(Item::id, id).one()
|
||||
if (item != null && item.totalQuantity >= item.availableQuantity + quantity) {
|
||||
ktUpdate().eq(Item::id, id).set(Item::availableQuantity, item.availableQuantity + quantity).update()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun batchInsertItems(items: List<Item>): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Batch inserting items")
|
||||
saveBatch(items)
|
||||
}
|
||||
|
||||
override fun replaceAllItems(items: List<Item>): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Replacing all items")
|
||||
remove(ktQuery())
|
||||
saveBatch(items)
|
||||
}
|
||||
|
||||
override fun exportAllItems(): Mono<List<Item>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all items")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+60
-2
@@ -1,10 +1,68 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.ItemTransaction
|
||||
import club.itstudio.itmanager.mapper.ItemTransactionMapper
|
||||
import club.itstudio.itmanager.service.ItemTransactionService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class ItemTransactionServiceImpl : ServiceImpl<ItemTransactionMapper, ItemTransaction>(), ItemTransactionService
|
||||
class ItemTransactionServiceImpl : ServiceImpl<ItemTransactionMapper, ItemTransaction>(), ItemTransactionService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getTransactionById(id: Long): Mono<ItemTransaction> =
|
||||
blockingCall {
|
||||
logger.info("Searching transaction by id")
|
||||
ktQuery().eq(ItemTransaction::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("ItemTransaction not found")))
|
||||
|
||||
override fun listByItem(itemId: Long): Mono<List<ItemTransaction>> =
|
||||
blockingCall {
|
||||
logger.info("Searching transactions by item id")
|
||||
ktQuery().eq(ItemTransaction::itemId, itemId).list()
|
||||
}
|
||||
|
||||
override fun listByType(transType: String): Mono<List<ItemTransaction>> =
|
||||
blockingCall {
|
||||
logger.info("Searching transactions by type")
|
||||
ktQuery().eq(ItemTransaction::transType, transType).list()
|
||||
}
|
||||
|
||||
override fun listByOperator(operatorId: Long): Mono<List<ItemTransaction>> =
|
||||
blockingCall {
|
||||
logger.info("Searching transactions by operator id")
|
||||
ktQuery().eq(ItemTransaction::operatorId, operatorId).list()
|
||||
}
|
||||
|
||||
override fun createTransaction(transaction: ItemTransaction): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating transaction")
|
||||
save(transaction)
|
||||
}
|
||||
|
||||
override fun updateTransaction(transaction: ItemTransaction): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating transaction")
|
||||
updateById(transaction)
|
||||
}
|
||||
|
||||
override fun deleteTransaction(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting transaction by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun exportAllTransactions(): Mono<List<ItemTransaction>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all transactions")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+72
-2
@@ -1,10 +1,80 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.Memo
|
||||
import club.itstudio.itmanager.mapper.MemoMapper
|
||||
import club.itstudio.itmanager.service.MemoService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class MemoServiceImpl : ServiceImpl<MemoMapper, Memo>(), MemoService
|
||||
class MemoServiceImpl : ServiceImpl<MemoMapper, Memo>(), MemoService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getMemoById(id: Long): Mono<Memo> =
|
||||
blockingCall {
|
||||
logger.info("Searching memo by id")
|
||||
ktQuery().eq(Memo::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("Memo not found")))
|
||||
|
||||
override fun searchMemos(keyword: String?): Mono<List<Memo>> =
|
||||
blockingCall {
|
||||
logger.info("Searching memos with keyword")
|
||||
if (keyword.isNullOrBlank()) {
|
||||
list()
|
||||
} else {
|
||||
ktQuery().and {
|
||||
it.like(Memo::title, keyword).or().like(Memo::content, keyword)
|
||||
}.list()
|
||||
}
|
||||
}
|
||||
|
||||
override fun listByAuthor(authorId: Long): Mono<List<Memo>> =
|
||||
blockingCall {
|
||||
logger.info("Searching memos by author id")
|
||||
ktQuery().eq(Memo::authorId, authorId).list()
|
||||
}
|
||||
|
||||
override fun listByRelatedItem(itemId: Long): Mono<List<Memo>> =
|
||||
blockingCall {
|
||||
logger.info("Searching memos by related item id")
|
||||
ktQuery().eq(Memo::relatedItemId, itemId).list()
|
||||
}
|
||||
|
||||
override fun listPublicMemos(): Mono<List<Memo>> =
|
||||
blockingCall {
|
||||
logger.info("Listing public memos")
|
||||
ktQuery().eq(Memo::isPublic, true).list()
|
||||
}
|
||||
|
||||
override fun createMemo(memo: Memo): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating memo")
|
||||
save(memo)
|
||||
}
|
||||
|
||||
override fun updateMemo(memo: Memo): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating memo")
|
||||
updateById(memo)
|
||||
}
|
||||
|
||||
override fun deleteMemo(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting memo by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun exportAllMemos(): Mono<List<Memo>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all memos")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
+75
-2
@@ -1,10 +1,83 @@
|
||||
package club.itstudio.itmanager.service.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import club.itstudio.itmanager.entity.dto.Personnel
|
||||
import club.itstudio.itmanager.mapper.PersonnelMapper
|
||||
import club.itstudio.itmanager.service.PersonnelService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Service
|
||||
class PersonnelServiceImpl : ServiceImpl<PersonnelMapper, Personnel>(), PersonnelService
|
||||
class PersonnelServiceImpl : ServiceImpl<PersonnelMapper, Personnel>(), PersonnelService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
private fun <T : Any> blockingCall(block: () -> T?): Mono<T> =
|
||||
Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic())
|
||||
|
||||
override fun getPersonnelById(id: Long): Mono<Personnel> =
|
||||
blockingCall {
|
||||
logger.info("Searching personnel by id")
|
||||
ktQuery().eq(Personnel::id, id).one()
|
||||
}.switchIfEmpty(Mono.error(NoSuchElementException("Personnel not found")))
|
||||
|
||||
override fun searchPersonnel(keyword: String?): Mono<List<Personnel>> =
|
||||
blockingCall {
|
||||
logger.info("Searching personnel with keyword")
|
||||
if (keyword.isNullOrBlank()) {
|
||||
list()
|
||||
} else {
|
||||
ktQuery().and {
|
||||
it.like(Personnel::name, keyword)
|
||||
.or().like(Personnel::employeeNo, keyword)
|
||||
.or().like(Personnel::phone, keyword)
|
||||
.or().like(Personnel::email, keyword)
|
||||
}.list()
|
||||
}
|
||||
}
|
||||
|
||||
override fun listByDepartment(departmentId: Long): Mono<List<Personnel>> =
|
||||
blockingCall {
|
||||
logger.info("Searching personnel by department id")
|
||||
ktQuery().eq(Personnel::departmentId, departmentId).list()
|
||||
}
|
||||
|
||||
override fun listByRole(role: String): Mono<List<Personnel>> =
|
||||
blockingCall {
|
||||
logger.info("Searching personnel by role")
|
||||
ktQuery().eq(Personnel::role, role).list()
|
||||
}
|
||||
|
||||
override fun createPersonnel(personnel: Personnel): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Creating personnel")
|
||||
save(personnel)
|
||||
}
|
||||
|
||||
override fun updatePersonnel(personnel: Personnel): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Updating personnel")
|
||||
updateById(personnel)
|
||||
}
|
||||
|
||||
override fun deletePersonnel(id: Long): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Deleting personnel by id")
|
||||
removeById(id)
|
||||
}
|
||||
|
||||
override fun setActive(id: Long, active: Boolean): Mono<Boolean> =
|
||||
blockingCall {
|
||||
logger.info("Setting personnel active status")
|
||||
ktUpdate().eq(Personnel::id, id).set(Personnel::isActive, active).update()
|
||||
}
|
||||
|
||||
override fun exportAllPersonnel(): Mono<List<Personnel>> =
|
||||
blockingCall {
|
||||
logger.info("Exporting all personnel")
|
||||
list()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user