|
@@ -1,55 +1,48 @@
|
|
|
package com.uas.console.donate.controller;
|
|
package com.uas.console.donate.controller;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.uas.console.donate.model.Org;
|
|
|
import com.uas.console.donate.model.Project;
|
|
import com.uas.console.donate.model.Project;
|
|
|
|
|
+import com.uas.console.donate.model.ProjectRecode;
|
|
|
|
|
+import com.uas.console.donate.service.ProjectRecodeService;
|
|
|
import com.uas.console.donate.service.ProjectService;
|
|
import com.uas.console.donate.service.ProjectService;
|
|
|
|
|
+import com.uas.dfs.service.FileClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
|
|
-import org.springframework.data.domain.Pageable;
|
|
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import javax.sql.DataSource;
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
@Controller
|
|
@Controller
|
|
|
@RequestMapping("/project")
|
|
@RequestMapping("/project")
|
|
|
public class ProjectController {
|
|
public class ProjectController {
|
|
|
|
|
|
|
|
|
|
+ private static final SimpleDateFormat codesdf=new SimpleDateFormat("yyyymmddhhmmsssss");
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ProjectService projectService ;
|
|
private ProjectService projectService ;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取所有捐款项目
|
|
|
|
|
- * @param page
|
|
|
|
|
- * @param size
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- @RequestMapping("/getProjects")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public Page<Project> findAll(@RequestParam(value = "page",defaultValue = "0")Integer page,
|
|
|
|
|
- @RequestParam(value = "size",defaultValue = "5")Integer size){
|
|
|
|
|
- Pageable pageable=pageSort(page,size);
|
|
|
|
|
- return projectService.findAll(pageable);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ProjectRecodeService projectRecodeService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FileClient fileClient;
|
|
|
|
|
|
|
|
- /*审核状态正序,时间倒序排序的方式*/
|
|
|
|
|
- private Pageable pageSort(Integer page,Integer size){
|
|
|
|
|
- Sort.Order statusSort=new Sort.Order(Sort.Direction.ASC,"status");
|
|
|
|
|
- Sort.Order timeSort=new Sort.Order(Sort.Direction.DESC,"submitTime");
|
|
|
|
|
- List<Sort.Order> list=new ArrayList<Sort.Order>();
|
|
|
|
|
- list.add(statusSort);
|
|
|
|
|
- list.add(timeSort);
|
|
|
|
|
- Sort sort = new Sort(list);
|
|
|
|
|
- Pageable pageable=new PageRequest(page,size,sort);
|
|
|
|
|
- return pageable;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 审核所有捐款项目
|
|
|
|
|
|
|
+ * 审核通过项目
|
|
|
*/
|
|
*/
|
|
|
@RequestMapping("/approve")
|
|
@RequestMapping("/approve")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@@ -58,7 +51,7 @@ public class ProjectController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 驳回所有捐款项目
|
|
|
|
|
|
|
+ * 审核驳回项目
|
|
|
*/
|
|
*/
|
|
|
@RequestMapping("/unapprove")
|
|
@RequestMapping("/unapprove")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@@ -66,5 +59,150 @@ public class ProjectController {
|
|
|
return projectService.unapprove(id,refuse);
|
|
return projectService.unapprove(id,refuse);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取所有未被活动关联到的项目
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping("/getProjectQualification")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public List<Project> getProjectQualification(){
|
|
|
|
|
+ return projectService.getProjects();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 展示特定项目信息
|
|
|
|
|
+ * area=0,展示全部分类
|
|
|
|
|
+ * 默认展示已审核的项目信息
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @RequestMapping("/showProjects")
|
|
|
|
|
+ public List<Project> showProjects(@RequestParam(defaultValue ="0") Integer area,@RequestParam(defaultValue="1")Integer status) {
|
|
|
|
|
+ if(area==0){
|
|
|
|
|
+ return projectService.findByStatus(status);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return projectService.queryProjects(area,status);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断项目中有没有草稿,有,展示到项目填写表单,没有,就新建表单
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @RequestMapping("/show")
|
|
|
|
|
+ public Project show(){
|
|
|
|
|
+ return projectService.show();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存项目草稿
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @RequestMapping("/save")
|
|
|
|
|
+ public Project save(@RequestParam(required = false) MultipartFile logo,
|
|
|
|
|
+ @RequestParam(required = false) MultipartFile pcImg,
|
|
|
|
|
+ @RequestParam(required = false) MultipartFile mobileImg,
|
|
|
|
|
+ @RequestParam(required = false) MultipartFile listImg,
|
|
|
|
|
+ String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException{
|
|
|
|
|
+
|
|
|
|
|
+ Project project=JSONObject.parseObject(jsonStr,Project.class);
|
|
|
|
|
+ if(logo!=null){
|
|
|
|
|
+ String file1=fileClient.upload(logo.getBytes(),logo.getSize(),"jpg",null);
|
|
|
|
|
+ project.setLogo(file1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(pcImg!=null){
|
|
|
|
|
+ String file2=fileClient.upload(pcImg.getBytes(),pcImg.getSize(),"jpg",null);
|
|
|
|
|
+ project.setPcImg(file2);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(mobileImg!=null){
|
|
|
|
|
+ String file3=fileClient.upload(mobileImg.getBytes(),mobileImg.getSize(),"jpg",null);
|
|
|
|
|
+ project.setMobileImg(file3);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(listImg!=null){
|
|
|
|
|
+ String file4=fileClient.upload(listImg.getBytes(),listImg.getSize(),"jpg",null);
|
|
|
|
|
+ project.setListImg(file4);
|
|
|
|
|
+ }
|
|
|
|
|
+ return projectService.save(project);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上传图片
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @RequestMapping(value = "/upload",method = RequestMethod.POST)
|
|
|
|
|
+ public String ueditorUpload(MultipartFile file) throws IOException {
|
|
|
|
|
+ //上传图片
|
|
|
|
|
+ String path=fileClient.upload(file.getBytes(),file.getSize(),"jpg",null);
|
|
|
|
|
+
|
|
|
|
|
+ return path;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 正式提交项目
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @RequestMapping("/submit")
|
|
|
|
|
+ public Project submit(@RequestParam(required = false) MultipartFile logo,
|
|
|
|
|
+ @RequestParam(required = false) MultipartFile pcImg,
|
|
|
|
|
+ @RequestParam(required = false) MultipartFile mobileImg,
|
|
|
|
|
+ @RequestParam(required = false) MultipartFile listImg,
|
|
|
|
|
+ String jsonStr, HttpServletRequest request, HttpServletResponse response)throws IOException{
|
|
|
|
|
+ Project project = JSONObject.parseObject(jsonStr, Project.class);
|
|
|
|
|
+ if(logo!=null){
|
|
|
|
|
+ String file1=fileClient.upload(logo.getBytes(),logo.getSize(),"jpg",null);
|
|
|
|
|
+ project.setLogo(file1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(pcImg!=null){
|
|
|
|
|
+ String file2=fileClient.upload(pcImg.getBytes(),pcImg.getSize(),"jpg",null);
|
|
|
|
|
+ project.setPcImg(file2);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(mobileImg!=null){
|
|
|
|
|
+ String file3=fileClient.upload(mobileImg.getBytes(),mobileImg.getSize(),"jpg",null);
|
|
|
|
|
+ project.setMobileImg(file3);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(listImg!=null){
|
|
|
|
|
+ String file4=fileClient.upload(listImg.getBytes(),listImg.getSize(),"jpg",null);
|
|
|
|
|
+ project.setListImg(file4);
|
|
|
|
|
+ }
|
|
|
|
|
+ Date date=new Date();
|
|
|
|
|
+ //设置项目提交时间
|
|
|
|
|
+ project.setSubmitTime(date);
|
|
|
|
|
+ //设置项目编号
|
|
|
|
|
+ project.setCode(codesdf.format(date));
|
|
|
|
|
+
|
|
|
|
|
+ return projectService.submit(project);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 取出某项目的,以及该项目对应机构的具体信息
|
|
|
|
|
+ * @param id
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @RequestMapping("/detail")
|
|
|
|
|
+ public List<Object> detail(Long id){
|
|
|
|
|
+ Org org=projectService.findOrgInfo(id);
|
|
|
|
|
+ Project project=projectService.findOne(id);
|
|
|
|
|
+ //项目进度
|
|
|
|
|
+
|
|
|
|
|
+ //捐款信息
|
|
|
|
|
+ List<ProjectRecode> projectRecodeList=projectRecodeService.findProjectDetail(id);
|
|
|
|
|
+ //财务披露
|
|
|
|
|
|
|
|
|
|
+ List<Object> list=new ArrayList<>();
|
|
|
|
|
+ list.add(org);
|
|
|
|
|
+ list.add(project);
|
|
|
|
|
+ list.add(projectRecodeList);
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ *项目列表搜索框查询
|
|
|
|
|
+ * @param search
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @RequestMapping("/search")
|
|
|
|
|
+ public List<Project> search(String search){
|
|
|
|
|
+ return projectService.search(search);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|