Sop管理

This commit is contained in:
2026-04-23 14:23:43 +08:00
parent a99b1b5b09
commit 54f2053d45
6 changed files with 380 additions and 1 deletions

View File

@@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* 知识库管理前端控制器
* 话术库管理前端控制器
*/
@Slf4j
@RestController

View File

@@ -0,0 +1,107 @@
package com.rj.controller;
import com.rj.entity.SopManagementMy;
import com.rj.service.ISopManagementMyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* SOP知识库管理前端控制器
*/
@Slf4j
@RestController
@RequestMapping("/api/sopManagementMy")
@Tag(name = "SOP知识库管理(sop_management_my)", description = "增删改查与分页")
public class SopManagementMyController {
@Autowired
private ISopManagementMyService sopManagementMyService;
@PostMapping("/add")
@Operation(summary = "新增")
public ResponseEntity<Map<String, Object>> add(
@Parameter(description = "实体", required = true) @RequestBody SopManagementMy entity) {
Map<String, Object> result = sopManagementMyService.add(entity);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
}
return ResponseEntity.badRequest().body(result);
}
@PutMapping("/update")
@Operation(summary = "编辑")
public ResponseEntity<Map<String, Object>> update(
@Parameter(description = "实体", required = true) @RequestBody SopManagementMy entity) {
Map<String, Object> result = sopManagementMyService.update(entity);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
}
return ResponseEntity.badRequest().body(result);
}
@DeleteMapping("/delete/{id}")
@Operation(summary = "删除")
public ResponseEntity<Map<String, Object>> delete(
@Parameter(description = "主键ID", required = true) @PathVariable String id) {
Map<String, Object> result = sopManagementMyService.deleteById(id);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
}
return ResponseEntity.badRequest().body(result);
}
@GetMapping("/list")
@Operation(summary = "分页查询")
public ResponseEntity<Map<String, Object>> list(
@RequestParam(defaultValue = "1") Integer current,
@RequestParam(defaultValue = "10") Integer size,
@RequestParam(required = false) String title,
@RequestParam(required = false) String category,
@RequestParam(required = false) String industry,
@RequestParam(required = false) String creator,
@RequestParam(required = false) String status) {
Map<String, Object> result = sopManagementMyService.pageQuery(
current, size, title, category, industry, creator, status
);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
}
return ResponseEntity.internalServerError().body(result);
}
@GetMapping("/get/{id}")
@Operation(summary = "按ID查询")
public ResponseEntity<Map<String, Object>> getById(
@Parameter(description = "主键ID", required = true) @PathVariable String id) {
Map<String, Object> result = new HashMap<>();
try {
SopManagementMy data = sopManagementMyService.getById(id);
if (data == null) {
result.put("success", false);
result.put("message", "记录不存在");
return ResponseEntity.notFound().build();
}
result.put("success", true);
result.put("message", "查询成功");
result.put("data", data);
return ResponseEntity.ok(result);
} catch (Exception e) {
log.error("sop_management_my get by id error, id={}", id, e);
result.put("success", false);
result.put("message", "查询异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
}