| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- package com.goafanti.demand.controller;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.goafanti.admin.service.AftFileService;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.CertifyApiController;
- import com.goafanti.common.enums.AttachmentType;
- import com.goafanti.common.enums.DeleteStatus;
- import com.goafanti.common.enums.DemandAuditStatus;
- import com.goafanti.common.model.AftFile;
- import com.goafanti.common.model.Demand;
- import com.goafanti.common.model.DemandPublish;
- import com.goafanti.common.utils.StringUtils;
- import com.goafanti.demand.service.DemandFollowService;
- import com.goafanti.demand.service.DemandOrderService;
- import com.goafanti.demand.service.DemandPublishPageService;
- import com.goafanti.demand.service.DemandPublishService;
- import com.goafanti.demand.service.DemandService;
- import com.goafanti.user.service.UserService;
- @RestController
- @RequestMapping(value = "/api/admin/demand")
- public class AdminDemandApiController extends CertifyApiController {
- @Resource
- private DemandService demandService;
- @Resource
- private UserService userService;
- @Resource
- private AftFileService aftFileService;
- @Resource
- private DemandOrderService demandOrderService;
- @Resource
- DemandPublishService demandPublishService;
- @Resource
- DemandFollowService demandFollowService;
- /**
- * 科技需求匹配科技成果
- */
- @RequestMapping(value = "/matchAchievement", method = RequestMethod.POST)
- public Result matchAchievement(String id) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "成果ID"));
- return res;
- }
- Demand d = demandService.selectByPrimaryKey(id);
- if (null == d|| !DeleteStatus.UNDELETE.getCode().equals(d.getDeletedSign())
- || !DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())) {
- res.getError().add(buildError("", "当前状态无法匹配!"));
- return res;
- }
- res.setData(demandService.updateMatchAchievement(d));
- return res;
- }
-
- /**
- * 下载技术需求批量导入Excel模板
- *
- * @param response
- * @return
- */
- @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
- public Result downloadTemplateFile(HttpServletResponse response, String sign) {
- Result res = new Result();
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.DEMAND_TEMPLATE) {
- String fileName = "";
- AftFile af = aftFileService.selectAftFileBySign(sign);
- if (null == af) {
- res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
- } else {
- String path = af.getFilePath();
- String suffix = path.substring(path.lastIndexOf("."));
- fileName = AttachmentType.DEMAND_TEMPLATE.getDesc() + suffix;
- downloadFile(response, fileName, path);
- }
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 个人用户--需求列表
- */
- @RequestMapping(value = "/userList", method = RequestMethod.GET)
- public Result userList(String pageNo, String pageSize) {
- Result res = new Result();
- //res.setData(null); TODO
- return res;
- }
- /**
- * 组织用户--需求列表(个人组织合并)
- */
- @RequestMapping(value = "/orgList", method = RequestMethod.GET)
- public Result orgList(String pageNo, String pageSize) {
- Result res = new Result();
- //res.setData(null); TODO
- return res;
- }
- /**
- * 需求列表
- * @param pageNo
- * @param pageSize
- * @return
- */
- @RequestMapping(value = "/list", method = RequestMethod.GET)
- public Result list(String name,String employerName,Integer demandType,
- Integer auditStatus,Integer status,String startDate, String endDate,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(demandService.listDemand(name, employerName, demandType, auditStatus, status,startDate,endDate, pageNo, pageSize));
- return res;
- }
-
- /**
- * 个人需求详情
- */
- @RequestMapping(value = "/userDemandDetail", method = RequestMethod.GET)
- public Result userDemandDetail(String id) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
- return res;
- }
- res.setData(demandService.selectUserDemandDetail(id));
- return res;
- }
- /**
- * 组织用户详情(个人组织合并)
- */
- @RequestMapping(value = "/orgDemandDetail", method = RequestMethod.GET)
- public Result orgDemandDetail(String id,Integer dataCategory) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
- return res;
- }
- if(dataCategory==0){
- res.setData(demandService.selectUserDemandDetail(id));
- return res;
- }else if(dataCategory==1){
- res.setData(demandService.selectOrgDemandDetail(id));
- return res;
- }
- return res;
- }
-
- /**
- * 需求详情
- * @param id
- * @return
- */
- @RequestMapping(value = "/demandDetail", method = RequestMethod.GET)
- public Result demandDetail(String id){
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
- return res;
- }
- res.setData(demandService.selectDemandDetail(id));
- return res;
- }
-
- /**
- * 审核需求
- * @param id
- * @param auditResult
- * @return
- */
-
- @RequestMapping(value = "/auditDemand", method = RequestMethod.GET)
- public Result auditDemand(String id, Integer auditResult,String auditInfo){
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
- return res;
- }
- Demand d = demandService.selectByPrimaryKey(id);
- if (null == d) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
- return res;
- }
- if(d.getAuditStatus() != DemandAuditStatus.INAUDIT.getCode()){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求未达审核条件"));
- return res;
- }
- if(AFTConstants.NO == auditResult && StringUtils.isBlank(auditInfo)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需填写审核意见"));
- return res;
- }
- if(AFTConstants.YES == auditResult || AFTConstants.NO == auditResult){
- d.setAuditStatus(auditResult);
- }
- demandService.updateByPrimaryKeySelective(d);
- return res;
- }
-
- /**
- * 需求管理--获取个人用户下拉
- */
- @RequestMapping(value = "/userNames", method = RequestMethod.GET)
- public Result getUserNames() {
- Result res = new Result();
- res.setData(userService.selectDemandUserNames());
- return res;
- }
- /**
- * 需求管理--获取组织用户下拉
- */
- @RequestMapping(value = "/unitNames", method = RequestMethod.GET)
- public Result getUnitNames() {
- Result res = new Result();
- res.setData(userService.selectDemandUnitNames());
- return res;
- }
- /**
- * 需求资料--图片上传
- */
- @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
- public Result uploadPicture(HttpServletRequest req, String sign, String uid) {
- Result res = new Result();
- if (StringUtils.isBlank(uid)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
- return res;
- }
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.DEMAND_PICTURE|| attachmentType == AttachmentType.DEMAND_COVER_PICTURE) {
- res.setData(handleFiles(res, "/demand/", false, req, sign, uid));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 需求资料--文本文件上传
- */
- @RequestMapping(value = "/uploadTextFile", method = RequestMethod.POST)
- public Result uploadTextFile(HttpServletRequest req, String sign, String uid) {
- Result res = new Result();
- if (StringUtils.isBlank(uid)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
- return res;
- }
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
- res.setData(handleFiles(res, "/demand/", false, req, sign, uid));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 需求撤消发布(下架)
- */
- @RequestMapping(value = "/offShelf", method = RequestMethod.POST)
- public Result offShelf(String id,Integer releaseStatus) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
- return res;
- }
- Demand d = demandService.selectByPrimaryKey(id);
- if (null == d) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
- return res;
- }
- d.setReleaseStatus(releaseStatus);
- res.setData(demandService.updateReleaseStatus(d));
- return res;
- }
- /**
- * 下载需求文件--文本文件
- */
- @RequestMapping(value = "/download", method = RequestMethod.GET)
- public Result download(HttpServletResponse response, String id) {
- Result res = new Result();
- if (StringUtils.isEmpty(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
- return res;
- }
- Demand d = demandService.selectByPrimaryKey(id);
- if (null == d) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
- return res;
- }
- downloadUnPrivateFile(response, d.getTextFileDownloadFileName(), d.getTextFileUrl());
- return res;
- }
- /**
- * 我的需求列表
- */
- @RequestMapping(value = "/myList", method = RequestMethod.GET)
- public Result myList(String pageNo, String pageSize) {
- Result res = new Result();
- // res.setData(null) todo;
- return res;
- }
-
- /**
- * 需求发布
- */
- @RequestMapping(value = "/addDemandPublish", method = RequestMethod.POST)
- private Result addDemandPublish(DemandPublish d) {
- Result res = new Result();
- if (StringUtils.isBlank(d.getDemandId())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求", "需求"));
- return res;
- }
- res.setData(demandPublishService.insertDemandPublish(d));
- return res;
- }
- /**
- * 撤销发布
- */
- @RequestMapping(value = "/deletePublish", method = RequestMethod.GET)
- private Result deletePublish(String id) {
- Result res = new Result();
- res.setData(demandPublishService.deletePublish(id));
- return res;
- }
- /**
- * 修改发布
- */
- @RequestMapping(value = "/updatePublish", method = RequestMethod.GET)
- private Result updatePublish(DemandPublish d) {
- Result res = new Result();
- res.setData(demandPublishService.updatePublish(d));
- return res;
- }
-
- /**
- * 发布列表
- */
- @RequestMapping(value = "/listPublish", method = RequestMethod.GET)
- private Result listPublish(String name,String publishPlatform,Integer publishClient,String publishPage,
- Integer ifTop, Integer pageNo, Integer pageSize,String employerName) {
- Result res = new Result();
- if (null==pageNo) {
- pageNo=1;
- }
- if (null==pageSize) {
- pageSize=10;
- }
- res.setData(demandPublishService.listPublish( name, publishPlatform, publishClient, publishPage,
- ifTop, pageNo, pageSize,employerName));
- return res;
- }
- /**
- * 获取需求页面位置
- */
- @RequestMapping(value="/getPublishPage",method = RequestMethod.GET)
- private Result getPublishPage(){
- Result res=new Result();
- return res.data(DemandPublishPageService.getBranchInformation());
- }
-
- }
|