去掉shiro框架
This commit is contained in:
73
src/main/java/com/label/controller/CompanyController.java
Normal file
73
src/main/java/com/label/controller/CompanyController.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.label.controller;
|
||||
|
||||
import com.label.annotation.RequireRole;
|
||||
import com.label.common.result.PageResult;
|
||||
import com.label.common.result.Result;
|
||||
import com.label.entity.SysCompany;
|
||||
import com.label.service.CompanyService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "公司管理", description = "租户公司增删改查")
|
||||
@RestController
|
||||
@RequestMapping("/api/companies")
|
||||
@RequiredArgsConstructor
|
||||
public class CompanyController {
|
||||
|
||||
private final CompanyService companyService;
|
||||
|
||||
@Operation(summary = "分页查询公司列表")
|
||||
@GetMapping
|
||||
@RequireRole("ADMIN")
|
||||
public Result<PageResult<SysCompany>> list(
|
||||
@RequestParam(defaultValue = "1") int page,
|
||||
@RequestParam(defaultValue = "20") int pageSize,
|
||||
@RequestParam(required = false) String status) {
|
||||
return Result.success(companyService.list(page, pageSize, status));
|
||||
}
|
||||
|
||||
@Operation(summary = "创建公司")
|
||||
@PostMapping
|
||||
@RequireRole("ADMIN")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public Result<SysCompany> create(@RequestBody Map<String, String> body) {
|
||||
return Result.success(companyService.create(body.get("companyName"), body.get("companyCode")));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新公司信息")
|
||||
@PutMapping("/{id}")
|
||||
@RequireRole("ADMIN")
|
||||
public Result<SysCompany> update(@PathVariable Long id, @RequestBody Map<String, String> body) {
|
||||
return Result.success(companyService.update(id, body.get("companyName"), body.get("companyCode")));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新公司状态")
|
||||
@PutMapping("/{id}/status")
|
||||
@RequireRole("ADMIN")
|
||||
public Result<Void> updateStatus(@PathVariable Long id, @RequestBody Map<String, String> body) {
|
||||
companyService.updateStatus(id, body.get("status"));
|
||||
return Result.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除公司")
|
||||
@DeleteMapping("/{id}")
|
||||
@RequireRole("ADMIN")
|
||||
public Result<Void> delete(@PathVariable Long id) {
|
||||
companyService.delete(id);
|
||||
return Result.success(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user