package ink.wgink.module.article.controller.api.content;

import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.article.pojo.dtos.content.ContentDTO;
import ink.wgink.module.article.pojo.vos.content.ContentVO;
import ink.wgink.module.article.service.content.IContentDataAuthService;
import ink.wgink.module.article.service.content.IContentService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultData;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.util.RegexUtil;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: ArticleContentController
 * @Description: 文章内容
 * @Author: WenG
 * @Date: 2020-04-03 15:37
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "文章内容数据权限接口")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/content/data-auth")
public class ContentDataAuthController extends DefaultBaseController {

    @Autowired
    private IContentDataAuthService contentDataAuthService;

    @ApiOperation(value = "文章内容列表", notes = "文章内容列表接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "categoryId", value = "文章目录", paramType = "query", dataType = "String")
    })
    @GetMapping("list")
    public List<ContentDTO> list() {
        Map<String, Object> params = requestParams();
        return contentDataAuthService.list(params);
    }

    @ApiOperation(value = "文章内容分页列表", notes = "文章内容分页列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
            @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
            @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "categoryId", value = "文章目录", paramType = "query", dataType = "String")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("listpage")
    public SuccessResultList<List<ContentDTO>> listPage(ListPage page) {
        Map<String, Object> params = requestParams();
        page.setParams(params);
        return contentDataAuthService.listPage(page);
    }

}