package cn.stylefeng.guns.zjxl.cnotroller;

import cn.stylefeng.guns.zjxl.model.ZjxlBasicInfo;
import cn.stylefeng.guns.zjxl.service.ZjxlBasicInfoService;
import cn.stylefeng.guns.zjxlUtil.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

/***
 * @ClassName: ZjxlBasicInfoController
 * @Description: 公司基本信息
 * @Auther: shi kejing
 * @Date: 2020/11/3 16:00
 */
@RestController
@Api(description = "公司基本信息")
@RequestMapping(value = "/zjxl/basicInfo",name = "公司基本信息")
public class ZjxlBasicInfoController extends BaseController {

    @Autowired
    private ZjxlBasicInfoService basicInfoService;

    @RequestMapping(value = "/addBasicInfo", method = RequestMethod.POST)
    @ApiOperation(value = "编辑基本信息")
    public String addBasicInfo(@ApiParam(name = "basicInfoTel", value = "咨询电话", required = false) @RequestParam(value = "basicInfoTel", required = false)String basicInfoTel,
                               @ApiParam(name = "basicInfoAddress", value = "公司地址", required = false) @RequestParam(value = "basicInfoAddress", required = false)String basicInfoAddress,
                               @ApiParam(name = "basicInfoEmail", value = "公司邮箱", required = false) @RequestParam(value = "basicInfoEmail", required = false)String basicInfoEmail,
                               @ApiParam(name = "basicInfoRecord", value = "备案信息", required = false) @RequestParam(value = "basicInfoRecord", required = false)String basicInfoRecord,//备案信息
                               @ApiParam(name = "basicInfoQrcode", value = "二维码", required = false) @RequestParam(value = "basicInfoQrcode", required = false)String basicInfoQrcode){
        try {
            ZjxlBasicInfo basicInfo = new ZjxlBasicInfo();
            basicInfo.setBasicInfoTel(basicInfoTel);
            basicInfo.setBasicInfoAddress(basicInfoAddress);
            basicInfo.setBasicInfoEmail(basicInfoEmail);
            basicInfo.setBasicInfoRecord(basicInfoRecord);
            basicInfo.setBasicInfoQrcode(basicInfoQrcode);

            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
            basicInfo.setBasicInfoCreateTime(df.format(new Date()));// new Date()为获取当前系统时间

            return write(200,"编辑成功","data",basicInfoService.addBasicInfo(basicInfo));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"编辑失败");
        }
    }
}
