package com.goafanti.sc.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.goafanti.common.bo.Result;
import com.goafanti.common.constant.ErrorConstants;
import com.goafanti.common.controller.CertifyApiController;
import com.goafanti.common.utils.StringUtils;
import com.goafanti.sc.bo.inputDemands;
import com.goafanti.sc.service.ScAchievementService;
import com.goafanti.sc.service.ScDemandService;

@RestController
@RequestMapping(value = "/open/api")
public class ScDemandApiController extends CertifyApiController {
	@Resource
    private ScAchievementService		scachievementService;
	@Resource
	private ScDemandService				ScDemandService;
    
    /**
     * 新增需求
     */
    @RequestMapping(value = "/addDemand", method = RequestMethod.POST)
    private Result addDemand(inputDemands a ) {
        Result res = new Result();
       res.setData(ScDemandService.addDemands(a));
       return res;
    }
    
   /**
     * 需求列表
     */
    @RequestMapping(value = "/demandList", method = RequestMethod.GET)
    private Result demandList(String reserveButtUnit,String type,String name,String orgName,Integer pageSize,Integer pageNo) {
        Result res = new Result();
       res.setData(ScDemandService.DemandList(reserveButtUnit,type,name,orgName,pageSize,pageNo));
       return res;
    }
   /**
    * 删除需求
    */
    @RequestMapping(value = "/delectDemand", method = RequestMethod.GET)
    private Result delectDemand(String id){
    	Result res = new Result();
    	if (StringUtils.isBlank(id)) {
         	 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果", "成果ID"));
              return res;
  		}
    	 res.setData(ScDemandService.delectDemand(id));
    	 return res;
    }
    /**
     * 修改成果
     */
     @RequestMapping(value = "/updateDemand", method = RequestMethod.POST)
     private Result updateDemand(inputDemands a){
     	Result res = new Result();
     	 res.setData(ScDemandService.updateDemand(a));
     	 return res;
     }
     /**
      * 需求详情
      */
      @RequestMapping(value = "/demandDetails", method = RequestMethod.GET)
      private Result demandDetails(String id){
      	Result res = new Result();
      	if (StringUtils.isBlank(id)) {
           	 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果", "成果ID"));
                return res;
    		}
      	 res.setData(ScDemandService.demandDetails(id));
      	 return res;
      }
    
       
}