|
@@ -1,6 +1,9 @@
|
|
|
package com.gihon.component.rbac.controller;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -14,6 +17,7 @@ import com.gihon.component.exception.BusinessException;
|
|
|
import com.gihon.component.response.PageBean;
|
|
|
import com.gihon.component.response.Response;
|
|
|
import com.gihon.component.response.ResponseStatus;
|
|
|
+import com.gihon.component.response.SelectVal;
|
|
|
import com.gihon.component.service.GihonCompanyService;
|
|
|
import com.gihon.component.vo.CompanyListReq;
|
|
|
import com.gihon.component.web.auth.AuthUtils;
|
|
@@ -21,57 +25,67 @@ import com.gihon.component.web.auth.AuthUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
-@Api(value ="公司模块" ,tags = "公司模块")
|
|
|
+@Api(value = "公司模块", tags = "公司模块")
|
|
|
@RestController
|
|
|
@RequestMapping("company")
|
|
|
public class CompanyController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private GihonCompanyService companyService;
|
|
|
-
|
|
|
- @ApiOperation("COMPANY:列表")
|
|
|
- @GetMapping("list")
|
|
|
- public Response<PageBean<GihonCompany>> list(CompanyListReq companyListReq) {
|
|
|
- IPage<GihonCompany> list = companyService.getCompanylistPage(companyListReq);
|
|
|
- return Response.okPage(list);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("COMPANY:启用")
|
|
|
- @PostMapping("enable/{id}")
|
|
|
- public Response<Void> enable(@PathVariable Long id) {
|
|
|
- companyService.enableCompany(id, AuthUtils.getUserId(), true);
|
|
|
- return Response.ok();
|
|
|
- }
|
|
|
- @ApiOperation("COMPANY:禁用")
|
|
|
- @PostMapping("disable/{id}")
|
|
|
- public Response<Void> disable(@PathVariable Long id) {
|
|
|
- companyService.enableCompany(id, AuthUtils.getUserId(), false);
|
|
|
- return Response.ok();
|
|
|
- }
|
|
|
- @ApiOperation("COMPANY:新增")
|
|
|
- @PostMapping("")
|
|
|
- public Response<Void> saveCompany(@RequestBody GihonCompany company) {
|
|
|
- companyService.saveCompany(company);
|
|
|
- return Response.ok();
|
|
|
- }
|
|
|
- @ApiOperation("COMPANY:编辑")
|
|
|
- @PostMapping("/{id}")
|
|
|
- public Response<Void> updateCompany(@RequestBody GihonCompany company,@PathVariable Long id) {
|
|
|
- Long companyId = AuthUtils.getCompanyId();
|
|
|
- if(companyId!=null&&!companyId.equals(id)) {
|
|
|
- throw new BusinessException(ResponseStatus.FORBIDDEN);
|
|
|
- }
|
|
|
- company.setId(id);
|
|
|
- companyService.updateCompany(company);
|
|
|
- return Response.ok();
|
|
|
- }
|
|
|
- @ApiOperation("COMPANY:详情")
|
|
|
- @GetMapping("/{id}")
|
|
|
- public Response<GihonCompany> getCompany(@PathVariable Long id) {
|
|
|
- Long companyId = AuthUtils.getCompanyId();
|
|
|
- if(companyId!=null&&!companyId.equals(id)) {
|
|
|
- throw new BusinessException(ResponseStatus.FORBIDDEN);
|
|
|
- }
|
|
|
- return Response.ok(companyService.getById(id));
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private GihonCompanyService companyService;
|
|
|
+
|
|
|
+ @ApiOperation("COMPANY:列表")
|
|
|
+ @GetMapping("list")
|
|
|
+ public Response<PageBean<GihonCompany>> list(@Validated CompanyListReq companyListReq) {
|
|
|
+ IPage<GihonCompany> list = companyService.getCompanylistPage(companyListReq);
|
|
|
+ return Response.okPage(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("COMPANY:启用")
|
|
|
+ @PostMapping("enable/{id}")
|
|
|
+ public Response<Void> enable(@PathVariable Long id) {
|
|
|
+ companyService.enableCompany(id, AuthUtils.getUserId(), true);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("COMPANY:禁用")
|
|
|
+ @PostMapping("disable/{id}")
|
|
|
+ public Response<Void> disable(@PathVariable Long id) {
|
|
|
+ companyService.enableCompany(id, AuthUtils.getUserId(), false);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("COMPANY:新增")
|
|
|
+ @PostMapping("")
|
|
|
+ public Response<Void> saveCompany(@Validated @RequestBody GihonCompany company) {
|
|
|
+ companyService.saveCompany(company);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("COMPANY:编辑")
|
|
|
+ @PostMapping("/{id}")
|
|
|
+ public Response<Void> updateCompany(@Validated @RequestBody GihonCompany company, @PathVariable Long id) {
|
|
|
+ Long companyId = AuthUtils.getCompanyId();
|
|
|
+ if (companyId != null && !companyId.equals(id)) {
|
|
|
+ throw new BusinessException(ResponseStatus.FORBIDDEN);
|
|
|
+ }
|
|
|
+ company.setId(id);
|
|
|
+ companyService.updateCompany(company);
|
|
|
+ return Response.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("COMPANY:详情")
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public Response<GihonCompany> getCompany(@PathVariable Long id) {
|
|
|
+ Long companyId = AuthUtils.getCompanyId();
|
|
|
+ if (companyId != null && !companyId.equals(id)) {
|
|
|
+ throw new BusinessException(ResponseStatus.FORBIDDEN);
|
|
|
+ }
|
|
|
+ return Response.ok(companyService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("COMPANY:列表")
|
|
|
+ @GetMapping("/labelAndValue")
|
|
|
+ public Response<List<SelectVal>> labelAndValue(String companyName) {
|
|
|
+ return Response.ok(companyService.labelAndValue(AuthUtils.getCompanyId(),companyName));
|
|
|
+ }
|
|
|
}
|