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

com.ajaxjs.config.stru.SiteStruController Maven / Gradle / Ivy

Go to download

AJAXJS aims to full-stack, not only the server-side framework, but also integrates the front-end library. It'€™s written in HTML5 + Java, a successor to the JVM platform, efficient, secure, stable, cross-platform and many other advantages, but it abandoned the traditional enterprise architecture brought about by the large and bloated, emphasizing the lightweight, and fast, very suitable for the Internet fast application.

The newest version!
package com.ajaxjs.config.stru;

import com.ajaxjs.framework.BaseController;
import com.ajaxjs.util.io.FileHelper;
import com.ajaxjs.util.logger.LogHelper;
import com.ajaxjs.web.mvc.MvcRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.File;

@Controller
@RequestMapping("/admin/website/siteStru")
public class SiteStruController extends BaseController {
	private static final LogHelper LOGGER = LogHelper.getLog(SiteStruController.class);

	@GetMapping
	public String siteStruUI(ModelMap model) {
		LOGGER.info("编辑网站结构");

		if (SiteStruService.STRU != null && SiteStruService.STRU.isLoaded()) {
			model.put("siteStruJson", FileHelper.openAsText(SiteStruService.STRU.getJsonPath()));

			return "website/config-site-stru";
		} else
			return errMsg("该网站没有使用目录定义功能");
	}

	@ResponseBody
	@PostMapping(produces = JSON)
	public String saveSiteStru(String json, HttpServletRequest req) {
		LOGGER.info("保存网站结构");

		FileHelper.saveText(SiteStruService.STRU.getJsonPath(), json);
		SiteStruService.loadSiteStru(req.getServletContext());

		return BaseController.jsonOk("修改网站结构成功!");
	}

	@ResponseBody
	@PostMapping(value = "initJSP", produces = JSON)
	public String siteStruUI_initJSP(String path, HttpServletRequest _req) {
		LOGGER.info("初始化 JSP 页面");

		MvcRequest req = (MvcRequest) _req;
		String folder = req.mappath(path);
		FileHelper.mkDir(folder);
		String dest = folder + File.separator + "index.jsp";
		FileHelper.copy(req.mappath(JSP_PERFIX_WEBINF + File.separator + "common-page.jsp"), dest, true);

		return jsonOk("初始化 JSP 页面成功!");
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy