use of com.blade.mvc.annotation.Route in project tale by otale.
the class InstallController method doInstall.
@Route(value = "/", method = HttpMethod.POST)
@JSON
public RestResponse doInstall(@QueryParam String site_title, @QueryParam String site_url, @QueryParam String admin_user, @QueryParam String admin_email, @QueryParam String admin_pwd) {
if (FileKit.exist(AttachController.CLASSPATH + "install.lock") && TaleConst.OPTIONS.getInt("allow_install", 0) != 1) {
return RestResponse.fail("请勿重复安装");
}
try {
if (StringKit.isBlank(site_title) || StringKit.isBlank(site_url) || StringKit.isBlank(admin_user) || StringKit.isBlank(admin_pwd)) {
return RestResponse.fail("请确认网站信息输入完整");
}
if (admin_pwd.length() < 6 || admin_pwd.length() > 14) {
return RestResponse.fail("请输入6-14位密码");
}
if (StringKit.isNotBlank(admin_email) && !TaleUtils.isEmail(admin_email)) {
return RestResponse.fail("邮箱格式不正确");
}
Users users = new Users();
users.setUsername(admin_user);
users.setPassword(admin_pwd);
users.setEmail(admin_email);
siteService.initSite(users);
if (site_url.endsWith("/")) {
site_url = site_url.substring(0, site_url.length() - 1);
}
if (!site_url.startsWith("http")) {
site_url = "http://".concat(site_url);
}
optionsService.saveOption("site_title", site_title);
optionsService.saveOption("site_url", site_url);
Config config = new Config();
config.addAll(optionsService.getOptions());
TaleConst.OPTIONS = config;
} catch (Exception e) {
String msg = "安装失败";
if (e instanceof TipException) {
msg = e.getMessage();
} else {
LOGGER.error(msg, e);
}
return RestResponse.fail(msg);
}
return RestResponse.ok();
}
use of com.blade.mvc.annotation.Route in project tale by otale.
the class IndexController method backup.
/**
* 系统备份
* @return
*/
@Route(value = "backup", method = HttpMethod.POST)
@JSON
public RestResponse backup(@QueryParam String bk_type, @QueryParam String bk_path, Request request) {
if (StringKit.isBlank(bk_type)) {
return RestResponse.fail("请确认信息输入完整");
}
try {
BackResponse backResponse = siteService.backup(bk_type, bk_path, "yyyyMMddHHmm");
logService.save(LogActions.SYS_BACKUP, null, request.address(), this.getUid());
return RestResponse.ok(backResponse);
} catch (Exception e) {
String msg = "备份失败";
if (e instanceof TipException) {
msg = e.getMessage();
} else {
LOGGER.error(msg, e);
}
return RestResponse.fail(msg);
}
}
use of com.blade.mvc.annotation.Route in project tale by otale.
the class ThemeController method saveSetting.
/**
* 保存主题配置项
* @param request
* @return
*/
@Route(value = "setting", method = HttpMethod.POST)
@JSON
public RestResponse saveSetting(Request request) {
try {
Map<String, String> querys = request.querys();
optionsService.saveOptions(querys);
Config config = new Config();
config.addAll(optionsService.getOptions());
TaleConst.OPTIONS = config;
logService.save(LogActions.THEME_SETTING, JSONKit.toJSONString(querys), request.address(), this.getUid());
return RestResponse.ok();
} catch (Exception e) {
String msg = "主题设置失败";
if (e instanceof TipException) {
msg = e.getMessage();
} else {
LOGGER.error(msg, e);
}
return RestResponse.fail(msg);
}
}
Aggregations