package com.yiqi.api.controller.system;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yiqi.common.constant.UrlConstants;
import com.yiqi.common.core.controller.BaseController;
import com.yiqi.common.core.domain.R;
import com.yiqi.system.domain.SysDocument;
import com.yiqi.system.service.ISysDocumentService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "文档")
@RestController
@RequestMapping(value = UrlConstants.wxappApi + "/document")
public class WeAppDocumentController extends BaseController {

    @Autowired
    private ISysDocumentService sysDocumentService;

    @ApiOperation("获取文档内容")
    @GetMapping(value = "info")
    public R<SysDocument> info(@RequestParam @ApiParam("0：用户协议，1：隐私政策，2：服务约定 3：积分协议 9：注销约定") String code) throws Exception {
        return R.ok(sysDocumentService.getOne(new QueryWrapper<SysDocument>().lambda().eq(SysDocument::getCode, code), false));
    }
}
