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> 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 create(@RequestBody Map body) { return Result.success(companyService.create(body.get("companyName"), body.get("companyCode"))); } @Operation(summary = "更新公司信息") @PutMapping("/{id}") @RequireRole("ADMIN") public Result update(@PathVariable Long id, @RequestBody Map body) { return Result.success(companyService.update(id, body.get("companyName"), body.get("companyCode"))); } @Operation(summary = "更新公司状态") @PutMapping("/{id}/status") @RequireRole("ADMIN") public Result updateStatus(@PathVariable Long id, @RequestBody Map body) { companyService.updateStatus(id, body.get("status")); return Result.success(null); } @Operation(summary = "删除公司") @DeleteMapping("/{id}") @RequireRole("ADMIN") public Result delete(@PathVariable Long id) { companyService.delete(id); return Result.success(null); } }