|
@@ -3,12 +3,14 @@ package com.jpsoft.employment.modules.base.controller;
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.employment.modules.base.entity.EnterpriseInfo;
|
|
import com.jpsoft.employment.modules.base.entity.EnterpriseInfo;
|
|
|
import com.jpsoft.employment.modules.base.service.EnterpriseInfoService;
|
|
import com.jpsoft.employment.modules.base.service.EnterpriseInfoService;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.dto.FileDTO;
|
|
|
import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
import com.jpsoft.employment.modules.base.entity.TrainingInfo;
|
|
import com.jpsoft.employment.modules.base.entity.TrainingInfo;
|
|
|
import com.jpsoft.employment.modules.base.service.TrainingInfoService;
|
|
import com.jpsoft.employment.modules.base.service.TrainingInfoService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import net.sf.json.JSONArray;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -29,11 +31,11 @@ public class TrainingInfoController {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private EnterpriseInfoService enterpriseInfoService;
|
|
private EnterpriseInfoService enterpriseInfoService;
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- @ApiOperation(value="创建空记录")
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "创建空记录")
|
|
|
@GetMapping("create")
|
|
@GetMapping("create")
|
|
|
- public MessageResult<TrainingInfo> create(){
|
|
|
|
|
|
|
+ public MessageResult<TrainingInfo> create() {
|
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
TrainingInfo trainingInfo = new TrainingInfo();
|
|
TrainingInfo trainingInfo = new TrainingInfo();
|
|
@@ -44,14 +46,14 @@ public class TrainingInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="添加信息")
|
|
|
|
|
|
|
+ @ApiOperation(value = "添加信息")
|
|
|
@PostMapping("add")
|
|
@PostMapping("add")
|
|
|
- public MessageResult<TrainingInfo> add(@RequestBody TrainingInfo trainingInfo,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<TrainingInfo> add(@RequestBody TrainingInfo trainingInfo, @RequestAttribute String subject) {
|
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
trainingInfo.setId(UUID.randomUUID().toString());
|
|
trainingInfo.setId(UUID.randomUUID().toString());
|
|
|
- trainingInfo.setDelFlag(false);
|
|
|
|
|
|
|
+ trainingInfo.setDelFlag(false);
|
|
|
trainingInfo.setCreateBy(subject);
|
|
trainingInfo.setCreateBy(subject);
|
|
|
trainingInfo.setCreateTime(new Date());
|
|
trainingInfo.setCreateTime(new Date());
|
|
|
trainingInfo.setStatus("0");
|
|
trainingInfo.setStatus("0");
|
|
@@ -65,9 +67,8 @@ public class TrainingInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库添加失败");
|
|
msgResult.setMessage("数据库添加失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -76,9 +77,9 @@ public class TrainingInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="获取信息")
|
|
|
|
|
|
|
+ @ApiOperation(value = "获取信息")
|
|
|
@GetMapping("edit/{id}")
|
|
@GetMapping("edit/{id}")
|
|
|
- public MessageResult<TrainingInfo> edit(@PathVariable("id") String id){
|
|
|
|
|
|
|
+ public MessageResult<TrainingInfo> edit(@PathVariable("id") String id) {
|
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -91,9 +92,8 @@ public class TrainingInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -102,15 +102,23 @@ public class TrainingInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="更新用户")
|
|
|
|
|
|
|
+ @ApiOperation(value = "更新用户")
|
|
|
@PostMapping("update")
|
|
@PostMapping("update")
|
|
|
- public MessageResult<TrainingInfo> update(@RequestBody TrainingInfo trainingInfo,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<TrainingInfo> update(@RequestBody TrainingInfo trainingInfo, @RequestAttribute String subject) {
|
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- trainingInfo.setUpdateBy(subject);
|
|
|
|
|
|
|
+ trainingInfo.setUpdateBy(subject);
|
|
|
trainingInfo.setUpdateTime(new Date());
|
|
trainingInfo.setUpdateTime(new Date());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (trainingInfo.getFileList().size() > 0) {
|
|
|
|
|
+ List<FileDTO> fileList = trainingInfo.getFileList();
|
|
|
|
|
+
|
|
|
|
|
+ JSONArray jsonArray = JSONArray.fromObject(fileList);
|
|
|
|
|
+
|
|
|
|
|
+ trainingInfo.setFile(jsonArray.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
int affectCount = trainingInfoService.update(trainingInfo);
|
|
int affectCount = trainingInfoService.update(trainingInfo);
|
|
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
@@ -120,9 +128,8 @@ public class TrainingInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库更新失败");
|
|
msgResult.setMessage("数据库更新失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -131,19 +138,19 @@ public class TrainingInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="删除用户")
|
|
|
|
|
|
|
+ @ApiOperation(value = "删除用户")
|
|
|
@PostMapping("delete/{id}")
|
|
@PostMapping("delete/{id}")
|
|
|
- public MessageResult<TrainingInfo> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<TrainingInfo> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
-
|
|
|
|
|
- TrainingInfo trainingInfo = trainingInfoService.get(id);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ TrainingInfo trainingInfo = trainingInfoService.get(id);
|
|
|
trainingInfo.setDelFlag(true);
|
|
trainingInfo.setDelFlag(true);
|
|
|
trainingInfo.setUpdateBy(subject);
|
|
trainingInfo.setUpdateBy(subject);
|
|
|
trainingInfo.setUpdateTime(new Date());
|
|
trainingInfo.setUpdateTime(new Date());
|
|
|
-
|
|
|
|
|
- int affectCount = trainingInfoService.update(trainingInfo);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = trainingInfoService.update(trainingInfo);
|
|
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
@@ -151,9 +158,8 @@ public class TrainingInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库删除失败");
|
|
msgResult.setMessage("数据库删除失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -163,9 +169,9 @@ public class TrainingInfoController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="批量删除")
|
|
|
|
|
|
|
+ @ApiOperation(value = "批量删除")
|
|
|
@PostMapping("batchDelete")
|
|
@PostMapping("batchDelete")
|
|
|
- public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject) {
|
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -187,9 +193,8 @@ public class TrainingInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("删除失败");
|
|
msgResult.setMessage("删除失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -198,35 +203,35 @@ public class TrainingInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
|
|
- @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
|
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
|
|
+ @RequestMapping(value = "pageList", method = RequestMethod.POST)
|
|
|
public MessageResult<Map> pageList(
|
|
public MessageResult<Map> pageList(
|
|
|
String id,
|
|
String id,
|
|
|
- @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
|
|
- @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
|
|
- HttpServletRequest request){
|
|
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
|
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
|
|
+ HttpServletRequest request) {
|
|
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
|
|
//当前用户ID
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
System.out.println(subject);
|
|
|
|
|
|
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("create_time","desc"));
|
|
|
|
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
|
- searchParams.put("id","%" + id + "%");
|
|
|
|
|
|
|
+ searchParams.put("id", "%" + id + "%");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- Page<TrainingInfo> page = trainingInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
|
|
|
+ Page<TrainingInfo> page = trainingInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
|
|
|
|
|
- for (TrainingInfo trainingInfo:page) {
|
|
|
|
|
|
|
+ for (TrainingInfo trainingInfo : page) {
|
|
|
EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(trainingInfo.getEnterpriseId());
|
|
EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(trainingInfo.getEnterpriseId());
|
|
|
- if(enterpriseInfo!=null){
|
|
|
|
|
|
|
+ if (enterpriseInfo != null) {
|
|
|
trainingInfo.setEnterpriseName(enterpriseInfo.getName());
|
|
trainingInfo.setEnterpriseName(enterpriseInfo.getName());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -239,9 +244,9 @@ public class TrainingInfoController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="审核信息")
|
|
|
|
|
|
|
+ @ApiOperation(value = "审核信息")
|
|
|
@PostMapping("check/{id}")
|
|
@PostMapping("check/{id}")
|
|
|
- public MessageResult<TrainingInfo> check(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<TrainingInfo> check(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
MessageResult<TrainingInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -259,9 +264,8 @@ public class TrainingInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库审核失败");
|
|
msgResult.setMessage("数据库审核失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|