package com.fs.app.controller;

import cn.hutool.json.JSONUtil;
import com.fs.store.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.servlet.ModelAndView;

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

    @Autowired
    private ISysConfigService configService;


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

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

        ModelAndView mv=new ModelAndView();
        mv.addObject("userAgreement", config.getUserAgreement());
        mv.setViewName("userAgreement");
        return mv;
    }
    @GetMapping("/privacyPolicy")
    public ModelAndView privacyPolicy( )
    {
        String json=configService.selectConfigByKey("store.agreement");
        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
        ModelAndView mv=new ModelAndView();
        mv.addObject("privacyPolicy", config.getPrivacyPolicy());
        mv.setViewName("privacyPolicy");
        return mv;
    }


}
