|
@@ -95,7 +95,7 @@ public class IndexController {
|
|
|
|
|
|
/*网站首页*/
|
|
/*网站首页*/
|
|
@GetMapping
|
|
@GetMapping
|
|
- public ModelAndView index(@RequestParam(value = "keyword",required = false) String keyword, HttpServletRequest request){
|
|
|
|
|
|
+ public ModelAndView index(@RequestParam(value = "keyword",required = false) String keyword){
|
|
String domain = ControllerUtil.getDomain();
|
|
String domain = ControllerUtil.getDomain();
|
|
log.debug("通过域名访问网站首页[{}]",domain);
|
|
log.debug("通过域名访问网站首页[{}]",domain);
|
|
TCmsSite site = siteService.findByDomain(domain);
|
|
TCmsSite site = siteService.findByDomain(domain);
|
|
@@ -105,13 +105,7 @@ public class IndexController {
|
|
if(!StrUtil.isBlank(keyword)) {
|
|
if(!StrUtil.isBlank(keyword)) {
|
|
return new ModelAndView( "forward:/"+sitePrefix+"/search");
|
|
return new ModelAndView( "forward:/"+sitePrefix+"/search");
|
|
}
|
|
}
|
|
- ModelAndView modelAndView = new ModelAndView( "forward:/"+sitePrefix+"/"+site.getSiteId());
|
|
|
|
- if (request.getSession().getAttribute(LOGIN_USER) == null) {
|
|
|
|
- modelAndView.addObject("btnId", "login");
|
|
|
|
- } else {
|
|
|
|
- modelAndView.addObject("btnId", "exit");
|
|
|
|
- }
|
|
|
|
- return modelAndView;
|
|
|
|
|
|
+ return new ModelAndView( "forward:/"+sitePrefix+"/"+site.getSiteId());
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/login")
|
|
@GetMapping("/login")
|
|
@@ -124,7 +118,7 @@ public class IndexController {
|
|
@GetMapping("/exit")
|
|
@GetMapping("/exit")
|
|
public ModelAndView exit(HttpServletRequest request){
|
|
public ModelAndView exit(HttpServletRequest request){
|
|
request.getSession().removeAttribute(LOGIN_USER);
|
|
request.getSession().removeAttribute(LOGIN_USER);
|
|
- return index(null, request);
|
|
|
|
|
|
+ return index(null);
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/register")
|
|
@GetMapping("/register")
|
|
@@ -180,7 +174,7 @@ public class IndexController {
|
|
*/
|
|
*/
|
|
@GetMapping("/${system.site.prefix}/{siteId}")
|
|
@GetMapping("/${system.site.prefix}/{siteId}")
|
|
public String index(@PathVariable("siteId") Integer siteId,
|
|
public String index(@PathVariable("siteId") Integer siteId,
|
|
- Model model){
|
|
|
|
|
|
+ Model model,HttpServletRequest request){
|
|
log.debug("通过站点Id访问网站首页[{}]",siteId);
|
|
log.debug("通过站点Id访问网站首页[{}]",siteId);
|
|
SimpleDateFormat formatYear = new SimpleDateFormat("yyyy");
|
|
SimpleDateFormat formatYear = new SimpleDateFormat("yyyy");
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d");
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d");
|
|
@@ -213,6 +207,11 @@ public class IndexController {
|
|
model.addAttribute("description",site.getDescription());
|
|
model.addAttribute("description",site.getDescription());
|
|
model.addAttribute("site",site);
|
|
model.addAttribute("site",site);
|
|
model.addAttribute("xwdtList",xwdtList);
|
|
model.addAttribute("xwdtList",xwdtList);
|
|
|
|
+ if (request.getSession().getAttribute(LOGIN_USER) == null) {
|
|
|
|
+ model.addAttribute("btnId", "login");
|
|
|
|
+ } else {
|
|
|
|
+ model.addAttribute("btnId", "exit");
|
|
|
|
+ }
|
|
if(StrUtil.isBlank(site.getTemplate())) {
|
|
if(StrUtil.isBlank(site.getTemplate())) {
|
|
return view(CmsConst.INDEX_TPL);
|
|
return view(CmsConst.INDEX_TPL);
|
|
}
|
|
}
|
|
@@ -223,23 +222,31 @@ public class IndexController {
|
|
@GetMapping("/${system.site.prefix}/{siteId}/{categoryId}")
|
|
@GetMapping("/${system.site.prefix}/{siteId}/{categoryId}")
|
|
public String category(@PathVariable("siteId") Integer siteId,
|
|
public String category(@PathVariable("siteId") Integer siteId,
|
|
@PathVariable("categoryId") Long categoryId,
|
|
@PathVariable("categoryId") Long categoryId,
|
|
- Model model){
|
|
|
|
|
|
+ Model model, HttpServletRequest request){
|
|
log.debug("栏目");
|
|
log.debug("栏目");
|
|
TCmsSite site = siteService.findById(siteId);
|
|
TCmsSite site = siteService.findById(siteId);
|
|
if(CmsUtil.isNullOrEmpty(site)) {
|
|
if(CmsUtil.isNullOrEmpty(site)) {
|
|
throw new CmsException(CmsConst.SITE_NOT_FOUND);
|
|
throw new CmsException(CmsConst.SITE_NOT_FOUND);
|
|
}
|
|
}
|
|
TCmsCategory category = categoryService.findById(categoryId);
|
|
TCmsCategory category = categoryService.findById(categoryId);
|
|
|
|
+ if (request.getSession().getAttribute(LOGIN_USER) == null) {
|
|
|
|
+ model.addAttribute("showState", false);
|
|
|
|
+ } else {
|
|
|
|
+ model.addAttribute("showState", true);
|
|
|
|
+ }
|
|
if(CmsUtil.isNullOrEmpty(category)) {
|
|
if(CmsUtil.isNullOrEmpty(category)) {
|
|
throw new CmsException(CmsConst.CATEGORY_NOT_FOUND);
|
|
throw new CmsException(CmsConst.CATEGORY_NOT_FOUND);
|
|
}
|
|
}
|
|
PageInfo page = contentService.page(1,siteId,category.getCategoryId());
|
|
PageInfo page = contentService.page(1,siteId,category.getCategoryId());
|
|
model.addAttribute("title",category.getCategoryName());
|
|
model.addAttribute("title",category.getCategoryName());
|
|
|
|
+
|
|
model.addAttribute("keyword",site.getKeyword());
|
|
model.addAttribute("keyword",site.getKeyword());
|
|
model.addAttribute("description",site.getDescription());
|
|
model.addAttribute("description",site.getDescription());
|
|
model.addAttribute("site",site);
|
|
model.addAttribute("site",site);
|
|
model.addAttribute("category",category);
|
|
model.addAttribute("category",category);
|
|
model.addAttribute("page",page);
|
|
model.addAttribute("page",page);
|
|
|
|
+
|
|
|
|
+
|
|
if(StrUtil.isBlank(site.getTemplate())) {
|
|
if(StrUtil.isBlank(site.getTemplate())) {
|
|
return view(category.getIndexTpl());
|
|
return view(category.getIndexTpl());
|
|
}
|
|
}
|