81 lines
3.3 KiB
Java
81 lines
3.3 KiB
Java
package com.rj.controller;
|
|
|
|
import com.rj.entity.LbPurchaseApply;
|
|
import com.rj.service.ILbPurchaseApplyService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.time.LocalDate;
|
|
import java.util.Map;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/lbPurchaseApply")
|
|
@Tag(name = "进货申请", description = "lb_purchase_apply增删改查与分页")
|
|
public class LbPurchaseApplyController {
|
|
|
|
@Autowired
|
|
private ILbPurchaseApplyService lbPurchaseApplyService;
|
|
|
|
@PostMapping("/add")
|
|
@Operation(summary = "新增")
|
|
public ResponseEntity<Map<String, Object>> add(
|
|
@Parameter(description = "实体", required = true) @RequestBody LbPurchaseApply entity) {
|
|
Map<String, Object> result = lbPurchaseApplyService.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 LbPurchaseApply entity) {
|
|
Map<String, Object> result = lbPurchaseApplyService.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 Long id) {
|
|
Map<String, Object> result = lbPurchaseApplyService.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 tenantId,
|
|
@RequestParam(required = false) String applyUser,
|
|
@RequestParam(required = false) String applyPhone,
|
|
@RequestParam(required = false) String colleagueName,
|
|
@RequestParam(required = false) String teamLeader,
|
|
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate applyDate) {
|
|
Map<String, Object> result = lbPurchaseApplyService.pageQuery(
|
|
current, size, tenantId, applyUser, applyPhone, colleagueName, teamLeader, applyDate
|
|
);
|
|
Boolean success = (Boolean) result.get("success");
|
|
if (success != null && success) {
|
|
return ResponseEntity.ok(result);
|
|
}
|
|
return ResponseEntity.internalServerError().body(result);
|
|
}
|
|
}
|