|
|
@@ -1,18 +1,19 @@
|
|
|
package com.uas.console.donate.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.console.donate.model.Org;
|
|
|
import com.uas.console.donate.service.OrgService;
|
|
|
+import com.uas.dfs.service.FileClient;
|
|
|
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.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Controller
|
|
|
@@ -21,46 +22,118 @@ public class OrgController {
|
|
|
@Autowired
|
|
|
private OrgService orgService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FileClient fileClient;
|
|
|
+
|
|
|
/**
|
|
|
- * 获取未通知的机构列表
|
|
|
+ * 发起机构,有草稿取出草稿,没有草稿就新增
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
- @RequestMapping("/unnotify")
|
|
|
- public Page<Org> findUnnotify(@RequestParam(value = "page",defaultValue = "0")Integer page,
|
|
|
- @RequestParam(value = "size",defaultValue = "10")Integer size){
|
|
|
- Pageable pageable=pageSort(page,size);
|
|
|
-
|
|
|
- return orgService.findUnnotify(pageable);
|
|
|
+ @RequestMapping("/show")
|
|
|
+ public Org show(){
|
|
|
+ return orgService.show();
|
|
|
}
|
|
|
- private Pageable pageSort(Integer page,Integer size){
|
|
|
- Sort.Order timeSort=new Sort.Order(Sort.Direction.DESC,"createTime");
|
|
|
- List<Sort.Order> list=new ArrayList<Sort.Order>();
|
|
|
- list.add(timeSort);
|
|
|
- Sort sort = new Sort(list);
|
|
|
- Pageable pageable=new PageRequest(page,size,sort);
|
|
|
- return pageable;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存机构草稿
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping("/save")
|
|
|
+ public Org save(@RequestParam(required = false) MultipartFile logo,
|
|
|
+ @RequestParam(required = false) MultipartFile certificate,
|
|
|
+ @RequestParam(required = false) MultipartFile personCertificate,
|
|
|
+ @RequestParam(required = false) MultipartFile donateCertificate,
|
|
|
+ @RequestParam(required = false) MultipartFile legalIdCard,
|
|
|
+ @RequestParam(required = false) MultipartFile material,
|
|
|
+ @RequestParam(required = false) MultipartFile certify,
|
|
|
+ String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException{
|
|
|
+
|
|
|
+ Org org= JSONObject.parseObject(jsonStr,Org.class);
|
|
|
+
|
|
|
+ if (logo!=null) {
|
|
|
+ String file1=fileClient.upload(logo.getBytes(),logo.getSize(),"jpg",null);
|
|
|
+ org.setLogo(file1);
|
|
|
+ }
|
|
|
+ if(certificate!=null){
|
|
|
+ String file2=fileClient.upload(certificate.getBytes(),certificate.getSize(),"jpg",null);
|
|
|
+ org.setCertificate(file2);
|
|
|
+ }
|
|
|
+ if(personCertificate!=null){
|
|
|
+ String file3=fileClient.upload(personCertificate.getBytes(),personCertificate.getSize(),"jpg",null);
|
|
|
+ org.setPersonCertificate(file3);
|
|
|
+ }
|
|
|
+ if(donateCertificate!=null){
|
|
|
+ String file4=fileClient.upload(donateCertificate.getBytes(),donateCertificate.getSize(),"jpg",null);
|
|
|
+ org.setDonateCertificate(file4);
|
|
|
+ }
|
|
|
+ if(legalIdCard!=null){
|
|
|
+ String file5=fileClient.upload(legalIdCard.getBytes(),legalIdCard.getSize(),"jpg",null);
|
|
|
+ org.setLegalIdCard(file5);
|
|
|
+ }
|
|
|
+ if(material!=null){
|
|
|
+ String file6=fileClient.upload(material.getBytes(),material.getSize(),"jpg",null);
|
|
|
+ org.setMaterial(file6);
|
|
|
+ }
|
|
|
+ if(certify!=null){
|
|
|
+ String file7=fileClient.upload(certify.getBytes(),certify.getSize(),"jpg",null);
|
|
|
+ org.setCertify(file7);
|
|
|
+ }
|
|
|
+
|
|
|
+ return orgService.save(org);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取已审核的机构列表
|
|
|
+ *提交机构申请
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
- @RequestMapping("/checked")
|
|
|
- public Page<Org> findChecked(@RequestParam(value = "page",defaultValue = "0")Integer page,
|
|
|
- @RequestParam(value = "size",defaultValue = "10")Integer size){
|
|
|
- Pageable pageable=pageSort(page,size);
|
|
|
- return orgService.findChecked(pageable);
|
|
|
+ @RequestMapping("/submit")
|
|
|
+ public Org submit(@RequestParam(required = false) MultipartFile logo,
|
|
|
+ @RequestParam(required = false) MultipartFile certificate,
|
|
|
+ @RequestParam(required = false) MultipartFile personCertificate,
|
|
|
+ @RequestParam(required = false) MultipartFile donateCertificate,
|
|
|
+ @RequestParam(required = false) MultipartFile legalIdCard,
|
|
|
+ @RequestParam(required = false) MultipartFile material,
|
|
|
+ @RequestParam(required = false) MultipartFile certify,
|
|
|
+ String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException{
|
|
|
+ Org org= JSONObject.parseObject(jsonStr,Org.class);
|
|
|
+ if (logo != null) {
|
|
|
+ String file1=fileClient.upload(logo.getBytes(),logo.getSize(),"jpg",null);
|
|
|
+ org.setLogo(file1);
|
|
|
+ }
|
|
|
+ if(certificate!=null){
|
|
|
+ String file2=fileClient.upload(certificate.getBytes(),certificate.getSize(),"jpg",null);
|
|
|
+ org.setCertificate(file2);
|
|
|
+ }
|
|
|
+ if(personCertificate!=null){
|
|
|
+ String file3=fileClient.upload(personCertificate.getBytes(),personCertificate.getSize(),"jpg",null);
|
|
|
+ org.setPersonCertificate(file3);
|
|
|
+ }
|
|
|
+ if(donateCertificate!=null){
|
|
|
+ String file4=fileClient.upload(donateCertificate.getBytes(),donateCertificate.getSize(),"jpg",null);
|
|
|
+ org.setDonateCertificate(file4);
|
|
|
+ }
|
|
|
+ if(legalIdCard!=null){
|
|
|
+ String file5=fileClient.upload(legalIdCard.getBytes(),legalIdCard.getSize(),"jpg",null);
|
|
|
+ org.setLegalIdCard(file5);
|
|
|
+ }
|
|
|
+ if(material!=null){
|
|
|
+ String file6=fileClient.upload(material.getBytes(),material.getSize(),"jpg",null);
|
|
|
+ org.setMaterial(file6);
|
|
|
+ }
|
|
|
+ if(certify!=null){
|
|
|
+ String file7=fileClient.upload(certify.getBytes(),certify.getSize(),"jpg",null);
|
|
|
+ org.setCertify(file7);
|
|
|
+ }
|
|
|
+ return orgService.sumbit(org);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取未通过的机构列表
|
|
|
+ * 查询某一机构详情信息
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
- @RequestMapping("/refused")
|
|
|
- public Page<Org> findRefused(@RequestParam(value = "page",defaultValue = "0")Integer page,
|
|
|
- @RequestParam(value = "size",defaultValue = "10")Integer size){
|
|
|
- Pageable pageable=pageSort(page,size);
|
|
|
- return orgService.findRefused(pageable);
|
|
|
+ @RequestMapping("/detail")
|
|
|
+ public Org detail(Long id){
|
|
|
+ return orgService.findOne(id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -81,4 +154,23 @@ public class OrgController {
|
|
|
return orgService.unapprove(id,refuse);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 展示特定机构信息
|
|
|
+ * type=0,展示全部type,major=0展示所有major
|
|
|
+ * 默认展示已审核的机构信息
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping("/showOrgs")
|
|
|
+ public List<Org> showOrgs(@RequestParam(defaultValue ="0") Integer type, @RequestParam(defaultValue="0") Integer majorArea, @RequestParam(defaultValue="1")Integer status) {
|
|
|
+ if (type == 0 && majorArea != 0) {
|
|
|
+ return orgService.findByMajorArea(majorArea,status);
|
|
|
+ } else if (type != 0 && majorArea == 0) {
|
|
|
+ return orgService.findByType(type,status);
|
|
|
+ } else if(type!=0 && majorArea!=0 ){
|
|
|
+ return orgService.findByTypeAndMajorArea(type, majorArea,status);
|
|
|
+ }else{
|
|
|
+ return orgService.findByStatus(status);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|