package com.fs.app.controller.store;

import cn.hutool.json.JSONUtil;
import com.fs.hisStore.config.AgreementConfig;
import com.fs.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value="/store/h5")
public class H5ScrmController
{

    @Autowired
    private ISysConfigService configService;


    @GetMapping("/userAgreement")
    public ModelAndView userAgreement( )
    {

        String json=configService.selectConfigByKey("his.agreementConfig");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);

        ModelAndView mv=new ModelAndView();
        mv.addObject("userAgreement", config.getUserRegister());
        mv.setViewName("userAgreement");
        //return R.ok().put("userAgreement", config.getUserRegister());
        return mv;
    }
    @GetMapping("/userAgreementNew")
    @ResponseBody
    public String userAgreementNew(){
        String json=configService.selectConfigByKey("store.agreement");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
        return config.getUserAgreement();
    }
    @GetMapping("/privacyPolicyNew")
    @ResponseBody
    public String privacyPolicyNew( )
    {
        String json=configService.selectConfigByKey("store.agreement");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
        return config.getPrivacyPolicy();
    }
    @GetMapping("/privacyPolicy")
    public ModelAndView privacyPolicy( )
    {
        String json=configService.selectConfigByKey("his.agreementConfig");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
        ModelAndView mv=new ModelAndView();
        mv.addObject("privacyPolicy", config.getUserPrivacy());
        mv.setViewName("privacyPolicy");
        //return R.ok().put("privacyPolicy", config.getUserPrivacy());
        return mv;
    }
    @GetMapping("/doctorRegister")
    public ModelAndView doctorRegister( )
    {
        String json=configService.selectConfigByKey("his.agreementConfig");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
        ModelAndView mv=new ModelAndView();
        mv.addObject("doctorRegister", config.getDoctorRegister());
        mv.setViewName("doctorRegister");
        //return R.ok().put("doctorRegister", config.getDoctorRegister());
        return mv;
    }
    @GetMapping("/doctorFiling")
    public ModelAndView doctorFiling( )
    {
        String json=configService.selectConfigByKey("his.agreementConfig");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
        ModelAndView mv=new ModelAndView();
        mv.addObject("doctorFiling", config.getDoctorFiling());
        mv.setViewName("doctorFiling");
        //return R.ok().put("doctorFiling", config.getDoctorFiling());
        return mv;
    }
    @GetMapping("/userHealth")
    public ModelAndView userHealth( )
    {
        String json=configService.selectConfigByKey("his.agreementConfig");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
        ModelAndView mv=new ModelAndView();
        mv.addObject("userHealth", config.getUserHealth());
        mv.setViewName("userHealth");
        //return R.ok().put("userHealth", config.getUserHealth());
        return mv;
    }
    @GetMapping("/vipService")
    public ModelAndView vipService( )
    {
        String json=configService.selectConfigByKey("his.agreementConfig");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
        ModelAndView mv=new ModelAndView();
        mv.addObject("vipService", config.getVipService());
        mv.setViewName("vipService");
        //return R.ok().put("vipService", config.getVipService());
        return mv;
    }


}
