1 changed files with 75 additions and 0 deletions
@ -0,0 +1,75 @@ |
|||
package com.storeroom.modules.system.controller; |
|||
|
|||
|
|||
import com.storeroom.annotation.Log; |
|||
import com.storeroom.exception.BaseException; |
|||
import com.storeroom.modules.system.domain.Job; |
|||
import com.storeroom.modules.system.service.JobService; |
|||
import com.storeroom.modules.system.service.dto.JobQueryCriteria; |
|||
import com.storeroom.utils.ApiResponse; |
|||
import com.storeroom.utils.enums.ResponseStatus; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
import java.util.Set; |
|||
|
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "系统:岗位管理") |
|||
@RequestMapping("/api/job") |
|||
public class JobController { |
|||
|
|||
private final JobService jobService; |
|||
private static final String ENTITY_NAME = "job"; |
|||
|
|||
@ApiOperation("导出岗位数据") |
|||
@GetMapping(value = "/download") |
|||
public void exportJob(HttpServletResponse response, JobQueryCriteria criteria) throws IOException { |
|||
jobService.download(jobService.queryAll(criteria), response); |
|||
} |
|||
|
|||
@ApiOperation("查询岗位") |
|||
@GetMapping |
|||
public ResponseEntity<Object> queryJob(JobQueryCriteria criteria, Pageable pageable){ |
|||
return new ResponseEntity<>(jobService.queryAll(criteria, pageable), HttpStatus.OK); |
|||
} |
|||
|
|||
@Log("新增岗位") |
|||
@ApiOperation("新增岗位") |
|||
@PostMapping |
|||
public ApiResponse<Object> createJob(@Validated @RequestBody Job resources){ |
|||
if (resources.getId() != null) { |
|||
throw new BaseException("A new "+ ENTITY_NAME +" cannot already have an ID"); |
|||
} |
|||
jobService.create(resources); |
|||
return ApiResponse.success(ResponseStatus.SUCCESS); |
|||
} |
|||
|
|||
@Log("修改岗位") |
|||
@ApiOperation("修改岗位") |
|||
@PutMapping |
|||
public ApiResponse<Object> updateJob(@Validated(Job.Update.class) @RequestBody Job resources){ |
|||
jobService.update(resources); |
|||
return ApiResponse.success(ResponseStatus.SUCCESS); |
|||
} |
|||
|
|||
@Log("删除岗位") |
|||
@ApiOperation("删除岗位") |
|||
@DeleteMapping |
|||
|
|||
public ApiResponse<Object> deleteJob(@RequestBody Set<Long> ids){ |
|||
// 验证是否被用户关联 |
|||
jobService.verification(ids); |
|||
jobService.delete(ids); |
|||
return ApiResponse.success(ResponseStatus.SUCCESS); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue