diff --git a/README.md b/README.md index 3c80a68..bfa3b73 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,18 @@ - /ask-code - /register - /reset - - /departments - /email - /finance - /items + - / + - /{id}/upload_images + - /{id}/set_primary_image + - /{id}/borrow + - /{id}/return_item + - /available + - /in_use + - /categories + - /images - /proof-images - /usages @@ -53,8 +61,6 @@ | `finance/` | GET/POST/PUT/DELETE | 财务记录 CRUD 操作 | | `finance/{id}/upload_images/` | POST | 上传财务凭证图片 | | `finance/{id}/` | DELETE | 删除财务记录(发送邮件通知) | -| `departments/` | GET/POST/PUT/DELETE | 部门 CRUD 操作 | -| `departments/{id}/` | DELETE | 删除部门(发送邮件通知) | | `finance/categories/`(原 `finance_categories/`) | GET/POST/PUT/DELETE | 财务分类 CRUD 操作 | | `proof-images/` | GET/POST/PUT/DELETE | 财务凭证图片 CRUD 操作 | | `proof-images/{id}/` | DELETE | 删除凭证图片(自动删除物理文件) | @@ -98,8 +104,6 @@ Authorization: Bearer [schema.sql](./schema.sql) - users/account (系统用户/认证信息) -- departments (组织/部门) - - parent_id -> departments.id (自关联父级) - categories (物品类别) - parent_id -> categories.id (自关联父级) - items (物品基本信息) diff --git a/schema.sql b/schema.sql index 333d88e..e178e39 100644 --- a/schema.sql +++ b/schema.sql @@ -15,21 +15,6 @@ CREATE TABLE account DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT ='系统用户/认证信息'; --- 部门表 -DROP TABLE IF EXISTS departments; -CREATE TABLE departments -( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(100) NOT NULL, - code VARCHAR(50), - parent_id BIGINT UNSIGNED, - description TEXT, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - CONSTRAINT fk_departments_parent FOREIGN KEY (parent_id) REFERENCES departments (id) ON DELETE SET NULL -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='组织/部门'; - -- 物品类别 DROP TABLE IF EXISTS categories; CREATE TABLE categories diff --git a/src/backend/src/main/kotlin/club/itstudio/itmanager/controller/v1/DepartmentsController.kt b/src/backend/src/main/kotlin/club/itstudio/itmanager/controller/v1/DepartmentsController.kt deleted file mode 100644 index 94bc933..0000000 --- a/src/backend/src/main/kotlin/club/itstudio/itmanager/controller/v1/DepartmentsController.kt +++ /dev/null @@ -1,29 +0,0 @@ -package club.itstudio.itmanager.controller.v1 - -import club.itstudio.itmanager.utils.Const -import org.springframework.validation.annotation.Validated -import org.springframework.web.bind.annotation.* -import reactor.core.publisher.Mono - -@Validated -@RestController -@RequestMapping("/api/v1/departments") -class DepartmentsController { - - // departments/ GET/POST/PUT/DELETE 部门 CRUD 操作 - @GetMapping("", "/") - fun getDepartments(): Mono = Const.INTERNAL_ERROR_MONO - - @PostMapping("", "/") - fun createDepartment(): Mono = Const.INTERNAL_ERROR_MONO - - @PutMapping("", "/") - fun updateDepartment(): Mono = Const.INTERNAL_ERROR_MONO - - @DeleteMapping("", "/") - fun deleteDepartment(@RequestParam(required = false) id: String?): Mono = Const.INTERNAL_ERROR_MONO - - // departments/{id}/ DELETE 删除部门(发送邮件通知) - @DeleteMapping("/{id}", "/{id}/") - fun deleteById(@PathVariable("id") id: String): Mono = Const.INTERNAL_ERROR_MONO -} \ No newline at end of file diff --git a/src/backend/src/main/kotlin/club/itstudio/itmanager/controller/v1/UsersController.kt b/src/backend/src/main/kotlin/club/itstudio/itmanager/controller/v1/UsersController.kt deleted file mode 100644 index ab5ad23..0000000 --- a/src/backend/src/main/kotlin/club/itstudio/itmanager/controller/v1/UsersController.kt +++ /dev/null @@ -1,18 +0,0 @@ -package club.itstudio.itmanager.controller.v1 - -import club.itstudio.itmanager.utils.Const -import org.springframework.validation.annotation.Validated -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController -import reactor.core.publisher.Mono - -@Validated -@RestController -@RequestMapping("/api/v1/users") -class UsersController { - - // users/ GET 获取用户列表(只读) - @GetMapping("", "/") - fun getUsers(): Mono = Const.INTERNAL_ERROR_MONO -} diff --git a/src/backend/src/main/kotlin/club/itstudio/itmanager/entity/dto/Department.kt b/src/backend/src/main/kotlin/club/itstudio/itmanager/entity/dto/Department.kt deleted file mode 100644 index 3e82679..0000000 --- a/src/backend/src/main/kotlin/club/itstudio/itmanager/entity/dto/Department.kt +++ /dev/null @@ -1,21 +0,0 @@ -package club.itstudio.itmanager.entity.dto - -import com.baomidou.mybatisplus.annotation.IdType -import com.baomidou.mybatisplus.annotation.TableId -import com.baomidou.mybatisplus.annotation.TableName -import club.itstudio.itmanager.entity.DataCopy -import kotlinx.datetime.LocalDateTime -import kotlinx.serialization.Serializable - -@Serializable -@TableName("departments") -data class Department( - @TableId(type = IdType.AUTO) - val id: Long? = null, - val name: String = "", - val code: String? = null, - val parentId: Long? = null, - val description: String? = null, - val createdAt: LocalDateTime? = null, - val updatedAt: LocalDateTime? = null -) : DataCopy diff --git a/src/backend/src/main/kotlin/club/itstudio/itmanager/mapper/DepartmentMapper.kt b/src/backend/src/main/kotlin/club/itstudio/itmanager/mapper/DepartmentMapper.kt deleted file mode 100644 index d7e7561..0000000 --- a/src/backend/src/main/kotlin/club/itstudio/itmanager/mapper/DepartmentMapper.kt +++ /dev/null @@ -1,8 +0,0 @@ -package club.itstudio.itmanager.mapper - -import com.baomidou.mybatisplus.core.mapper.BaseMapper -import club.itstudio.itmanager.entity.dto.Department -import org.apache.ibatis.annotations.Mapper - -@Mapper -interface DepartmentMapper : BaseMapper diff --git a/src/backend/src/main/kotlin/club/itstudio/itmanager/service/DepartmentService.kt b/src/backend/src/main/kotlin/club/itstudio/itmanager/service/DepartmentService.kt deleted file mode 100644 index f8221d1..0000000 --- a/src/backend/src/main/kotlin/club/itstudio/itmanager/service/DepartmentService.kt +++ /dev/null @@ -1,15 +0,0 @@ -package club.itstudio.itmanager.service - -import com.baomidou.mybatisplus.extension.service.IService -import club.itstudio.itmanager.entity.dto.Department -import reactor.core.publisher.Mono - -interface DepartmentService : IService { - fun getDepartmentById(id: Long): Mono - fun listAllDepartments(): Mono> - fun listByParentId(parentId: Long): Mono> - fun createDepartment(department: Department): Mono - fun updateDepartment(department: Department): Mono - fun deleteDepartment(id: Long): Mono - fun exportAllDepartments(): Mono> -} diff --git a/src/backend/src/main/kotlin/club/itstudio/itmanager/service/impl/DepartmentServiceImpl.kt b/src/backend/src/main/kotlin/club/itstudio/itmanager/service/impl/DepartmentServiceImpl.kt deleted file mode 100644 index d74adb8..0000000 --- a/src/backend/src/main/kotlin/club/itstudio/itmanager/service/impl/DepartmentServiceImpl.kt +++ /dev/null @@ -1,62 +0,0 @@ -package club.itstudio.itmanager.service.impl - -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(), DepartmentService { - - private val logger = LoggerFactory.getLogger(this::class.java) - - private fun blockingCall(block: () -> T?): Mono = - Mono.fromCallable(block).subscribeOn(Schedulers.boundedElastic()) - - override fun getDepartmentById(id: Long): Mono = - blockingCall { - logger.info("Searching department by id") - ktQuery().eq(Department::id, id).one() - }.switchIfEmpty(Mono.error(NoSuchElementException("Department not found"))) - - override fun listAllDepartments(): Mono> = - blockingCall { - logger.info("Listing all departments") - list() - } - - override fun listByParentId(parentId: Long): Mono> = - blockingCall { - logger.info("Searching departments by parent id") - ktQuery().eq(Department::parentId, parentId).list() - } - - override fun createDepartment(department: Department): Mono = - blockingCall { - logger.info("Creating department") - save(department) - } - - override fun updateDepartment(department: Department): Mono = - blockingCall { - logger.info("Updating department") - updateById(department) - } - - override fun deleteDepartment(id: Long): Mono = - blockingCall { - logger.info("Deleting department by id") - removeById(id) - } - - override fun exportAllDepartments(): Mono> = - blockingCall { - logger.info("Exporting all departments") - list() - } -}