|
|
@@ -1,11 +1,16 @@
|
|
|
package com.jpsoft.employment.modules.job.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
-import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
-import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.employment.modules.base.entity.Company;
|
|
|
+import com.jpsoft.employment.modules.base.service.CompanyService;
|
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
+import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.employment.modules.job.entity.Recruitment;
|
|
|
import com.jpsoft.employment.modules.job.service.RecruitmentService;
|
|
|
+import com.jpsoft.employment.modules.sys.entity.DataDictionary;
|
|
|
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -19,20 +24,41 @@ import java.util.*;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/job/recruitment")
|
|
|
+@Api(description = "recruitment")
|
|
|
public class RecruitmentController {
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
private RecruitmentService recruitmentService;
|
|
|
+ @Autowired
|
|
|
+ private CompanyService companyService;
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @ApiOperation(value="创建空记录")
|
|
|
+ @GetMapping("create")
|
|
|
+ public MessageResult<Recruitment> create(){
|
|
|
+ MessageResult<Recruitment> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Recruitment recruitment = new Recruitment();
|
|
|
+
|
|
|
+ msgResult.setData(recruitment);
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value="添加信息")
|
|
|
@PostMapping("add")
|
|
|
- public MessageResult<Recruitment> add(@ModelAttribute Recruitment recruitment){
|
|
|
+ public MessageResult<Recruitment> add(@RequestBody Recruitment recruitment,@RequestAttribute String subject){
|
|
|
MessageResult<Recruitment> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
recruitment.setId(UUID.randomUUID().toString());
|
|
|
-
|
|
|
+ recruitment.setDelFlag(false);
|
|
|
+ recruitment.setCreateBy(subject);
|
|
|
+ recruitment.setCreateTime(new Date());
|
|
|
+
|
|
|
int affectCount = recruitmentService.insert(recruitment);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
@@ -54,8 +80,8 @@ public class RecruitmentController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value="获取信息")
|
|
|
- @GetMapping("detail/{id}")
|
|
|
- public MessageResult<Recruitment> detail(@PathVariable("id") String id){
|
|
|
+ @GetMapping("edit/{id}")
|
|
|
+ public MessageResult<Recruitment> edit(@PathVariable("id") String id){
|
|
|
MessageResult<Recruitment> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
@@ -81,10 +107,13 @@ public class RecruitmentController {
|
|
|
|
|
|
@ApiOperation(value="更新用户")
|
|
|
@PostMapping("update")
|
|
|
- public MessageResult<Recruitment> update(@ModelAttribute Recruitment recruitment){
|
|
|
+ public MessageResult<Recruitment> update(@RequestBody Recruitment recruitment,@RequestAttribute String subject){
|
|
|
MessageResult<Recruitment> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
+ recruitment.setUpdateBy(subject);
|
|
|
+ recruitment.setUpdateTime(new Date());
|
|
|
+
|
|
|
int affectCount = recruitmentService.update(recruitment);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
@@ -105,19 +134,25 @@ public class RecruitmentController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="删除用户")
|
|
|
+ @ApiOperation(value="删除")
|
|
|
@PostMapping("delete/{id}")
|
|
|
- public MessageResult<Recruitment> delete(@PathVariable("id") String id){
|
|
|
- MessageResult<Recruitment> msgResult = new MessageResult<>();
|
|
|
+ public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
- int affectCount = recruitmentService.delete(id);
|
|
|
+ Recruitment recruitment = recruitmentService.get(id);
|
|
|
+ recruitment.setDelFlag(true);
|
|
|
+ recruitment.setUpdateBy(subject);
|
|
|
+ recruitment.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ int affectCount = recruitmentService.update(recruitment);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
|
+ msgResult.setData(affectCount);
|
|
|
} else {
|
|
|
msgResult.setResult(false);
|
|
|
- msgResult.setMessage("数据库删除失败");
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex){
|
|
|
@@ -132,24 +167,47 @@ public class RecruitmentController {
|
|
|
|
|
|
|
|
|
@ApiOperation(value="批量删除")
|
|
|
- @PostMapping("batchDelete/{id}")
|
|
|
- public MessageResult<Recruitment> batchDelete(@PathVariable("id") String id){
|
|
|
- MessageResult<Recruitment> msgResult = new MessageResult<>();
|
|
|
+ @PostMapping("batchDelete")
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ int affectCount = 0;
|
|
|
|
|
|
- msgResult.setResult(false);
|
|
|
- msgResult.setMessage("未实现");
|
|
|
+ for (String id : idList) {
|
|
|
+ Recruitment recruitment = recruitmentService.get(id);
|
|
|
+ recruitment.setDelFlag(true);
|
|
|
+ recruitment.setUpdateBy(subject);
|
|
|
+ recruitment.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ affectCount += recruitmentService.update(recruitment);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(affectCount);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "list",method = RequestMethod.POST)
|
|
|
- public MessageResult<Map> list(
|
|
|
+ @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
+ public MessageResult<Map> pageList(
|
|
|
String id,
|
|
|
@RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
@RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
- HttpServletRequest request){
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
+ @RequestAttribute String subject){
|
|
|
|
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
|
@@ -165,9 +223,24 @@ public class RecruitmentController {
|
|
|
searchParams.put("id","%" + id + "%");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Page<Recruitment> page = recruitmentService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
-
|
|
|
+ for(Recruitment recruitment : page.getResult()){
|
|
|
+ Company company = companyService.get(recruitment.getCompanyId());
|
|
|
+ recruitment.setCompanyName(company.getName());
|
|
|
+
|
|
|
+ DataDictionary dataDictionary = new DataDictionary();
|
|
|
+ dataDictionary = dataDictionaryService.get(recruitment.getWorkYear());
|
|
|
+ recruitment.setWorkYearName(dataDictionary.getName());
|
|
|
+ dataDictionary = dataDictionaryService.get(recruitment.getEducation());
|
|
|
+ recruitment.setEducationName(dataDictionary.getName());
|
|
|
+ if(recruitment.getIsDiscussPersonally()){
|
|
|
+ recruitment.setWageTypeName("面议");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ dataDictionary = dataDictionaryService.get(recruitment.getWageType());
|
|
|
+ recruitment.setWageTypeName(dataDictionary.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(PojoUtils.pageWrapper(page));
|