|
@@ -0,0 +1,316 @@
|
|
|
|
|
+package com.jpsoft.employment.modules.base.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.entity.FeedbackMethod;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.entity.LoveProject;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.entity.RegUser;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.service.FeedbackMethodService;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.service.LoveProjectService;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.service.RegUserService;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.entity.ParticipateProjectInfo;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.service.ParticipateProjectInfoService;
|
|
|
|
|
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.apache.ibatis.mapping.ResultMap;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/base/participateProjectInfo")
|
|
|
|
|
+public class ParticipateProjectInfoController {
|
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ParticipateProjectInfoService participateProjectInfoService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RegUserService regUserService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private LoveProjectService loveProjectService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FeedbackMethodService feedbackMethodService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value="创建空记录")
|
|
|
|
|
+ @GetMapping("create")
|
|
|
|
|
+ public MessageResult<ParticipateProjectInfo> create(){
|
|
|
|
|
+ MessageResult<ParticipateProjectInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ ParticipateProjectInfo participateProjectInfo = new ParticipateProjectInfo();
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setData(participateProjectInfo);
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value="添加信息")
|
|
|
|
|
+ @PostMapping("add")
|
|
|
|
|
+ public MessageResult<ParticipateProjectInfo> add(@RequestBody ParticipateProjectInfo participateProjectInfo,@RequestAttribute String subject){
|
|
|
|
|
+ MessageResult<ParticipateProjectInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ participateProjectInfo.setId(UUID.randomUUID().toString());
|
|
|
|
|
+ participateProjectInfo.setDelFlag(false);
|
|
|
|
|
+ participateProjectInfo.setCreateBy(subject);
|
|
|
|
|
+ participateProjectInfo.setCreateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = participateProjectInfoService.insert(participateProjectInfo);
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(participateProjectInfo);
|
|
|
|
|
+ } 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="获取信息")
|
|
|
|
|
+ @GetMapping("edit/{id}")
|
|
|
|
|
+ public MessageResult<ParticipateProjectInfo> edit(@PathVariable("id") String id){
|
|
|
|
|
+ MessageResult<ParticipateProjectInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ ParticipateProjectInfo participateProjectInfo = participateProjectInfoService.get(id);
|
|
|
|
|
+
|
|
|
|
|
+ if (participateProjectInfo != null) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(participateProjectInfo);
|
|
|
|
|
+ } 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="更新用户")
|
|
|
|
|
+ @PostMapping("update")
|
|
|
|
|
+ public MessageResult<ParticipateProjectInfo> update(@RequestBody ParticipateProjectInfo participateProjectInfo,@RequestAttribute String subject){
|
|
|
|
|
+ MessageResult<ParticipateProjectInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ participateProjectInfo.setUpdateBy(subject);
|
|
|
|
|
+ participateProjectInfo.setUpdateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = participateProjectInfoService.update(participateProjectInfo);
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(participateProjectInfo);
|
|
|
|
|
+ } 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="删除用户")
|
|
|
|
|
+ @PostMapping("delete/{id}")
|
|
|
|
|
+ public MessageResult<ParticipateProjectInfo> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
|
|
+ MessageResult<ParticipateProjectInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ ParticipateProjectInfo participateProjectInfo = participateProjectInfoService.get(id);
|
|
|
|
|
+ participateProjectInfo.setDelFlag(true);
|
|
|
|
|
+ participateProjectInfo.setUpdateBy(subject);
|
|
|
|
|
+ participateProjectInfo.setUpdateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = participateProjectInfoService.update(participateProjectInfo);
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ } 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="批量删除")
|
|
|
|
|
+ @PostMapping("batchDelete")
|
|
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
|
|
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ int affectCount = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (String id : idList) {
|
|
|
|
|
+ ParticipateProjectInfo participateProjectInfo = participateProjectInfoService.get(id);
|
|
|
|
|
+ participateProjectInfo.setDelFlag(true);
|
|
|
|
|
+ participateProjectInfo.setUpdateBy(subject);
|
|
|
|
|
+ participateProjectInfo.setUpdateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ affectCount += participateProjectInfoService.update(participateProjectInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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 = "pageList",method = RequestMethod.POST)
|
|
|
|
|
+ public MessageResult<Map> pageList(
|
|
|
|
|
+ String regUserName,String loveProjectTitle,String status,
|
|
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
|
|
+ HttpServletRequest request){
|
|
|
|
|
+ String subject = (String)request.getAttribute("subject");
|
|
|
|
|
+
|
|
|
|
|
+ //当前用户ID
|
|
|
|
|
+ System.out.println(subject);
|
|
|
|
|
+
|
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(regUserName)) {
|
|
|
|
|
+ searchParams.put("regUserName",regUserName + "%");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(loveProjectTitle)) {
|
|
|
|
|
+ searchParams.put("loveProjectTitle",loveProjectTitle + "%");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(status)) {
|
|
|
|
|
+ searchParams.put("status",status);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Page<ParticipateProjectInfo> page = participateProjectInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
|
+
|
|
|
|
|
+ for (ParticipateProjectInfo participateProjectInfo:page) {
|
|
|
|
|
+ RegUser regUser = regUserService.get(participateProjectInfo.getRegUserId());
|
|
|
|
|
+ if(regUser!=null){
|
|
|
|
|
+ participateProjectInfo.setRegUserName(regUser.getRealName());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LoveProject loveProject = loveProjectService.get(participateProjectInfo.getLoveProjectId());
|
|
|
|
|
+ if(loveProject!=null){
|
|
|
|
|
+ participateProjectInfo.setLoveProjectTitle(loveProject.getTitle());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ FeedbackMethod feedbackMethod = feedbackMethodService.get(participateProjectInfo.getFeedbackId());
|
|
|
|
|
+ if(feedbackMethod!=null){
|
|
|
|
|
+ participateProjectInfo.setFeedbackName(feedbackMethod.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String statusN = dataDictionaryService.findNameByCatalogNameAndValue("参与项目状态",participateProjectInfo.getStatus());
|
|
|
|
|
+ if(StringUtils.isNotEmpty(statusN)){
|
|
|
|
|
+ participateProjectInfo.setStatusN(statusN);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value="更改状态")
|
|
|
|
|
+ @PostMapping("changeStatus")
|
|
|
|
|
+ public MessageResult<ParticipateProjectInfo> changeStatus(String id,String status,@RequestAttribute String subject){
|
|
|
|
|
+ MessageResult<ParticipateProjectInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ ParticipateProjectInfo participateProjectInfo = participateProjectInfoService.get(id);
|
|
|
|
|
+ participateProjectInfo.setStatus(status);
|
|
|
|
|
+ if(status.equals("2")){
|
|
|
|
|
+ participateProjectInfo.setCompletionTime(now);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ participateProjectInfo.setCompletionTime(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ participateProjectInfo.setUpdateBy(subject);
|
|
|
|
|
+ participateProjectInfo.setUpdateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = participateProjectInfoService.update(participateProjectInfo);
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage("数据库删除失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception ex){
|
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|