package com.cftech.questionnaire.core.paper_read.web;

import com.alibaba.fastjson.JSONObject;
import com.cftech.questionnaire.core.paper_read.model.Paper_read;
import com.cftech.questionnaire.core.paper_read.service.Paper_readService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 问卷浏览接口
 * Created by Ago on 2018/10/10.
 */
@RestController
@RequestMapping(value = "/mobile/auth/paperredadd")
public class MobilePaper_readController {
    @Autowired
    private Paper_readService paper_readService;

    /**
     * 问卷浏览
     * @param paper_read
     * @return
     */
    @RequestMapping(value = "/paperaddren",method = {RequestMethod.GET,RequestMethod.POST},produces = MediaType.APPLICATION_JSON_UTF8_VALUE )
    public JSONObject paperaddren(Paper_read paper_read){
        JSONObject jsonObject = new JSONObject();
        try {
            if(paper_read!=null){
                boolean flag = paper_readService.save(paper_read);
                if(flag){
                    jsonObject.put("errorNo",0);
                }
            }else{
                jsonObject.put("errorNo",2);
            }
        }catch (Exception e){
            e.printStackTrace();
            jsonObject.put("errorNo",1);
        }
        return jsonObject;
    }
}
