package com.cweb.controller.cms;

import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData;
import com.hfkj.service.cms.CmsContentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
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.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping(value="/cms")
@Api(value="cms")
public class CmsContentController {

    Logger log = LoggerFactory.getLogger(CmsContentController.class);

    @Resource
    private CmsContentService cmsContentService;

    @RequestMapping(value="/getCms",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询列表")
    public ResponseData getCms(@RequestParam(value = "code" , required = false) String code,
                               @RequestParam(value = "platformCode" , required = false) String platformCode) {
        try {

            Map<String , Object> map = new HashMap<>();
            map.put("code", code);
            if (platformCode == null) {
                platformCode = "WXAPPLETS";
            }
            map.put("platformCode", platformCode);
            return ResponseMsgUtil.success(cmsContentService.getList(map));

        } catch (Exception e) {
            log.error("error!",e);
            return ResponseMsgUtil.exception(e);
        }
    }

}
