56 lines
1.9 KiB
Java
56 lines
1.9 KiB
Java
package com.isu.gaswellwatch.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.isu.gaswellwatch.annotation.OperationLog;
|
|
import com.isu.gaswellwatch.dto.CompanyDTO;
|
|
import com.isu.gaswellwatch.dto.CompanyEditDTO;
|
|
import com.isu.gaswellwatch.entity.Response;
|
|
import com.isu.gaswellwatch.enums.LogType;
|
|
import com.isu.gaswellwatch.service.CompanyService;
|
|
import com.isu.gaswellwatch.vo.CompanyVO;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.validation.Valid;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@RestController
|
|
@RequestMapping("company")
|
|
public class CompanyController {
|
|
/**
|
|
* 服务对象
|
|
*/
|
|
@Resource
|
|
private CompanyService companyService;
|
|
|
|
@GetMapping("/page")
|
|
public Response<Page<CompanyVO>> page(@RequestParam(defaultValue = "1") Integer currentPage,
|
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
|
@RequestParam(required = false) String name,
|
|
@RequestParam(required = false) String code){
|
|
return Response.succeed(companyService.page(currentPage,pageSize,name,code));
|
|
}
|
|
|
|
@PostMapping("/add")
|
|
@OperationLog(description = "新增公司",type = LogType.ADD)
|
|
public Response<String> add(@RequestBody @Valid CompanyDTO companyDTO){
|
|
companyService.add(companyDTO);
|
|
return Response.succeed();
|
|
}
|
|
|
|
@PostMapping("/edit")
|
|
@OperationLog(description = "修改公司",type = LogType.UPDATE)
|
|
public Response<String> edit(@RequestBody @Valid CompanyEditDTO companyEditDTO){
|
|
companyService.edit(companyEditDTO);
|
|
return Response.succeed();
|
|
}
|
|
|
|
@GetMapping("/delete")
|
|
@OperationLog(description = "删除公司",type = LogType.DELETE)
|
|
public Response<String> delete(@RequestParam Long id){
|
|
companyService.delete(id);
|
|
return Response.succeed();
|
|
}
|
|
}
|
|
|