All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.guerlab.smart.article.web.controller.commons.SimpleArticleController Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2018-2021 guerlab.net and other contributors.
 *
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.guerlab.smart.article.web.controller.commons;

import io.swagger.v3.oas.annotations.tags.Tag;
import net.guerlab.smart.article.core.enums.AuditStatus;
import net.guerlab.smart.article.core.exception.ArticleInvalidException;
import net.guerlab.smart.article.core.searchparams.ArticleSearchParams;
import net.guerlab.smart.article.service.entity.SimpleArticle;
import net.guerlab.smart.article.service.service.SimpleArticleService;
import net.guerlab.smart.article.web.controller.AbstractArticleController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 简单文章
 *
 * @author guer
 */
@Tag(name = "简单文章")
@RestController("/commons/simpleArticle")
@RequestMapping("/commons/simpleArticle")
public class SimpleArticleController extends AbstractArticleController {

    @Override
    protected void beforeFindList(ArticleSearchParams searchParams) {
        searchParams.setPublished(true);
        searchParams.setAuditStatus(AuditStatus.PASS);
    }

    @Override
    protected SimpleArticle findOne0(String id) {
        SimpleArticle dto = super.findOne0(id);

        if (!dto.getPublished()) {
            throw new ArticleInvalidException();
        }

        return dto;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy