package cn.pluss.platform.controller;

import cn.jiguang.common.utils.StringUtils;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.appGuide.AppGuideService;
import cn.pluss.platform.entity.AppGuide;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author djh
 * 简介富文本内容
 */
@RestController
@RequestMapping("/intro")
public class IntroduceController {

    @Autowired
    private AppGuideService appGuideService;

    @GetMapping({"/common", "/common/{code}"})
    public Result<String> billIntro(@PathVariable(value = "code", required = false) String code) {
        if (StringUtils.isEmpty(code)) {
            String html = "<p><img src=\"https://www.shouyinbei.net/resources/images/upload/82031620725808697.jpg\" style=\"\"/></p><p><img src=\"https://www.shouyinbei.net/resources/images/upload/86751620725811158.jpg\" style=\"\"/></p><p><img src=\"https://www.shouyinbei.net/resources/images/upload/38401620725814105.jpg\" style=\"\"/></p><p><img src=\"https://www.shouyinbei.net/resources/images/upload/14561620725816223.jpg\" style=\"\"/></p><p><img src=\"https://www.shouyinbei.net/resources/images/upload/45071620725822267.jpg\" style=\"\"/></p><p><img src=\"https://www.shouyinbei.net/resources/images/upload/31221620725827105.jpg\" style=\"\"/></p><p><img src=\"https://www.shouyinbei.net/resources/images/upload/68211620725829889.jpg\" style=\"\"/></p><p><br/></p>";
            return ResultGenerator.genSuccessResult(html);
        }

        AppGuide entity = appGuideService.getByCode(code);
        return ResultGenerator.genSuccessResult(entity == null? "": entity.getContent());
    }
}