com.cq1080.pages.cotroller.PagesController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Pages Show documentation
Show all versions of Pages Show documentation
Yet Another Spring Boot Framework
The newest version!
package com.cq1080.pages.cotroller;
import com.cq1080.pages.bean.entity.WebPage;
import com.cq1080.pages.service.WebPageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
import javax.annotation.Resource;
@Controller
@RequestMapping
@Api(tags = "通用页面查看")
@RequiredArgsConstructor
@ConditionalOnProperty(value = "yasf.manage.disable",havingValue = "false",matchIfMissing = true)
public class PagesController {
private final WebPageService webPageService;
@ApiOperation("通用页面查看")
@ResponseBody
@GetMapping(value = {"/pages/{name}","/pages/{name}.html"})
public ModelAndView page(@PathVariable String name){
WebPage webPage = webPageService.findByPath(name);
ModelAndView modelAndView = new ModelAndView();
String page = "WebPage";
if("tos_page".equals(name) || "policy_page".equals(name)){
page = "ProtocolPage";
}
if (webPage != null){
modelAndView.addObject("page",webPage);
}else {
page = "WebPageError";
}
modelAndView.setViewName(page);
return modelAndView;
}
@ApiOperation("用户协议")
@ResponseBody
@GetMapping(value = {"/pages/tos_page","/pages/tos_page.html"})
public ModelAndView tosPage(){
return page("tos_page");
}
@ApiOperation("隐私协议")
@ResponseBody
@GetMapping(value = {"/pages/policy_page","/pages/policy_page.html"})
public ModelAndView policyPage(){
return page("policy_page");
}
}