master
wangbing 4 years ago
parent 99688c474f
commit 6c430e7835

Binary file not shown.

Binary file not shown.

@ -21,22 +21,26 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.test.skip>true</maven.test.skip>
<commons-io-version>2.6</commons-io-version>
<pagehelper-version>1.2.5</pagehelper-version>
<mybatis-version>1.3.2</mybatis-version>
<ehcache-version>1.1.0</ehcache-version>
<dozer-version>5.5.1</dozer-version>
<spring-cloud.version>Greenwich.RC2</spring-cloud.version>
<poi-ooxml-version>3.8</poi-ooxml-version>
</properties>
<repositories>
<!-- 将中央仓库地址指向阿里云聚合仓库,提高下载速度 -->
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<id>central</id>
<name>Central Repository</name>
<layout>default</layout>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
</repositories>
<pluginRepositories>
<!-- 将插件的仓库指向阿里云聚合仓库解决低版本maven下载插件异常或提高下载速度 -->
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://maven.aliyun.com/repository/public</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
@ -48,99 +52,61 @@
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.caches</groupId>
<artifactId>mybatis-ehcache</artifactId>
<version>1.3.2</version>
</dependency>
<!-- mybatis 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<!-- freemarker -->
<!-- freemarker模板框架 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<!-- 安全框架 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- 阿里巴巴旗下关于Excel处理类性能优化可处理超大数据量 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.6</version>
</dependency>
<!-- Java Bean映射工具,已集成中MapperUtil工具类中 -->
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.21.0.1</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper-version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.caches</groupId>
<artifactId>mybatis-ehcache</artifactId>
<version>${ehcache-version}</version>
</dependency>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>${dozer-version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi-ooxml-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- 项目名称 -->

@ -4,8 +4,11 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationContextInitializedEvent;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import xyz.wbsite.frame.auth.LocalData;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import xyz.wbsite.frame.base.LocalData;
@SpringBootApplication
@EnableAutoConfiguration
@ -17,6 +20,25 @@ public class Application extends SpringBootServletInitializer {
}
public static void main(String[] args) {
LocalData.setApplicationContext(SpringApplication.run(Application.class, args));
SpringApplication application = new SpringApplication(Application.class);
application.addListeners(getListener());
application.run(args);
}
/**
* LocalData.getContext()null
* SpringApplication
*
* @return ApplicationListener
*/
private static ApplicationListener getListener() {
return new ApplicationListener<ApplicationEvent>() {
@Override
public void onApplicationEvent(ApplicationEvent applicationEvent) {
if (applicationEvent instanceof ApplicationContextInitializedEvent) {
LocalData.setContext(((ApplicationContextInitializedEvent) applicationEvent).getApplicationContext());
}
}
};
}
}

@ -0,0 +1,81 @@
package xyz.wbsite.action;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import xyz.wbsite.frame.base.LocalData;
import xyz.wbsite.frame.listener.FrameListener;
import xyz.wbsite.frame.utils.LogUtil;
import xyz.wbsite.frame.utils.RequestUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.Map;
/**
*
*
* @author author
* @version 0.0.1
* @since 2017-01-01
*/
@Controller
public class GlobalErrorController extends BasicErrorController {
public GlobalErrorController() {
super(new DefaultErrorAttributes(), new ErrorProperties());
}
@Override
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
return super.error(request);
}
@Override
@RequestMapping(produces = "text/html")
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
HttpStatus status = this.getStatus(request);
Map<String, Object> model = Collections.unmodifiableMap(this.getErrorAttributes(request, true));
response.setStatus(status.value());
ModelAndView modelAndView = this.resolveErrorView(request, response, status, model);
if (modelAndView == null) {
modelAndView = new ModelAndView("error", model);
}
switch (status) {
case FORBIDDEN://403
String errorUrl = RequestUtil.getErrorUrl(request);
errorUrl = errorUrl.replaceFirst(LocalData.getContext(), "");
String indexPage = LocalData.getEnvironment().getProperty("web.url.index", "/index.htm");
String loginPage = LocalData.getEnvironment().getProperty("web.url.login", "/login.htm");
if ((errorUrl.equals(indexPage) || errorUrl.equals("/")) && LocalData.getToken() == null) {
RequestUtil.setRedirect(loginPage);
} else {
modelAndView.setViewName("403");
}
break;
case NOT_FOUND://404
modelAndView.setViewName("404");
break;
case INTERNAL_SERVER_ERROR://500
default:
try {
FrameListener instance = FrameListener.getInstance();
instance.onError((String) model.get("trace"));
modelAndView.setViewName("500");
} catch (Exception ex) {
LogUtil.dumpException(ex);
} finally {
modelAndView.setViewName("500");
}
break;
}
return modelAndView;
}
}

@ -0,0 +1,108 @@
package xyz.wbsite.action.ajax.admin;
import com.alibaba.excel.support.ExcelTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import xyz.wbsite.frame.base.Error;
import xyz.wbsite.frame.excel.WExcel;
import xyz.wbsite.frame.utils.LogUtil;
import xyz.wbsite.frame.base.LocalData;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.base.BaseResponse;
import xyz.wbsite.frame.utils.ResponseUtil;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.frame.excel.exception.TemplateNotMatchException;
import xyz.wbsite.module.admin.ent.Config;
import xyz.wbsite.module.admin.mgr.ConfigManager;
import xyz.wbsite.module.admin.req.ConfigCreateRequest;
import xyz.wbsite.module.admin.req.ConfigDeleteRequest;
import xyz.wbsite.module.admin.req.ConfigFindRequest;
import xyz.wbsite.module.admin.req.ConfigUpdateRequest;
import xyz.wbsite.module.admin.rsp.ConfigCreateResponse;
import xyz.wbsite.module.admin.rsp.ConfigDeleteResponse;
import xyz.wbsite.module.admin.rsp.ConfigFindResponse;
import xyz.wbsite.module.admin.rsp.ConfigUpdateResponse;
import java.io.IOException;
import java.util.List;
public class ConfigAjax{
@Autowired
private ConfigManager configManager;
public ConfigCreateResponse create(ConfigCreateRequest request) {
return configManager.create(request, LocalData.getToken());
}
public ConfigDeleteResponse delete(ConfigDeleteRequest request) {
return configManager.delete(request, LocalData.getToken());
}
public ConfigUpdateResponse update(ConfigUpdateRequest request) {
return configManager.update(request, LocalData.getToken());
}
public ConfigFindResponse find(ConfigFindRequest request) {
return configManager.find(request, LocalData.getToken());
}
public Object template(){
return ResponseUtil.apply(new WExcel<>(Config.class));
}
public Object exports(ConfigFindRequest request) {
ConfigFindResponse response = configManager.find(request, LocalData.getToken());
if (response.hasError()) {
return response;
} else if (response.getTotalCount() == 0) {
response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空");
return response;
}
return ResponseUtil.apply(new WExcel<>(Config.class).addDatas(response.getResult()));
}
public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse();
try {
// 检查文件格式
String originalFilename = file.getOriginalFilename() != null ? file.getOriginalFilename() : "";
if (!originalFilename.matches(".+(.xlsx?|.XLSX?)$")) {
baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件格式错误!");
return baseResponse;
}
// 兼容2003以前老版本.xls
ExcelTypeEnum excelTypeEnum = originalFilename.matches(".+(.xlsx|.XLSX)$") ? ExcelTypeEnum.XLSX : ExcelTypeEnum.XLS;
WExcel sheet = new WExcel<>(Config.class).read(file.getBytes(), excelTypeEnum, new WExcel.Processor<Config>() {
@Override
public List<String> exec(Config o, int index) {
ConfigCreateRequest request = MapperUtil.map(o, ConfigCreateRequest.class);
List<String> validate = ValidationUtil.validate(request);
if (validate == null || validate.size() == 0) {
ConfigCreateResponse configCreateResponse = configManager.create(request, LocalData.getToken());
if (configCreateResponse.hasError()) {
for (Error error : configCreateResponse.getErrors()) {
validate.add(error.getMessage());
}
}
}
return validate;
}
});
// 当导入出现错误时可以将存在标注错误的Excel返回给用户改正
if (sheet.hasError()) {
return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx");
} else {
return baseResponse;
}
} catch (IOException e) {
e.printStackTrace();
LogUtil.dumpException(e);
baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件出错");
} catch (TemplateNotMatchException e) {
baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage());
}
return baseResponse;
}
}

@ -0,0 +1,108 @@
package xyz.wbsite.action.ajax.admin;
import com.alibaba.excel.support.ExcelTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import xyz.wbsite.frame.base.Error;
import xyz.wbsite.frame.excel.WExcel;
import xyz.wbsite.frame.utils.LogUtil;
import xyz.wbsite.frame.base.LocalData;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.base.BaseResponse;
import xyz.wbsite.frame.utils.ResponseUtil;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.frame.excel.exception.TemplateNotMatchException;
import xyz.wbsite.module.admin.ent.ConfigData;
import xyz.wbsite.module.admin.mgr.ConfigDataManager;
import xyz.wbsite.module.admin.req.ConfigDataCreateRequest;
import xyz.wbsite.module.admin.req.ConfigDataDeleteRequest;
import xyz.wbsite.module.admin.req.ConfigDataFindRequest;
import xyz.wbsite.module.admin.req.ConfigDataUpdateRequest;
import xyz.wbsite.module.admin.rsp.ConfigDataCreateResponse;
import xyz.wbsite.module.admin.rsp.ConfigDataDeleteResponse;
import xyz.wbsite.module.admin.rsp.ConfigDataFindResponse;
import xyz.wbsite.module.admin.rsp.ConfigDataUpdateResponse;
import java.io.IOException;
import java.util.List;
public class ConfigDataAjax{
@Autowired
private ConfigDataManager configDataManager;
public ConfigDataCreateResponse create(ConfigDataCreateRequest request) {
return configDataManager.create(request, LocalData.getToken());
}
public ConfigDataDeleteResponse delete(ConfigDataDeleteRequest request) {
return configDataManager.delete(request, LocalData.getToken());
}
public ConfigDataUpdateResponse update(ConfigDataUpdateRequest request) {
return configDataManager.update(request, LocalData.getToken());
}
public ConfigDataFindResponse find(ConfigDataFindRequest request) {
return configDataManager.find(request, LocalData.getToken());
}
public Object template(){
return ResponseUtil.apply(new WExcel<>(ConfigData.class));
}
public Object exports(ConfigDataFindRequest request) {
ConfigDataFindResponse response = configDataManager.find(request, LocalData.getToken());
if (response.hasError()) {
return response;
} else if (response.getTotalCount() == 0) {
response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空");
return response;
}
return ResponseUtil.apply(new WExcel<>(ConfigData.class).addDatas(response.getResult()));
}
public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse();
try {
// 检查文件格式
String originalFilename = file.getOriginalFilename() != null ? file.getOriginalFilename() : "";
if (!originalFilename.matches(".+(.xlsx?|.XLSX?)$")) {
baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件格式错误!");
return baseResponse;
}
// 兼容2003以前老版本.xls
ExcelTypeEnum excelTypeEnum = originalFilename.matches(".+(.xlsx|.XLSX)$") ? ExcelTypeEnum.XLSX : ExcelTypeEnum.XLS;
WExcel sheet = new WExcel<>(ConfigData.class).read(file.getBytes(), excelTypeEnum, new WExcel.Processor<ConfigData>() {
@Override
public List<String> exec(ConfigData o, int index) {
ConfigDataCreateRequest request = MapperUtil.map(o, ConfigDataCreateRequest.class);
List<String> validate = ValidationUtil.validate(request);
if (validate == null || validate.size() == 0) {
ConfigDataCreateResponse configDataCreateResponse = configDataManager.create(request, LocalData.getToken());
if (configDataCreateResponse.hasError()) {
for (Error error : configDataCreateResponse.getErrors()) {
validate.add(error.getMessage());
}
}
}
return validate;
}
});
// 当导入出现错误时可以将存在标注错误的Excel返回给用户改正
if (sheet.hasError()) {
return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx");
} else {
return baseResponse;
}
} catch (IOException e) {
e.printStackTrace();
LogUtil.dumpException(e);
baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件出错");
} catch (TemplateNotMatchException e) {
baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage());
}
return baseResponse;
}
}

@ -0,0 +1,108 @@
package xyz.wbsite.action.ajax.admin;
import com.alibaba.excel.support.ExcelTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import xyz.wbsite.frame.base.Error;
import xyz.wbsite.frame.excel.WExcel;
import xyz.wbsite.frame.utils.LogUtil;
import xyz.wbsite.frame.base.LocalData;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.base.BaseResponse;
import xyz.wbsite.frame.utils.ResponseUtil;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.frame.excel.exception.TemplateNotMatchException;
import xyz.wbsite.module.admin.ent.Locations;
import xyz.wbsite.module.admin.mgr.LocationsManager;
import xyz.wbsite.module.admin.req.LocationsCreateRequest;
import xyz.wbsite.module.admin.req.LocationsDeleteRequest;
import xyz.wbsite.module.admin.req.LocationsFindRequest;
import xyz.wbsite.module.admin.req.LocationsUpdateRequest;
import xyz.wbsite.module.admin.rsp.LocationsCreateResponse;
import xyz.wbsite.module.admin.rsp.LocationsDeleteResponse;
import xyz.wbsite.module.admin.rsp.LocationsFindResponse;
import xyz.wbsite.module.admin.rsp.LocationsUpdateResponse;
import java.io.IOException;
import java.util.List;
public class LocationsAjax{
@Autowired
private LocationsManager locationsManager;
public LocationsCreateResponse create(LocationsCreateRequest request) {
return locationsManager.create(request, LocalData.getToken());
}
public LocationsDeleteResponse delete(LocationsDeleteRequest request) {
return locationsManager.delete(request, LocalData.getToken());
}
public LocationsUpdateResponse update(LocationsUpdateRequest request) {
return locationsManager.update(request, LocalData.getToken());
}
public LocationsFindResponse find(LocationsFindRequest request) {
return locationsManager.find(request, LocalData.getToken());
}
public Object template(){
return ResponseUtil.apply(new WExcel<>(Locations.class));
}
public Object exports(LocationsFindRequest request) {
LocationsFindResponse response = locationsManager.find(request, LocalData.getToken());
if (response.hasError()) {
return response;
} else if (response.getTotalCount() == 0) {
response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空");
return response;
}
return ResponseUtil.apply(new WExcel<>(Locations.class).addDatas(response.getResult()));
}
public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse();
try {
// 检查文件格式
String originalFilename = file.getOriginalFilename() != null ? file.getOriginalFilename() : "";
if (!originalFilename.matches(".+(.xlsx?|.XLSX?)$")) {
baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件格式错误!");
return baseResponse;
}
// 兼容2003以前老版本.xls
ExcelTypeEnum excelTypeEnum = originalFilename.matches(".+(.xlsx|.XLSX)$") ? ExcelTypeEnum.XLSX : ExcelTypeEnum.XLS;
WExcel sheet = new WExcel<>(Locations.class).read(file.getBytes(), excelTypeEnum, new WExcel.Processor<Locations>() {
@Override
public List<String> exec(Locations o, int index) {
LocationsCreateRequest request = MapperUtil.map(o, LocationsCreateRequest.class);
List<String> validate = ValidationUtil.validate(request);
if (validate == null || validate.size() == 0) {
LocationsCreateResponse locationsCreateResponse = locationsManager.create(request, LocalData.getToken());
if (locationsCreateResponse.hasError()) {
for (Error error : locationsCreateResponse.getErrors()) {
validate.add(error.getMessage());
}
}
}
return validate;
}
});
// 当导入出现错误时可以将存在标注错误的Excel返回给用户改正
if (sheet.hasError()) {
return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx");
} else {
return baseResponse;
}
} catch (IOException e) {
e.printStackTrace();
LogUtil.dumpException(e);
baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件出错");
} catch (TemplateNotMatchException e) {
baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage());
}
return baseResponse;
}
}

@ -1,60 +0,0 @@
package xyz.wbsite.action.ajax.conf;
import org.springframework.beans.factory.annotation.Autowired;
import xyz.wbsite.frame.auth.LocalData;
import xyz.wbsite.module.conf.mgr.MappingManager;
import xyz.wbsite.module.conf.req.MappingCreateRequest;
import xyz.wbsite.module.conf.req.MappingDeleteRequest;
import xyz.wbsite.module.conf.req.MappingFindRequest;
import xyz.wbsite.module.conf.req.MappingGetRequest;
import xyz.wbsite.module.conf.req.MappingUpdateRequest;
import xyz.wbsite.module.conf.req.NginxReloadRequest;
import xyz.wbsite.module.conf.rsp.MappingCreateResponse;
import xyz.wbsite.module.conf.rsp.MappingDeleteResponse;
import xyz.wbsite.module.conf.rsp.MappingFindResponse;
import xyz.wbsite.module.conf.rsp.MappingGetResponse;
import xyz.wbsite.module.conf.rsp.MappingUpdateResponse;
public class MappingAjax {
@Autowired
private MappingManager mappingManager;
public MappingCreateResponse create(MappingCreateRequest request) {
MappingCreateResponse response = mappingManager.create(request, LocalData.getToken());
if (!response.hasError()) {
NginxAjax nginxAjax = LocalData.getBean(NginxAjax.class);
nginxAjax.flushConfig();
nginxAjax.reload(new NginxReloadRequest());
}
return response;
}
public MappingDeleteResponse delete(MappingDeleteRequest request) {
MappingDeleteResponse response = mappingManager.delete(request, LocalData.getToken());
if (!response.hasError()) {
NginxAjax nginxAjax = LocalData.getBean(NginxAjax.class);
nginxAjax.flushConfig();
nginxAjax.reload(new NginxReloadRequest());
}
return response;
}
public MappingUpdateResponse update(MappingUpdateRequest request) {
MappingUpdateResponse response = mappingManager.update(request, LocalData.getToken());
if (!response.hasError()) {
NginxAjax nginxAjax = LocalData.getBean(NginxAjax.class);
nginxAjax.flushConfig();
nginxAjax.reload(new NginxReloadRequest());
}
return response;
}
public MappingFindResponse find(MappingFindRequest request) {
return mappingManager.find(request, LocalData.getToken());
}
public MappingGetResponse get(MappingGetRequest request) {
return mappingManager.get(request, LocalData.getToken());
}
}

@ -1,119 +0,0 @@
package xyz.wbsite.action.ajax.conf;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import xyz.wbsite.frame.auth.LocalData;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.SortType;
import xyz.wbsite.frame.utils.ProcessUtil;
import xyz.wbsite.module.conf.ent.Mapping;
import xyz.wbsite.module.conf.ent.NginxCtrl;
import xyz.wbsite.module.conf.mgr.MappingManager;
import xyz.wbsite.module.conf.req.MappingFindRequest;
import xyz.wbsite.module.conf.req.NginxReloadRequest;
import xyz.wbsite.module.conf.req.NginxStartRequest;
import xyz.wbsite.module.conf.req.NginxStopRequest;
import xyz.wbsite.module.conf.rsp.MappingFindResponse;
import xyz.wbsite.module.conf.rsp.NginxReloadResponse;
import xyz.wbsite.module.conf.rsp.NginxStartResponse;
import xyz.wbsite.module.conf.rsp.NginxStopResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NginxAjax {
@Autowired
private NginxCtrl nginxCtrl;
@Autowired
private MappingManager mappingManager;
@Autowired
private FreeMarkerConfigurer freeMarkerConfigurer;
public NginxStartResponse start(NginxStartRequest request) {
NginxStartResponse response = new NginxStartResponse();
if (nginxCtrl.isRunning()) {
response.addError(ErrorType.BUSINESS_ERROR, "程序已经运行");
return response;
}
ProcessUtil.execBat(nginxCtrl.getStartCmd());
return response;
}
public NginxStopResponse stop(NginxStopRequest request) {
NginxStopResponse response = new NginxStopResponse();
if (!nginxCtrl.isRunning()) {
response.addError(ErrorType.BUSINESS_ERROR, "程序尚未运行");
return response;
}
ProcessUtil.execBat(nginxCtrl.getStopCmd());
return response;
}
public NginxReloadResponse reload(NginxReloadRequest request) {
NginxReloadResponse response = new NginxReloadResponse();
if (!nginxCtrl.isRunning()) {
response.addError(ErrorType.BUSINESS_ERROR, "程序尚未运行");
return response;
}
// 刷新配置文件
flushConfig();
// 重新加载配置文件
ProcessUtil.execBat(nginxCtrl.getReloadCmd());
return response;
}
public synchronized void flushConfig() {
Writer wr = null;
try {
File config = nginxCtrl.getConfig();
HashMap<String, Object> context = new HashMap<>();
MappingFindRequest mappingFindRequest = new MappingFindRequest();
mappingFindRequest.setPageSize(0);
mappingFindRequest.setSortKey("PORT");
mappingFindRequest.setSortType(SortType.ASC);
MappingFindResponse mappingFindResponse = mappingManager.find(mappingFindRequest, LocalData.getSysToken());
Map<String, List<Mapping>> services = new HashMap<>();
for (Mapping mapping : mappingFindResponse.getResult()) {
List<Mapping> mappings = services.get(mapping.getPort());
if (mappings == null) {
mappings = new ArrayList<>();
services.put(mapping.getPort(), mappings);
}
mappings.add(mapping);
}
context.put("services", services);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate("nginx.conf.ftl");
wr = new OutputStreamWriter(new FileOutputStream(config), "UTF-8");
//写入
template.process(context, wr);
//关闭流
wr.close();
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
e.printStackTrace();
} finally {
try {
wr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

@ -1,63 +0,0 @@
package xyz.wbsite.action.ajax.system;
import org.springframework.beans.factory.annotation.Value;
import xyz.wbsite.frame.auth.LocalData;
import xyz.wbsite.frame.auth.Token;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.utils.CookieUtil;
import xyz.wbsite.frame.utils.IDgenerator;
import xyz.wbsite.frame.utils.MD5Util;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.module.system.req.UserLoginRequest;
import xyz.wbsite.module.system.req.UserLogoutRequest;
import xyz.wbsite.module.system.rsp.UserLoginResponse;
import xyz.wbsite.module.system.rsp.UserLogoutResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Calendar;
import java.util.Date;
public class UserAjax {
@Value("${web.url.auth.admin}")
private String admin;
@Value("${web.url.auth.pwd}")
private String pwd;
public UserLoginResponse login(UserLoginRequest request, Token token, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
UserLoginResponse response = new UserLoginResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
if (request.getUsername().equals(admin)) {//超级管理员登录
String generatePwd = MD5Util.generatePwd(request.getPassword());
if (!generatePwd.equals(pwd)) {
response.addError(ErrorType.BUSINESS_ERROR, "用户名或密码错误!");
} else {
Date current = new Date();
Calendar instance = Calendar.getInstance();
instance.setTime(current);
instance.add(Calendar.HOUR_OF_DAY, 1);//默认一个小时内有效
Token sysToken = LocalData.getSysToken();
sysToken.setToken(IDgenerator.nextUUID());
Cookie cookie = CookieUtil.newCookie("token", sysToken.getToken());
httpServletResponse.addCookie(cookie);
response.setToken(sysToken.getToken());
}
}
return response;
}
public UserLogoutResponse logout(UserLogoutRequest request, Token token) {
UserLogoutResponse response = new UserLogoutResponse();
CookieUtil.clearCookie("token");
return response;
}
}

@ -0,0 +1,23 @@
package xyz.wbsite.action.ajax.wframe;
import xyz.wbsite.frame.base.DictLoadRequest;
import xyz.wbsite.frame.base.DictLoadResponse;
import xyz.wbsite.frame.provider.DictProvider;
import xyz.wbsite.frame.provider.FrameProvider;
import xyz.wbsite.frame.utils.ValidationUtil;
public class DictAjax {
public DictLoadResponse load(DictLoadRequest request) {
DictLoadResponse response = new DictLoadResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
DictProvider dictProvider = FrameProvider.getInstance().getDictProvider();
response.setResult(dictProvider.getDict(request.getDictName()));
return response;
}
}

@ -1,33 +0,0 @@
package xyz.wbsite.action.api.conf;
import xyz.wbsite.frame.auth.LocalData;
import xyz.wbsite.module.conf.mgr.MappingManager;
import xyz.wbsite.module.conf.req.*;
import xyz.wbsite.module.conf.rsp.*;
import org.springframework.beans.factory.annotation.Autowired;
public class MappingApi{
@Autowired
private MappingManager mappingManager;
public MappingCreateResponse create(MappingCreateRequest request) {
return mappingManager.create(request, LocalData.getToken());
}
public MappingDeleteResponse delete(MappingDeleteRequest request) {
return mappingManager.delete(request, LocalData.getToken());
}
public MappingUpdateResponse update(MappingUpdateRequest request) {
return mappingManager.update(request, LocalData.getToken());
}
public MappingFindResponse find(MappingFindRequest request) {
return mappingManager.find(request, LocalData.getToken());
}
public MappingGetResponse get(MappingGetRequest request) {
return mappingManager.get(request, LocalData.getToken());
}
}

@ -1,15 +0,0 @@
package xyz.wbsite.action.control;
import xyz.wbsite.frame.base.Control;
import org.springframework.ui.Model;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Header extends Control {
@Override
public void exec(Model model, HttpServletRequest request, HttpServletResponse response) {
}
}

@ -1,11 +1,19 @@
package xyz.wbsite.action.screen;
package xyz.wbsite.action.page.screen;
import xyz.wbsite.frame.base.Screen;
import xyz.wbsite.frame.base.LocalData;
import org.springframework.ui.Model;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* resources/templates/screen/index.ftl访Screen
*
* @author author
* @version 0.0.1
* @since 2020-11-01
*/
public class Index extends Screen {
@Override
@ -14,9 +22,11 @@ public class Index extends Screen {
// 获取配置
HashMap<String, Object> prop = new HashMap<>();
prop.put("open", true);//是否保持一个子菜单展开
prop.put("coll", true);//左侧菜单是否收缩
prop.put("coll", false);//左侧菜单是否收缩
prop.put("tran", false);//是否展示动画
prop.put("full", false);//是否全屏
prop.put("active", LocalData.getActive());//当前激活环境
model.addAttribute("prop", prop);
model.addAttribute("token", LocalData.getToken());
}
}

@ -1,23 +0,0 @@
package xyz.wbsite.action.screen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import xyz.wbsite.frame.base.Screen;
import xyz.wbsite.module.conf.ent.NginxCtrl;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Home extends Screen {
@Autowired
private NginxCtrl nginxCtrl;
@Value("${mapping.default.port}")
private String serverPort;
@Override
public void exec(Model model, HttpServletRequest request, HttpServletResponse response) {
model.addAttribute("run", nginxCtrl.isRunning() ? "true" : "false");
model.addAttribute("serverPort", serverPort);
}
}

@ -1,69 +0,0 @@
package xyz.wbsite.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StringUtils;
import xyz.wbsite.frame.utils.FileUtil;
import xyz.wbsite.frame.utils.ZipUtil;
import xyz.wbsite.module.conf.ent.NginxCtrl;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@Configuration
public class NginxConfig {
@Autowired
private Environment environment;
@Bean
public NginxCtrl initNginx() {
String property = environment.getProperty("nginx-path");
File nginxHome = null;
if (StringUtils.isEmpty(property)) {
ApplicationHome home = new ApplicationHome(getClass());
// 当前运行jar文件
File jarFile = home.getSource() != null ? home.getSource() : home.getDir();
//jar同目录
nginxHome = new File(jarFile.getParent(), "nginx");
if (!nginxHome.exists()) {
ClassPathResource classPathResource = new ClassPathResource("nginx-1.16.1.zip");
try {
InputStream inputStream = classPathResource.getInputStream();
File nginxDir = new File(jarFile.getParent(), "nginx");
File nginxZip = new File(jarFile.getParent(), "nginx.zip");
FileUtil.inputStream2File(inputStream, nginxZip);
ZipUtil.unZip(nginxZip, nginxDir);
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
nginxHome = new File(property);
}
if (!nginxHome.exists()) {
throw new RuntimeException("nginx home not exists!");
}
File start = new File(nginxHome, "start.bat");
File stop = new File(nginxHome, "stop.bat");
File reload = new File(nginxHome, "reload.bat");
NginxCtrl nginxCtrl = new NginxCtrl();
nginxCtrl.setStartCmd(start.getAbsolutePath());
nginxCtrl.setStopCmd(stop.getAbsolutePath());
nginxCtrl.setReloadCmd(reload.getAbsolutePath());
nginxCtrl.setVersionCmd(nginxHome.getAbsolutePath() + " -v ");
nginxCtrl.setConfig(new File(new File(nginxHome, "conf"), "nginx.conf"));
return nginxCtrl;
}
}

@ -0,0 +1,44 @@
package xyz.wbsite.frame.base;
import java.util.List;
public class DictEntity extends BaseEntity {
/**
*
*/
private String label;
/**
*
*/
private String value;
/**
*
*/
private List<DictEntity> children;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public List<DictEntity> getChildren() {
return children;
}
public void setChildren(List<DictEntity> children) {
this.children = children;
}
}

@ -0,0 +1,23 @@
package xyz.wbsite.frame.base;
import xyz.wbsite.frame.base.DictEntity;
import java.util.ArrayList;
import java.util.List;
public class DictLoadResponse extends BaseResponse {
private List<DictEntity> result = new ArrayList<>();
public List<DictEntity> getResult() {
return result;
}
public void setResult(List<DictEntity> result) {
this.result = result;
}
public void put(DictEntity entity) {
this.result.add(entity);
}
}

@ -1,14 +1,17 @@
package xyz.wbsite.frame.auth;
package xyz.wbsite.frame.base;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import xyz.wbsite.frame.auth.Token;
import xyz.wbsite.frame.utils.PropertiesUtil;
import xyz.wbsite.frame.utils.StringUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* LocalData -
@ -19,6 +22,8 @@ import javax.servlet.http.HttpServletResponse;
*/
public class LocalData {
private static String[] applicationArgs = null;
private static ApplicationContext applicationContext = null;
private static Token system = null;
@ -36,19 +41,6 @@ public class LocalData {
return system;
}
/**
* target = '/aa/bb'
*/
private static final ThreadLocal<String> actionHolder = new ThreadLocal();
public static String getAction() {
return actionHolder.get();
}
public static void setAction(String action) {
actionHolder.set(action);
}
/**
*
*/
@ -70,12 +62,12 @@ public class LocalData {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
}
public static ApplicationContext getApplicationContext() {
public static ApplicationContext getApplicationContext() {
return LocalData.applicationContext;
}
public static void setApplicationContext(ApplicationContext applicationContext) {
LocalData.applicationContext = applicationContext;
public static void setContext(ApplicationContext context) {
LocalData.applicationContext = context;
}
public static <T> T getBean(Class<T> t) {
@ -89,7 +81,52 @@ public class LocalData {
}
}
public static Object getBean(String beanName) {
if (getApplicationContext() == null) {
return null;
}
try {
return getApplicationContext().getBean(beanName);
} catch (BeansException ignored) {
return null;
}
}
public static <T> T getBean(String beanName, Class<T> t) {
if (getApplicationContext() == null) {
return null;
}
try {
return getApplicationContext().getBean(beanName, t);
} catch (BeansException ignored) {
return null;
}
}
public static Environment getEnvironment() {
return getBean(Environment.class);
}
public static String getProperty(String key, String defaultValue) {
Environment environment = getEnvironment();
if (environment != null) {
return environment.getProperty(key, defaultValue);
} else {
String active = LocalData.getActive();
if (StringUtil.isEmpty(active)) {
return PropertiesUtil.getProp("application.properties", key, defaultValue);
} else {
return PropertiesUtil.getProp("application-" + active + ".properties", key, defaultValue);
}
}
}
public static String getActive() {
Environment environment = getEnvironment();
return environment.getActiveProfiles()[0];
}
public static String getContext() {
return getRequest().getContextPath();
}
}

@ -0,0 +1,92 @@
package xyz.wbsite.frame.base;
import java.io.Serializable;
import java.util.Date;
public class LogTaskEntity implements Serializable {
/**
* TASK_ID -
*/
private String taskId;
/**
* TASK_NAME -
*/
private String taskName;
/**
* START_TIME -
*/
private Date startTime;
/**
* END_TIME -
*/
private Date endTime;
/**
* EXEC_TIME -
*/
private Integer execTime;
/**
* EXEC_STATE -
*/
private String execState;
/**
* EXEC_RESULT -
*/
private String execResult;
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Integer getExecTime() {
return execTime;
}
public void setExecTime(Integer execTime) {
this.execTime = execTime;
}
public String getExecState() {
return execState;
}
public void setExecState(String execState) {
this.execState = execState;
}
public String getExecResult() {
return execResult;
}
public void setExecResult(String execResult) {
this.execResult = execResult;
}
}

@ -0,0 +1,60 @@
package xyz.wbsite.frame.base;
import xyz.wbsite.frame.base.BaseRequest;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* LoginRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class LoginRequest extends BaseRequest {
@NotBlank(message = "[username]用户名不能为空")
private String username;
@NotBlank(message = "[password]用户密码不能为空")
private String password;
@NotNull(message = "[verifyCodeId]验证码ID不能为空")
private Long verifyCodeId;
@NotBlank(message = "[verifyCodeCode]验证码不能为空")
private String verifyCodeCode;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Long getVerifyCodeId() {
return verifyCodeId;
}
public void setVerifyCodeId(Long verifyCodeId) {
this.verifyCodeId = verifyCodeId;
}
public String getVerifyCodeCode() {
return verifyCodeCode;
}
public void setVerifyCodeCode(String verifyCodeCode) {
this.verifyCodeCode = verifyCodeCode;
}
}

@ -1,15 +1,15 @@
package xyz.wbsite.module.system.rsp;
package xyz.wbsite.frame.base;
import xyz.wbsite.frame.base.BaseResponse;
/**
* UserLoginResponse -
* LoginResponse -
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class UserLoginResponse extends BaseResponse {
public class LoginResponse extends BaseResponse {
/**
* token

@ -0,0 +1,14 @@
package xyz.wbsite.frame.base;
import xyz.wbsite.frame.base.BaseResponse;
/**
* LogoutResponse -
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class LogoutResponse extends BaseResponse {
}

@ -0,0 +1,71 @@
package xyz.wbsite.frame.base;
import java.io.Serializable;
public class SqlTaskEntity implements Serializable {
/**
* TASK_NAME -
*/
private String taskName;
/**
* TASK_NOTE -
*/
private String taskNote;
/**
* .
* Cron:Cron
* DelayRepeat:()
* FixRepeat:()
*/
private String taskType;
/**
* TYPE_VALUE -
*/
private String typeValue;
/**
* TASK_SQL - SQL
*/
private String taskSql;
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public String getTaskNote() {
return taskNote;
}
public void setTaskNote(String taskNote) {
this.taskNote = taskNote;
}
public String getTaskType() {
return taskType;
}
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getTypeValue() {
return typeValue;
}
public void setTypeValue(String typeValue) {
this.typeValue = typeValue;
}
public String getTaskSql() {
return taskSql;
}
public void setTaskSql(String taskSql) {
this.taskSql = taskSql;
}
}

@ -1,6 +1,7 @@
package xyz.wbsite.frame.auth;
package xyz.wbsite.frame.base;
import xyz.wbsite.frame.listener.FrameListener;
import xyz.wbsite.frame.utils.IDgenerator;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@ -12,7 +13,7 @@ import java.util.Set;
* @version 0.0.1
* @since 2017-01-01
*/
public class Token implements Serializable {
public class Token implements Serializable {
private static final Long serialVersionUID = 1L;
/**
* ID
@ -30,10 +31,22 @@ public class Token implements Serializable {
*
*/
private String userName;
/**
*
*/
private String userAlias;
private Set<String> resSet = new HashSet<>();
public boolean hasRes(String res) {
{// todo 开发初期收集资源,后期删除
String active = LocalData.getActive();
if (active.contains("dev")) {//测试环境捕获资源
FrameListener instance = FrameListener.getInstance();
instance.onRes(res);
}
}
for (String s : resSet) {
if (res.matches(s)) {
return true;
@ -51,12 +64,10 @@ public class Token implements Serializable {
this.resSet.addAll(resourceSet);
}
public Set<String> getResSet() {
return resSet;
}
public long getId() {
return id;
}
@ -81,6 +92,14 @@ public class Token implements Serializable {
this.userName = userName;
}
public String getUserAlias() {
return userAlias;
}
public void setUserAlias(String userAlias) {
this.userAlias = userAlias;
}
public String getToken() {
return token;
}

@ -0,0 +1,14 @@
package xyz.wbsite.frame.base;
import xyz.wbsite.frame.base.BaseRequest;
/**
* VerifyCodeRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2020-12-24
*/
public class VerifyCodeRequest extends BaseRequest {
}

@ -1,47 +0,0 @@
package xyz.wbsite.frame.excel;
import java.io.Serializable;
/**
* WCell - Excel
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class WCell implements Serializable {
/**
*
*/
private String value;
/**
* excel
*/
private String error;
public WCell() {
this.value = "";
}
public WCell(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}

@ -1,146 +0,0 @@
package xyz.wbsite.frame.excel;
import xyz.wbsite.frame.excel.converter.Converter;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* WColumn - Excel()
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class WColumn implements Serializable {
/**
*
*/
private String name = "";
/**
*
*/
private int cellWidth = 8;
/**
*
*/
private boolean isRequired = false;
/**
*
*/
private String description = "";
/**
*
*/
private Converter converter;
/**
* Field
*/
private Field field;
/**
* set
*/
private Method setMethod;
/**
* get
*/
private Method getMethod;
/**
* ExcelType
*/
private int cellType = 1;
/**
*
*/
private String[] cellList;
public WColumn() {
this.name = "";
}
public WColumn(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Field getField() {
return field;
}
public void setField(Field field) {
this.field = field;
}
public int getCellWidth() {
return cellWidth;
}
public void setCellWidth(int cellWidth) {
this.cellWidth = cellWidth;
}
public boolean isRequired() {
return isRequired;
}
public void setRequired(boolean isRequired) {
this.isRequired = isRequired;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Converter getConverter() {
return converter;
}
public void setConverter(Converter converter) {
this.converter = converter;
}
public int getCellType() {
return cellType;
}
public void setCellType(int cellType) {
this.cellType = cellType;
}
public Method getSetMethod() {
return setMethod;
}
public void setSetMethod(Method setMethod) {
this.setMethod = setMethod;
}
public Method getGetMethod() {
return getMethod;
}
public void setGetMethod(Method getMethod) {
this.getMethod = getMethod;
}
public String[] getCellList() {
return cellList;
}
public void setCellList(String[] cellList) {
this.cellList = cellList;
}
}

@ -1,34 +0,0 @@
package xyz.wbsite.frame.excel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* WRow - ExcelWCell<br>HashMap<String, WCell>,keyvalue
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class WRow extends HashMap<String, WCell> implements Serializable {
private List<String> errorList = new ArrayList<>();
public final boolean hasError() {
return errorList.size() > 0;
}
public final void addError(String errorMsg) {
errorList.add(errorMsg);
}
public final void addErrors(List<String> errorMsgs) {
errorList.addAll(errorMsgs);
}
public List<String> getErrorList() {
return errorList;
}
}

@ -1,40 +0,0 @@
package xyz.wbsite.frame.excel.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* ColumnName - ExcelExcel使
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ColumnName {
/**
*
*/
String value();
/**
*
*/
int width() default 8;
/**
* *
*/
boolean required() default false;
/**
*
*/
String dateFormat() default "yyyy-MM-dd";
}

@ -7,7 +7,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* ColumnList -
* ExcelSelect -
*
* @author wangbing
* @version 0.0.1
@ -16,7 +16,7 @@ import java.lang.annotation.Target;
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ColumnList {
public @interface ExcelSelect {
/**
*

@ -7,15 +7,13 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Ignore - Excel
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
@Target(ElementType.FIELD)
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Ignore {
boolean value() default true;
public @interface ExcelSheet {
String value();
}

@ -1,24 +1,23 @@
package xyz.wbsite.frame.excel.converter;
import xyz.wbsite.frame.excel.exception.ValueConverterException;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
* BooleanConverter - BooleanStringString
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class BooleanConverter implements Converter<Boolean> {
@Override
public Boolean convert(String var) throws ValueConverterException {
if (null == var || "".equals(var)) {
return false;
}
public Class supportJavaTypeKey() {
return Boolean.class;
}
String lowerCase = var.toLowerCase();
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
public Boolean convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
String lowerCase = cellData.getStringValue().toLowerCase();
if (lowerCase.matches("y|n")) {
return "y".equals(lowerCase);
} else if (lowerCase.matches("yes|no")) {
@ -32,15 +31,14 @@ public class BooleanConverter implements Converter<Boolean> {
} else if (lowerCase.matches("是|不是")) {
return "是".equals(lowerCase);
} else {
throw new ValueConverterException("[" + var + "] can not convert to Boolean");
throw new RuntimeException("[" + cellData.getStringValue() + "] 值有错误!");
}
}
@Override
public String string(Boolean var) {
if (var == null) {
return "";
public CellData convertToExcelData(Boolean value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
if (value == null) {
return new CellData("");
}
return var ? "是" : "否";
return new CellData(value ? "是" : "否");
}
}

@ -1,28 +0,0 @@
package xyz.wbsite.frame.excel.converter;
/**
* CharacterConverter - CharacterStringString
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class CharacterConverter implements Converter<Character> {
@Override
public Character convert(String var) {
if (var == null || var.equals("")) {
return '0';
} else {
return var.charAt(0);
}
}
@Override
public String string(Character var) {
if (var == null) {
return "";
}
return String.valueOf(var).trim();
}
}

@ -1,51 +0,0 @@
package xyz.wbsite.frame.excel.converter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* DateConverter - DateStringString
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class DateConverter implements Converter<Date> {
@Override
public Date convert(String var) {
if (var == null) {
return null;
}
Date date = null;
try {
var = var.trim();
if (var.matches("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse(var);
} else if (var.matches("[0-9]{4}/[0-9]{1,2}/[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse(var);
} else if (var.matches("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
date = sdf.parse(var);
} else if (var.matches("[0-9]{4}年[0-9]{1,2}月[0-9]{1,2}日 [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
date = sdf.parse(var);
}
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
@Override
public String string(Date var) {
if (var == null) {
return "";
}
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(var);
}
}

@ -1,28 +0,0 @@
package xyz.wbsite.frame.excel.converter;
/**
* DoubleConverter - DoubleStringString
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class DoubleConverter implements Converter<Double> {
@Override
public Double convert(String var) {
try {
return Double.parseDouble(var);
} catch (Exception e) {
return 0d;
}
}
@Override
public String string(Double var) {
if (var == null) {
return "";
}
return String.valueOf(var);
}
}

@ -1,33 +0,0 @@
package xyz.wbsite.frame.excel.converter;
/**
* FloatConverter - FloatStringString
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class FloatConverter implements Converter<Float> {
@Override
public Float convert(String var) {
try {
//增加对1.0一类的的优化显示
if (var.matches("(\\d+)\\.0")) {
var = var.replaceAll("\\.0$", "");
}
return Float.parseFloat(var);
} catch (Exception e) {
return 0f;
}
}
@Override
public String string(Float var) {
if (var == null) {
return "";
}
return String.valueOf(var);
}
}

@ -1,28 +0,0 @@
package xyz.wbsite.frame.excel.converter;
/**
* ShortConverter - ShortStringString
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class ShortConverter implements Converter<Short> {
@Override
public Short convert(String var) {
try {
return Short.parseShort(var);
} catch (Exception e) {
return 0;
}
}
@Override
public String string(Short var) {
if (var == null) {
return "";
}
return String.valueOf(var);
}
}

@ -1,17 +0,0 @@
package xyz.wbsite.frame.excel.exception;
/**
* Excel
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class ReadErrorException extends Exception {
public ReadErrorException() {
}
public ReadErrorException(String s) {
super(s);
}
}

@ -1,15 +0,0 @@
package xyz.wbsite.frame.excel.exception;
/**
*
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class ValueConverterException extends Exception {
public ValueConverterException(String s) {
super(s);
}
}

@ -0,0 +1,24 @@
package xyz.wbsite.frame.excel.handler;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.handler.AbstractCellWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.Cell;
import java.util.List;
public abstract class HeadWriteHandler extends AbstractCellWriteHandler {
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
super.afterCellDispose(writeSheetHolder, writeTableHolder, cellDataList, cell, head, relativeRowIndex, isHead);
if (isHead) {
handlerHead(head);
}
}
protected abstract void handlerHead(Head head);
}

@ -0,0 +1,50 @@
package xyz.wbsite.frame.excel.handler;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import xyz.wbsite.frame.excel.WHead;
import java.util.List;
import java.util.Map;
public class WCellWriteHandler implements CellWriteHandler {
private CellStyle[] styles;
private Map<Integer, List<String>> errMap;
public WCellWriteHandler(List<WHead> wHeads, CellStyle[] styles, Map<Integer, List<String>> errMap) {
this.styles = styles;
this.errMap = errMap;
}
@Override
public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer integer, Integer integer1, Boolean isHead) {
}
@Override
public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer integer, Boolean isHead) {
}
@Override
public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer integer, Boolean isHead) {
}
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> list, Cell cell, Head head, Integer rowIndex, Boolean isHead) {
if (isHead) {
cell.setCellStyle(styles[0]);
} else if (errMap.get(rowIndex) != null) {
cell.setCellStyle(styles[1]);
}
}
}

@ -1,57 +0,0 @@
package xyz.wbsite.frame.excel.style;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Workbook;
/**
* Created on 2015/1/29.
*
* @author
* @since 2.0.0
*/
public class BaseCellStyle {
/**
*
*/
protected CellStyle style;
public BaseCellStyle(Workbook workbook) {
style = workbook.createCellStyle();
style.setFillPattern(CellStyle.NO_FILL);
//下边框
style.setBorderBottom(CellStyle.SOLID_FOREGROUND);
//下边框颜色
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
//左边框
style.setBorderLeft(CellStyle.SOLID_FOREGROUND);
//左边框颜色
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
//右边框
style.setBorderRight(CellStyle.SOLID_FOREGROUND);
//右边框颜色
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
//上边框
style.setBorderTop(CellStyle.SOLID_FOREGROUND);
//上边框颜色
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //上下居中
style.setBorderBottom(CellStyle.SOLID_FOREGROUND); //下边框
style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); //下边框颜色
style.setBorderLeft(CellStyle.SOLID_FOREGROUND); //左边框
style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); //左边框颜色
style.setBorderRight(CellStyle.SOLID_FOREGROUND); //右边框
style.setRightBorderColor(IndexedColors.BLACK.getIndex()); //右边框颜色
style.setBorderTop(CellStyle.SOLID_FOREGROUND); //上边框
style.setTopBorderColor(IndexedColors.BLACK.getIndex()); //上边框颜色
}
public CellStyle getStyle() {
return style;
}
public void setStyle(CellStyle style) {
this.style = style;
}
}

@ -1,29 +0,0 @@
package xyz.wbsite.frame.excel.style;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Workbook;
/**
* Created on 2015/1/29.
*
* @author
* @since 2.0.0
*/
public class BaseFont {
/**
*
*/
protected Font font;
public BaseFont(Workbook workbook) {
font = workbook.createFont();
}
public Font getFont() {
return font;
}
public void setFont(Font font) {
this.font = font;
}
}

@ -1,18 +0,0 @@
package xyz.wbsite.frame.excel.style;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Workbook;
/**
* .
* Created on 2015/1/29.
*
* @author
* @since 2.0.0
*/
public class NormalFont extends BaseFont {
public NormalFont(Workbook workbook) {
super(workbook);
font.setColor(HSSFColor.BLACK.index); //字体颜色-黑色
}
}

@ -1,22 +0,0 @@
package xyz.wbsite.frame.excel.style;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Workbook;
public class SuccessCellStyle extends BaseCellStyle {
public SuccessCellStyle(Workbook workbook) {
super(workbook);
style.setFillForegroundColor(HSSFColor.GREEN.index); //背景颜色红色
style.setFillPattern(CellStyle.SOLID_FOREGROUND); //设置单元格填充样式
}
public CellStyle getStyle() {
return style;
}
public void setStyle(CellStyle style) {
this.style = style;
}
}

@ -0,0 +1,46 @@
package xyz.wbsite.frame.listener;
import xyz.wbsite.frame.base.LocalData;
import java.util.Map;
public class FrameListener {
private static FrameListener ourInstance = new FrameListener();
public static FrameListener getInstance() {
return ourInstance;
}
private FrameListener() {
}
public void onRes(String res) {
Map<String, IResListener> beansOfType = LocalData.getApplicationContext().getBeansOfType(IResListener.class);
for (IResListener resListener : beansOfType.values()) {
resListener.onRes(res);
}
}
public void onError(Throwable throwable) {
Map<String, IErrorListener> beansOfType = LocalData.getApplicationContext().getBeansOfType(IErrorListener.class);
for (IErrorListener errorListener : beansOfType.values()) {
errorListener.error(throwable);
}
}
public void onError(String message) {
onError(new RuntimeException(message));
}
public void onTaskError(Throwable error) {
Map<String, IErrorListener> beansOfType = LocalData.getApplicationContext().getBeansOfType(IErrorListener.class);
for (IErrorListener errorListener : beansOfType.values()) {
errorListener.error(error);
}
}
public void onTaskError(String message) {
onTaskError(new RuntimeException(message));
}
}

@ -0,0 +1,9 @@
package xyz.wbsite.frame.listener;
/**
*
*/
public interface IErrorListener {
void error(Throwable error);
}

@ -0,0 +1,15 @@
package xyz.wbsite.frame.provider;
import xyz.wbsite.frame.base.DictEntity;
import javax.validation.constraints.NotNull;
import java.util.List;
public interface DictProvider {
List<DictEntity> getDict(@NotNull String dictName);
boolean isExist(@NotNull String dictName);
boolean isExistValue(@NotNull String dictName, @NotNull String dictKey);
}

@ -0,0 +1,74 @@
package xyz.wbsite.frame.provider;
import xyz.wbsite.frame.base.LocalData;
import java.util.Iterator;
import java.util.Map;
public class FrameProvider {
private static FrameProvider ourInstance = new FrameProvider();
public static FrameProvider getInstance() {
return ourInstance;
}
private FrameProvider() {
}
public UserProvider getUserProvider() {
Map<String, UserProvider> beansOfType = LocalData.getApplicationContext().getBeansOfType(UserProvider.class);
if (beansOfType.size() == 0) {
return null;
}
Iterator<String> iterator = beansOfType.keySet().iterator();
String name = iterator.next();
while (iterator.hasNext()) {
String next = iterator.next();
name = !"simpleUserProvider".equals(next) ? next : name;
}
return beansOfType.get(name);
}
public TokenProvider getTokenProvider() {
Map<String, TokenProvider> beansOfType = LocalData.getApplicationContext().getBeansOfType(TokenProvider.class);
if (beansOfType.size() == 0) {
return null;
}
Iterator<String> iterator = beansOfType.keySet().iterator();
String name = iterator.next();
while (iterator.hasNext()) {
String next = iterator.next();
name = !"simpleTokenProvider".equals(next) ? next : name;
}
return beansOfType.get(name);
}
public ProfileProvider getProfileProvider() {
Map<String, ProfileProvider> beansOfType = LocalData.getApplicationContext().getBeansOfType(ProfileProvider.class);
if (beansOfType.size() == 0) {
return null;
}
Iterator<String> iterator = beansOfType.keySet().iterator();
String name = iterator.next();
while (iterator.hasNext()) {
String next = iterator.next();
name = !"simpleProfileProvider".equals(next) ? next : name;
}
return beansOfType.get(name);
}
public DictProvider getDictProvider() {
Map<String, DictProvider> beansOfType = LocalData.getApplicationContext().getBeansOfType(DictProvider.class);
if (beansOfType.size() == 0) {
return null;
}
Iterator<String> iterator = beansOfType.keySet().iterator();
String name = iterator.next();
while (iterator.hasNext()) {
String next = iterator.next();
name = !"simpleDictProvider".equals(next) ? next : name;
}
return beansOfType.get(name);
}
}

@ -0,0 +1,7 @@
package xyz.wbsite.frame.provider;
import xyz.wbsite.frame.base.LogTaskEntity;
public interface LogTaskCollector {
void collector(LogTaskEntity entity);
}

@ -0,0 +1,51 @@
package xyz.wbsite.frame.provider;
import xyz.wbsite.frame.base.LocalData;
import xyz.wbsite.frame.utils.StringUtil;
public class SimpleProfileProvider implements ProfileProvider {
@Override
public String getString(String key, String defaultValue) {
return LocalData.getProperty(key, defaultValue);
}
@Override
public int getInt(String key, int defaultValue) {
String string = getString(key, String.valueOf(defaultValue));
if (!StringUtil.isEmpty(string)) {
try {
return Integer.parseInt(string);
} catch (Exception ignored) {
}
}
return defaultValue;
}
@Override
public long getLong(String key, long defaultValue) {
String string = this.getString(key, String.valueOf(defaultValue));
if (!StringUtil.isEmpty(string)) {
try {
return Long.parseLong(string);
} catch (Exception ignored) {
}
}
return defaultValue;
}
@Override
public boolean getBoolean(String key, boolean defaultValue) {
String string = this.getString(key, String.valueOf(defaultValue));
if (!StringUtil.isEmpty(string)) {
try {
return Boolean.parseBoolean(string);
} catch (Exception ignored) {
}
}
return defaultValue;
}
}

@ -0,0 +1,38 @@
package xyz.wbsite.frame.provider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xyz.wbsite.config.CacheConfig;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.base.UserEntity;
import xyz.wbsite.frame.utils.IDgenerator;
import javax.validation.constraints.NotNull;
@Component
public class SimpleTokenProvider implements TokenProvider {
@Autowired
private CacheConfig cacheConfig;
public Token build(@NotNull UserEntity userEntity) {
Token token = new Token();
token.setId(IDgenerator.nextId());
token.setUserId(userEntity.getId());
token.setToken(IDgenerator.nextUUID());
token.setUserName(userEntity.getUserName());
token.setUserAlias(userEntity.getUserAlias());
token.putRes(userEntity.getResSet());
cacheConfig.put(token.getToken(), token, 3 * 60 * 60 * 1000);
return token;
}
public Token build(@NotNull String token) {
// 检索缓存Token
Object o = cacheConfig.get(token);
if (o != null && o instanceof Token) {
return (Token) o;
}
return null;
}
}

@ -0,0 +1,23 @@
package xyz.wbsite.frame.provider;
import org.springframework.stereotype.Component;
import xyz.wbsite.frame.base.LocalData;
import xyz.wbsite.frame.base.UserEntity;
@Component
public class SimpleUserProvider implements UserProvider {
public UserEntity getUser(String username) {
String admin = LocalData.getProperty("web.url.auth.admin", "");
if (!username.equals(admin)) {
return null;
}
UserEntity userEntity = new UserEntity();
userEntity.setId(0L);
userEntity.setUserName(username);
userEntity.setUserAlias("超级管理员");
userEntity.setPassword(LocalData.getProperty("web.url.auth.pwd", ""));
userEntity.putRes(".*");
return userEntity;
}
}

@ -0,0 +1,9 @@
package xyz.wbsite.frame.provider;
import xyz.wbsite.frame.base.SqlTaskEntity;
import java.util.List;
public interface SqlTaskProvider {
List<SqlTaskEntity> getSqlTask();
}

@ -0,0 +1,13 @@
package xyz.wbsite.frame.provider;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.base.UserEntity;
import javax.validation.constraints.NotNull;
public interface TokenProvider {
Token build(@NotNull UserEntity userEntity);
Token build(@NotNull String token);
}

@ -0,0 +1,8 @@
package xyz.wbsite.frame.provider;
import xyz.wbsite.frame.base.UserEntity;
public interface UserProvider {
UserEntity getUser(String username);
}

@ -0,0 +1,8 @@
package xyz.wbsite.frame.provider;
import xyz.wbsite.frame.base.VisitorEntity;
public interface VisitorProvider {
VisitorEntity getVisitor(String appKey);
}

@ -6,6 +6,14 @@ import org.springframework.util.Assert;
import java.time.Duration;
import java.util.concurrent.ScheduledFuture;
/**
* AB
* AB
*
* @author wangbing
* @version 0.0.1
* @since 2020-01-01
*/
public abstract class RunDelayRepeatTask extends RunTask {
public abstract Duration interval();

@ -6,6 +6,13 @@ import org.springframework.util.Assert;
import java.time.Duration;
import java.util.concurrent.ScheduledFuture;
/**
* ABA
*
* @author wangbing
* @version 0.0.1
* @since 2020-01-01
*/
public abstract class RunFixRepeatTask extends RunTask {
public abstract Duration interval();

@ -1,40 +0,0 @@
package xyz.wbsite.frame.schedule;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import xyz.wbsite.frame.auth.LocalData;
import xyz.wbsite.frame.utils.LogUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public abstract class RunSqlTask extends RunFixRepeatTask {
private Connection connection;
@Override
public void run() {
try {
if (connection == null || connection.isClosed()) {
SqlSessionFactory factory = LocalData.getBean(SqlSessionFactory.class);
SqlSession sqlSession = factory.openSession(true);
connection = sqlSession.getConnection();
}
} catch (Exception e) {
e.printStackTrace();
LogUtil.e("schedule: get connection failed!");
return;
}
try {
PreparedStatement preparedStatement = connection.prepareStatement(getSql());
preparedStatement.execute();
preparedStatement.close();
} catch (SQLException e) {
e.printStackTrace();
LogUtil.e("RunSqlTask exec failed! SQL:[" + getSql() + "]");
}
}
public abstract String getSql();
}

@ -1,21 +1,93 @@
package xyz.wbsite.frame.schedule;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import xyz.wbsite.frame.base.LocalData;
import xyz.wbsite.frame.base.LogTaskEntity;
import xyz.wbsite.frame.provider.LogTaskCollector;
import xyz.wbsite.frame.utils.LogUtil;
import java.util.Date;
import java.util.concurrent.ScheduledFuture;
/**
*
*
* @author wangbing
* @version 0.0.1
* @since 2020-01-01
*/
public abstract class RunTask implements Runnable {
public abstract String taskId();
public abstract ScheduledFuture<?> schedule(ThreadPoolTaskScheduler poolTaskScheduler);
protected abstract void task();
public String taskName() {
return "";
}
public void configChange(ThreadPoolTaskScheduler scheduler) {
ScheduledFuture<?> schedule = scheduler.schedule(this, new Date());
if (!schedule.cancel(true)) {
public String taskNote() {
return "";
}
@Override
public void run() {
LogTaskEntity logTaskEntity = new LogTaskEntity();
logTaskEntity.setTaskId(taskId());
logTaskEntity.setTaskName(taskName());
logTaskEntity.setStartTime(new Date());
try {
boolean before = before();
if (before) {
task();
}
after();
logTaskEntity.setExecState("1");
logTaskEntity.setExecResult("成功");
logTaskEntity.setEndTime(new Date());
} catch (Exception e) {
exception(e);
// 保证异常信息不会超过字段长度
String trace = LogUtil.getTrace(e);
if (trace.length() > 496) {
trace = trace.substring(0, 496);
}
logTaskEntity.setExecState("0");
logTaskEntity.setExecResult(String.format("失败[%s]", trace));
logTaskEntity.setEndTime(new Date());
}
try {
// 任务执行结果
logTaskEntity.setExecTime((int) (logTaskEntity.getEndTime().getTime() - logTaskEntity.getStartTime().getTime()));
LogTaskCollector logtaskManager = LocalData.getBean(LogTaskCollector.class);
if (logtaskManager != null) logtaskManager.collector(logTaskEntity);
// todo 考虑是否将任务的异常归为故障
} catch (Exception ignored) {
}
}
/**
*
*
* @return
*/
protected boolean before() {
return true;
}
/**
*
*/
protected void after() {
}
/**
*
*/
protected void exception(Exception e) {
e.printStackTrace();
}
public abstract ScheduledFuture<?> schedule(ThreadPoolTaskScheduler poolTaskScheduler);
}

@ -0,0 +1,58 @@
package xyz.wbsite.frame.sse;
import org.springframework.http.MediaType;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import xyz.wbsite.frame.utils.MapperUtil;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
public class Sser {
private static ConcurrentHashMap<String, SseEmitter> sseMap = new ConcurrentHashMap();
/**
*
*/
public static SseEmitter register(String key, SseEmitter sseEmitter) {
if (sseMap.get(key) != null) {
sseMap.remove(key);
}
sseMap.put(key, sseEmitter);
return sseEmitter;
}
/**
*
*
* @param key key
* @param data
*/
public static void push(String key, Object data) {
SseEmitter sseEmitter = sseMap.get(key);
if (sseEmitter == null) {
return;
}
try {
sseEmitter.send(MapperUtil.toJson(data), MediaType.APPLICATION_JSON);
} catch (IOException e) {
sseMap.remove(key);
}
}
/**
*
*
* @param data
*/
public static void pushAll(Object data) {
for (String s : sseMap.keySet()) {
try {
sseMap.get(s).send(MapperUtil.toJson(data), MediaType.APPLICATION_JSON);
} catch (IOException e) {
sseMap.remove(s);
}
}
}
}

@ -10,6 +10,7 @@ import java.util.Arrays;
* @since 2017-01-01
*/
public class Base64Util {
private static final char[] CA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
private static final int[] IA = new int[256];

@ -1,11 +1,26 @@
package xyz.wbsite.frame.utils;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Stack;
/**
* ClassUtil
* ClassUtil
*
* @author wangbing
* @version 0.0.1
@ -14,28 +29,53 @@ import java.util.*;
public class ClassUtil {
/**
*
* ()
*
* @param clazz
* @param clazz
* @return
*/
public static Field[] getFields(Class clazz) {
return getFields(clazz, false);
}
/**
*
*
* @param clazz
* @param parentFirst
* @return
* @return
*/
public static Field[] getFields(Class clazz, boolean parentFirst) {
Field[] fields = clazz.getDeclaredFields();
if (parentFirst) {
Field[] parentFields = getParentFields(clazz.getSuperclass());
return concat(fields, parentFields);
return ArrayUtil.merge(fields, parentFields);
}
return fields;
}
/**
*
*
*
* @param clazz
* @param clazz
* @return
*/
private static Field[] getParentFields(Class clazz) {
if (clazz != null && clazz.getSuperclass() != null) {
Field[] pfs = clazz.getSuperclass().getDeclaredFields();
Field[] ppfs = getParentFields(clazz.getSuperclass());
return ArrayUtil.merge(pfs, ppfs);
}
return new Field[0];
}
/**
*
*
* @param clazz
* @return
*/
public static boolean isCollection(Class<?> clazz) {
return Collection.class.isAssignableFrom(clazz);
}
@ -44,10 +84,10 @@ public class ClassUtil {
* GET
*
* @param name
* @param pojoClass POJO
* @return
* @param pojoClass
* @return
*/
public static Method getMethod(String name, Class<?> pojoClass) throws RuntimeException {
public static Method getMethod(String name, Class<?> pojoClass) {
String getMethodName = "get" + StringUtil.upperFirstWord(name);
try {
return pojoClass.getMethod(getMethodName);
@ -66,17 +106,23 @@ public class ClassUtil {
*
* @param name
* @param pojoClass POJO
* @return
* @return
*/
public static Method setMethod(String name, Class<?> pojoClass, Class<?> type) {
String setMethodName = "set" + StringUtil.upperFirstWord(name);
try {
return pojoClass.getMethod(setMethodName, type);
} catch (Exception e) {
return null;
throw new RuntimeException("can not find[" + name + "]method");
}
}
/**
*
*
* @param field
* @return
*/
public static boolean isJavaClass(Field field) {
Class<?> fieldType = field.getType();
boolean isBaseClass = false;
@ -92,23 +138,139 @@ public class ClassUtil {
return isBaseClass;
}
public static Field[] getFields(Class clazz) {
return getFields(clazz, false);
/**
* @param sourcePath
* @param classPath
* @return
*/
public static boolean compile(String sourcePath, String classPath) {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
Iterable<String> options = Arrays.asList("-d", classPath);
List<File> fileList = listJavaFile(sourcePath);
File[] files = new File[fileList.size()];
fileList.toArray(files);
Iterable<? extends JavaFileObject> javaFileObjects = fileManager.getJavaFileObjects(files);
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, options, null, javaFileObjects);
return task.call();
}
private static Field[] getParentFields(Class parentClazz) {
if (parentClazz != null) {
Field[] fields = parentClazz.getDeclaredFields();
Field[] parentFields = getParentFields(parentClazz.getSuperclass());
return concat(fields, parentFields);
/**
* @param className
* @param classContent
* @param classPath
* @return
*/
public static boolean compileStringJava(String className, String classContent, String classPath) {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
Iterable<String> options = Arrays.asList("-d", classPath);
SimpleJavaFileObject simpleJavaFileObject = new SimpleJavaFileObject(
URI.create("string:///" + className.replace('.', '/') + JavaFileObject.Kind.SOURCE.extension),
JavaFileObject.Kind.SOURCE) {
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return classContent;
}
};
Iterable<JavaFileObject> simpleJavaFileObjects = Arrays.asList(simpleJavaFileObject);
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, options, null, simpleJavaFileObjects);
return task.call();
}
private static List<File> listJavaFile(String sourcePath) {
ArrayList<File> result = new ArrayList<>();
File file = new File(sourcePath);
if (!file.exists()) file.mkdirs();
for (File item : file.listFiles()) {
if (item.isFile() && item.getName().endsWith(".java")) {
result.add(item);
} else if (item.isDirectory()) {
result.addAll(listJavaFile(item.getAbsolutePath()));
}
}
return new Field[0];
return result;
}
private static Field[] concat(Field[] f1, Field[] f2) {
Field[] fields = new Field[f1.length + f2.length];
System.arraycopy(f1, 0, fields, 0, f1.length);
System.arraycopy(f2, 0, fields, f1.length, f2.length);
return fields;
public static void loadClass(String classPath) throws Exception {
loadClass(new File(classPath));
}
/**
* clazzPath
* <p>
* clazzPath = /classes class/classes/text/test.class
*
* @param classPath
* @throws Exception
*/
public static void loadClass(File classPath) throws Exception {
// 记录加载.class文件的数量
int clazzCount = 0;
//only handle the folder
if (classPath.isFile()) {
classPath = classPath.getParentFile();
}
if (classPath.exists() && classPath.isDirectory()) {
// 获取路径长度
int classPathLen = classPath.getAbsolutePath().length() + 1;
Stack<File> stack = new Stack<>();
stack.push(classPath);
// 遍历类路径
while (stack.isEmpty() == false) {
File path = stack.pop();
File[] classFiles = path.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isDirectory() || pathname.getName().endsWith(".class");
}
});
for (File subFile : classFiles) {
if (subFile.isDirectory()) {
stack.push(subFile);
} else {
if (clazzCount++ == 0) {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
boolean accessible = method.isAccessible();
try {
if (accessible == false) {
method.setAccessible(true);
}
// 设置类加载器
URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
// 将当前类路径加入到类加载器中
method.invoke(classLoader, classPath.toURI().toURL());
} finally {
method.setAccessible(accessible);
}
}
// 文件名称
String className = subFile.getAbsolutePath();
className = className.substring(classPathLen, className.length() - 6);
className = className.replace(File.separatorChar, '.');
// 加载Class类
Class.forName(className);
System.out.println(String.format("读取应用程序类文件[class=%s]", className));
}
}
}
}
}
/**
*
* {@link #loadClass(File)}
* Class.forName()ClassClass.forName(name)
*
* @param className (package,)
* @return
* @throws Exception
*/
public static Class<?> getClass(String className) throws Exception {
ClassLoader loader = ClassUtil.class.getClassLoader();
return loader.loadClass(className);
}
}

@ -1,8 +1,7 @@
package xyz.wbsite.frame.utils;
import xyz.wbsite.frame.auth.LocalData;
import xyz.wbsite.frame.base.LocalData;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
@ -42,9 +41,7 @@ public class CookieUtil {
* @param value
*/
public static Cookie newCookie(String name, String value) {
HttpServletRequest request = LocalData.getRequest();
Cookie cookie = new Cookie(name, value);
cookie.setDomain(request.getServerName());
cookie.setMaxAge(-1);
cookie.setPath("/");
return cookie;
@ -56,10 +53,8 @@ public class CookieUtil {
* @param name
*/
public static void clearCookie(String name) {
HttpServletRequest request = LocalData.getRequest();
HttpServletResponse response = LocalData.getResponse();
Cookie cookie = new Cookie(name, null);
cookie.setDomain(request.getServerName());
cookie.setMaxAge(0);
cookie.setPath("/");
response.addCookie(cookie);

@ -47,7 +47,7 @@ public class MD5Util {
try {
MessageDigest md = MessageDigest.getInstance("md5");
byte[] e = md.digest(value.getBytes());
return toHexString(e);
return BytesUtil.bytes2Hex(e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return value;
@ -64,28 +64,10 @@ public class MD5Util {
try {
MessageDigest md = MessageDigest.getInstance("md5");
byte[] e = md.digest(bytes);
return toHexString(e);
return BytesUtil.bytes2Hex(e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
}
}
/**
* @param bytes
* @return Hex
*/
private static String toHexString(byte bytes[]) {
StringBuilder hs = new StringBuilder();
String stmp = "";
for (int n = 0; n < bytes.length; n++) {
stmp = Integer.toHexString(bytes[n] & 0xff);
if (stmp.length() == 1)
hs.append("0").append(stmp);
else
hs.append(stmp);
}
return hs.toString();
}
}

@ -0,0 +1,33 @@
package xyz.wbsite.frame.utils;
import java.util.Random;
public class RandomUtil {
/**
* [min,max)
* @param min ()
* @param max ()
* @return
*/
public static int getInt(int min, int max) {
Random random = new Random();
int nextInt = random.nextInt(max - min);
return nextInt + min;
}
/**
*
* @param dict
* @param len
* @return
*/
public static String getString(String dict, int len) {
Random r = new Random();
StringBuilder rs = new StringBuilder();
for (int j = 0; j < len; j++) {
rs.append(dict.charAt(r.nextInt(dict.length())));
}
return rs.toString();
}
}

@ -1,6 +1,13 @@
package xyz.wbsite.frame.utils;
import xyz.wbsite.frame.base.LocalData;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* RequestUtil
@ -76,4 +83,81 @@ public class RequestUtil {
return "";
}
}
public static String getScheme(HttpServletRequest request) {
String url = request.getRequestURL().toString();
Pattern compile = Pattern.compile("(http|https)://(.*)/");
Matcher matcher = compile.matcher(url);
if (matcher.find()) {
String group = matcher.group(1);
return group;
}
return "";
}
public static String getDomain(HttpServletRequest request) {
String url = request.getRequestURL().toString();
Pattern compile = Pattern.compile("(http|https)://(.*)(:.*)?/");
Matcher matcher = compile.matcher(url);
if (matcher.find()) {
String group = matcher.group(2);
return group;
}
return "";
}
public static int getPort(HttpServletRequest request) {
String url = request.getRequestURL().toString();
Pattern compile = Pattern.compile("(http|https)://(.*)(:.*)?/");
Matcher matcher = compile.matcher(url);
if (matcher.find()) {
String group = matcher.group(3);
if (group == null) {
return Integer.parseInt(group);
}
}
return 80;
}
public static void setRedirect(String url) {
HttpServletResponse response = LocalData.getResponse();
try {
response.sendRedirect(url);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void setForward(String url) {
HttpServletRequest request = LocalData.getRequest();
HttpServletResponse response = LocalData.getResponse();
try {
request.getRequestDispatcher(url).forward(request, response);
} catch (ServletException | IOException e) {
e.printStackTrace();
}
}
public static String getHeader(HttpServletRequest request, String head, String defaultValue) {
try {
return request.getHeader(head);
} catch (Exception e) {
return defaultValue;
}
}
public static String getHeader(HttpServletRequest request, String head) {
return getHeader(request, head, null);
}
public static Pattern actionPattern = Pattern.compile("^/(.+)\\.htm");
public static String getPage() {
HttpServletRequest request = LocalData.getRequest();
Matcher matcher = actionPattern.matcher(request.getServletPath());
if (!matcher.find()) {
return "";
}
return matcher.group(1);
}
}

@ -5,15 +5,16 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
@ -25,27 +26,78 @@ import java.util.regex.Pattern;
*/
public class ResourceUtil extends ResourceUtils {
/**
*
* :E:\...\classes
* JAR: E:\...\***.jar
*
* @return jar
*/
public static File getApplicationHome() {
ApplicationHome home = new ApplicationHome(ResourceUtil.class);
return home.getSource();
}
/**
*
*
* @param resourcePath
* @return
*/
public static List<String> listFileName(String resourcePath) {
if (!resourcePath.endsWith("/")) {
resourcePath = resourcePath + "/";
}
List<String> result = new ArrayList<>();
List<URL> urls = ResourceUtil.listURL(resourcePath);
for (URL url : urls) {
File file1 = new File(url.getFile());
if (file1.isFile()) {
result.add(file1.getName());
} else if (!file1.isDirectory() && !url.getFile().endsWith("/")) {
result.add(file1.getName());
}
}
return result;
}
/**
* @param resourceLocation
* @return URL
* @throws FileNotFoundException
*/
public static URL getURL(String resourceLocation) throws FileNotFoundException {
if (!resourceLocation.startsWith("classpath:")) {
resourceLocation = "classpath:" + resourceLocation;
}
return ResourceUtils.getURL(resourceLocation);
}
/**
* : /modules/dir/
*
* @param resourcePath
* @return
*/
public static List<String> getResourceFiles(String resourcePath) {
List<String> result = new ArrayList<>();
public static List<URL> listURL(String resourcePath) {
if (!resourcePath.startsWith("/")) {
resourcePath = "/" + resourcePath;
}
if (!resourcePath.endsWith("/")) {
resourcePath = resourcePath + "/";
}
List<URL> result = new ArrayList<>();
File applicationHome = getApplicationHome();
if (applicationHome.getAbsolutePath().endsWith(".jar")) {
if (applicationHome.getName().endsWith(".jar")) {
try {
Pattern pattern = Pattern.compile(".*" + resourcePath + "(.+\\..+)");
Pattern pattern = Pattern.compile("BOOT-INF/classes" + resourcePath + "[^/]+/?$");
JarFile jarFile = new JarFile(applicationHome);
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry jarEntry = entries.nextElement();
String name = jarEntry.getName();
if (name.matches(".*" + resourcePath + "(.+\\..+)")) {
Matcher matcher = pattern.matcher(name);
if (matcher.find()) result.add(matcher.group(1));
if (pattern.matcher(name).find()) {
result.add(getURL(name));
}
}
} catch (IOException e) {
@ -56,35 +108,24 @@ public class ResourceUtil extends ResourceUtils {
ClassPathResource cpr = new ClassPathResource(resourcePath);
File in = cpr.getFile();
for (File file : in.listFiles()) {
result.add(file.getName());
result.add(FileUtil.getURL(file.getAbsolutePath()));
}
return result;
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
/**
* jar
*
* @return jar
*/
public static File getApplicationHome() {
ApplicationHome home = new ApplicationHome(ResourceUtil.class);
return home.getSource();
}
/**
* resource
*
*
* @return
* @return
*/
public static InputStream getResourceInput(String resource) {
public static InputStream getInput(String resourceLocation) {
try {
ClassPathResource classPathResource = new ClassPathResource(resource);
ClassPathResource classPathResource = new ClassPathResource(resourceLocation);
return classPathResource.getInputStream();
} catch (IOException e) {
return null;
@ -92,53 +133,55 @@ public class ResourceUtil extends ResourceUtils {
}
/**
* jar
*
*
* @return
* @return
*/
public static boolean copyResource2File(String resource, File file) {
InputStream resourceInput = getResourceInput(resource);
FileOutputStream fileOutputStream = null;
public static byte[] getBytes(String resourceLocation) {
InputStream is = null;
byte[] result = null;
try {
if (!file.exists()) {
file.createNewFile();
}
fileOutputStream = new FileOutputStream(file);
FileUtil.copy(resourceInput, fileOutputStream);
is = getInput(resourceLocation);
result = new byte[is.available()];
is.read(result);
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
try {
if (fileOutputStream != null) fileOutputStream.close();
if (is != null) is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
return result;
}
/**
*
*
*
* @return
* @param resourceLocation
* @param file
* @return
*/
public static byte[] getResourceBytes(String resource) {
InputStream is = null;
byte[] result = null;
public static boolean copyToFile(String resourceLocation, File file) {
InputStream resourceInput = getInput(resourceLocation);
FileOutputStream fileOutputStream = null;
try {
is = getResourceInput(resource);
result = new byte[is.available()];
is.read(result);
if (!file.exists()) {
throw new RuntimeException(file.getAbsolutePath() + " not exists!");
}
fileOutputStream = FileUtil.openOutputStream(file);
FileUtil.copy(resourceInput, fileOutputStream);
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
try {
if (is != null) is.close();
if (fileOutputStream != null) fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
return true;
}
}

@ -0,0 +1,129 @@
package xyz.wbsite.frame.utils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import xyz.wbsite.frame.base.LocalData;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class SqlUtil {
public static void exec(String sql) {
SqlSession sqlSession = null;
try {
SqlSessionFactory factory = LocalData.getBean(SqlSessionFactory.class);
sqlSession = factory.openSession(true);
Connection connection = sqlSession.getConnection();
PreparedStatement statement = connection.prepareStatement(sql);
statement.execute();
} catch (SQLException e) {
throw new RuntimeException(String.format("[ %s ]执行错误!", sql));
} finally {
if (sqlSession != null) sqlSession.close();
}
}
public static int insert(String sql) {
return update(sql);
}
public static int delete(String sql) {
return update(sql);
}
public static int update(String sql) {
SqlSession sqlSession = null;
int result = 0;
try {
SqlSessionFactory factory = LocalData.getBean(SqlSessionFactory.class);
sqlSession = factory.openSession(true);
Connection connection = sqlSession.getConnection();
PreparedStatement statement = connection.prepareStatement(sql);
result = statement.executeUpdate();
statement.close();
connection.close();
} catch (SQLException e) {
throw new RuntimeException(String.format("[ %s ]执行错误!", sql));
} finally {
if (sqlSession != null) sqlSession.close();
}
return result;
}
public static <T> List<T> select(String sql, Class<T> t) {
List<T> result = new ArrayList<>();
try {
SqlSessionFactory factory = LocalData.getBean(SqlSessionFactory.class);
SqlSession sqlSession = factory.openSession(true);
Connection connection = sqlSession.getConnection();
PreparedStatement statement = connection.prepareStatement(sql);
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
T instance = t.newInstance();
Field[] fields = t.getDeclaredFields();
for (Field field : fields) {
Method method = ClassUtil.setMethod(field.getName(), t, field.getType());
if (field.getType() == String.class) {
String v = resultSet.getString(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Boolean.class || field.getType() == boolean.class) {
boolean v = resultSet.getBoolean(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Byte.class || field.getType() == byte.class) {
byte v = resultSet.getByte(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Short.class || field.getType() == short.class) {
short v = resultSet.getShort(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Character.class || field.getType() == char.class) {
short v = resultSet.getShort(field.getName());
method.invoke(instance, (char) v);
} else if (field.getType() == Integer.class || field.getType() == int.class) {
int v = resultSet.getInt(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Long.class || field.getType() == long.class) {
long v = resultSet.getLong(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Float.class || field.getType() == float.class) {
float v = resultSet.getFloat(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Double.class || field.getType() == double.class) {
double v = resultSet.getDouble(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Byte[].class || field.getType() == byte[].class) {
byte[] v = resultSet.getBytes(field.getName());
method.invoke(instance, v);
} else if (field.getType() == Date.class) {
Date v = resultSet.getDate(field.getName());
method.invoke(instance, v);
} else {
String v = resultSet.getString(field.getName());
method.invoke(instance, v);
}
}
result.add(instance);
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return result;
}
}

@ -1,17 +1,86 @@
package xyz.wbsite.frame.utils;
import java.util.Arrays;
/**
*
*/
public class StringUtil {
public static int getByteLength(String str) {
int length = str.replaceAll("[^\\x00-\\xff]", "**").length();
/**
*
* ("A", 10, "0")==> A000000000
*
* @param text
* @param length
* @param c
* @return
*/
public static String padRight(String text, int length, char c) {
if (text == null) {
throw new IllegalArgumentException("text can not be null!");
}
if (text.length() > length) {
throw new IllegalArgumentException("text's length " + text.length() + " is too long!");
}
char[] array = new char[length];
Arrays.fill(array, text.length(), length, c);
System.arraycopy(text.toCharArray(), 0, array, 0, text.length());
return new String(array);
}
/**
*
* ("A", 10, "0")==> 000000000A
*
* @param text
* @param length
* @param c
* @return
*/
public static String padLeft(String text, int length, char c) {
if (text == null) {
throw new IllegalArgumentException("text can not be null!");
}
if (text.length() > length) {
throw new IllegalArgumentException("text's length " + text.length() + " is too long!");
}
char[] array = new char[length];
Arrays.fill(array, 0, length - text.length(), c);
System.arraycopy(text.toCharArray(), 0, array, length - text.length(), text.length());
return new String(array);
}
/**
* ()
* ==> 2
*
* @param value
* @return
*/
public static int getByteLength(String value) {
int length = value.replaceAll("[^\\x00-\\xff]", "**").length();
return length;
}
public static String upperFirstWord(String str) {
String temp = str.substring(0, 1);
return temp.toUpperCase() + str.substring(1);
/**
*
* myCar ==> MyCar
*
* @param value
* @return
*/
public static String upperFirstWord(String value) {
String temp = value.substring(0, 1);
return temp.toUpperCase() + value.substring(1);
}
/**
*
*
* @param value
* @return
*/
public static boolean isEmpty(String value) {
int strLen;
if (value == null || (strLen = value.length()) == 0) {
@ -25,20 +94,27 @@ public class StringUtil {
return true;
}
/**
*
*
* @param value
* @return
*/
public static boolean isNotEmpty(String value) {
return !isEmpty(value);
}
/**
* ,
*
* @param value
* @return
*/
public static boolean isNumeric(Object obj) {
if (obj == null) {
public static boolean isNumeric(Object value) {
if (value == null) {
return false;
}
char[] chars = obj.toString().toCharArray();
char[] chars = value.toString().toCharArray();
int length = chars.length;
if (length < 1)
return false;
@ -56,7 +132,11 @@ public class StringUtil {
}
/**
*
*
* : \u6211 ==>
*
* @param unicode
* @return
*/
public static String unicodeToChinese(String unicode) {
StringBuilder out = new StringBuilder();
@ -68,7 +148,13 @@ public class StringUtil {
return out.toString();
}
/**
* 线
* :myCar ==> my_car
*
* @param name
* @return
*/
public static String toUnderlineStyle(String name) {
StringBuilder newName = new StringBuilder();
for (int i = 0; i < name.length(); i++) {

@ -0,0 +1,182 @@
package xyz.wbsite.frame.utils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
/**
*
* Builder
*
* @author wangbing
* @version 0.0.1
* @since 2020-05-01
*/
public class VerifyCodeUtil {
public static class Builder {
private String code;
private int size = 35;
private String dict = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
private BufferedImage bufferedImage;
private boolean freeColor = true;
private Color color = Color.BLACK;
private Color bgColor = Color.WHITE;
public Builder code(String code) {
this.code = code;
return this;
}
public Builder size(int size) {
this.size = size;
return this;
}
public Builder dict(String dict) {
this.dict = dict;
return this;
}
public Builder freeColor(boolean freeColor) {
this.freeColor = freeColor;
return this;
}
public Builder color(Color color) {
this.color = color;
return this;
}
public Builder bgColor(Color bgColor) {
this.bgColor = bgColor;
return this;
}
public boolean toFile(File file) {
if (bufferedImage == null) build();
try {
ImageIO.write(bufferedImage, "png", file);
return true;
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
public String toCode() {
return code;
}
public byte[] toBytes() {
if (bufferedImage == null) build();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
ImageIO.write(bufferedImage, "png", stream);
return stream.toByteArray();
} catch (IOException e) {
}
return null;
}
public String toBase64() {
if (bufferedImage == null) build();
return Base64Util.encodeToString(toBytes());
}
public Builder build() {
if (StringUtil.isEmpty(code)) {
this.code = RandomUtil.getString(dict, 4);
}
if (bufferedImage == null) {
bufferedImage = new BufferedImage(size * code.length(), size, BufferedImage.TYPE_INT_RGB);
}
draw(this, bufferedImage);
return this;
}
}
/**
* Builder
*
* @param builder
* @param verifyImg
*/
public static void draw(Builder builder, BufferedImage verifyImg) {
//验证码
String code = builder.code;
//方块大小
int size = builder.size;
//宽度
int width = builder.size * builder.code.length();
//高度
int height = builder.size;
//背景色
Color bgColor = builder.bgColor;
//是否随机颜色
boolean freeColor = builder.freeColor;
//字符颜色仅当freeColor为false时生效
Color color = builder.color;
Graphics2D graphics = (Graphics2D) verifyImg.getGraphics();
graphics.setColor(bgColor);//设置画笔颜色-验证码背景色
graphics.fillRect(0, 0, width, height);//填充背景
graphics.setFont(new Font("微软雅黑", Font.BOLD, (int) (height * 0.9)));
for (int i = 0; i < code.length(); i++) {
char c = code.charAt(i);
int descent = graphics.getFontMetrics().getDescent();// 字符基线以下高度
int charWidth = graphics.getFontMetrics().charWidth(c);// 字符高度
int charHeight = graphics.getFontMetrics().getHeight();// 字符高度
int centerX = size * i + size / 2;// 字符水平中心坐标
int centerY = size / 2;// 字符垂直中心坐标
int offsetX = -charWidth / 2;
int offsetY = charHeight / 2 - descent;
// 设置颜色
graphics.setColor(freeColor ? getRandomColor() : color);
// 设置字体旋转角度
int degree = RandomUtil.getInt(-30, 30);
// 旋转
graphics.rotate(degree * Math.PI / 180, centerX, centerY);
// 绘制字符
graphics.drawString(String.valueOf(c), centerX + offsetX, centerY + offsetY);
// 恢复旋转
graphics.rotate(-degree * Math.PI / 180, centerX, centerY);
}
//画干扰线
for (int i = 0; i < size / 5; i++) {
// 设置颜色
graphics.setColor(freeColor ? getRandomColor() : color);
// 随机画线
graphics.drawLine(RandomUtil.getInt(1, width), RandomUtil.getInt(1, height), RandomUtil.getInt(1, width), RandomUtil.getInt(1, height));
}
//添加噪点
for (int i = 0; i < size; i++) {
int x1 = RandomUtil.getInt(1, width);
int y1 = RandomUtil.getInt(1, height);
graphics.setColor(freeColor ? getRandomColor() : color);
graphics.fillRect(x1, y1, 2, 2);
}
}
/**
*
*/
private static Color getRandomColor() {
int r = RandomUtil.getInt(0, 256);
int g = RandomUtil.getInt(0, 256);
int b = RandomUtil.getInt(0, 256);
Color color = new Color(r, g, b);
return color;
}
}

@ -6,6 +6,13 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
/**
* ZipUtil - Zip
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class ZipUtil {
/**
@ -128,11 +135,4 @@ public class ZipUtil {
in.close();
}
}
public static void main(String[] args) {
//解压
unZip(new File("E:\\AAA.zip"), new File("E:\\AAA"));
//压缩
toZip(new File("E:\\AAA"), new File("E:\\AAA.zip"));
}
}

@ -0,0 +1,119 @@
package xyz.wbsite.module.admin.ent;
import xyz.wbsite.frame.excel.annotation.ExcelNote;
import xyz.wbsite.frame.excel.annotation.ExcelSelect;
import com.alibaba.excel.annotation.ExcelProperty;
import xyz.wbsite.frame.excel.annotation.ExcelSheet;
import xyz.wbsite.frame.base.BaseEntity;
/**
* SERVICES -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
@ExcelSheet("虚拟主机")
public class Services extends BaseEntity {
/**
* TITLE -
*/
@ExcelProperty("主机标题")
@ExcelNote("")
private String title;
/**
* DOMAIN -
*/
@ExcelProperty("主机域名")
@ExcelNote("")
private String domain;
/**
* TYPE -
*/
@ExcelProperty("服务类型")
@ExcelNote("")
private String type;
/**
* PORT -
*/
@ExcelProperty("服务端口")
@ExcelNote("")
private Integer port;
/**
* VALID -
*/
@ExcelProperty("是否启用")
@ExcelNote("")
@ExcelSelect({"是","否"})
private Boolean valid;
/**
* FILTER -
*/
@ExcelProperty("启用过滤")
@ExcelNote("")
@ExcelSelect({"是","否"})
private Boolean filter;
/**
* FILTER_CONF -
*/
@ExcelProperty("过滤配置")
@ExcelNote("")
private String filterConf;
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDomain() {
return this.domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public Integer getPort() {
return this.port;
}
public void setPort(Integer port) {
this.port = port;
}
public Boolean getValid() {
return this.valid;
}
public void setValid(Boolean valid) {
this.valid = valid;
}
public Boolean getFilter() {
return this.filter;
}
public void setFilter(Boolean filter) {
this.filter = filter;
}
public String getFilterConf() {
return this.filterConf;
}
public void setFilterConf(String filterConf) {
this.filterConf = filterConf;
}
}

@ -0,0 +1,168 @@
package xyz.wbsite.module.admin.mgr;
import xyz.wbsite.frame.utils.IDgenerator;
import xyz.wbsite.frame.utils.Message;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.module.admin.ent.ConfigData;
import xyz.wbsite.module.admin.mpr.ConfigDataMapper;
import xyz.wbsite.module.admin.req.ConfigDataCreateRequest;
import xyz.wbsite.module.admin.req.ConfigDataDeleteRequest;
import xyz.wbsite.module.admin.req.ConfigDataFindRequest;
import xyz.wbsite.module.admin.req.ConfigDataUpdateRequest;
import xyz.wbsite.module.admin.rsp.ConfigDataCreateResponse;
import xyz.wbsite.module.admin.rsp.ConfigDataDeleteResponse;
import xyz.wbsite.module.admin.rsp.ConfigDataFindResponse;
import xyz.wbsite.module.admin.rsp.ConfigDataUpdateResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* CONFIG_DATA -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
@Transactional
@Service
public class ConfigDataManagerImpl implements ConfigDataManager {
@Autowired
private ConfigDataMapper configDataMapper;
/**
*
*
* @param request
* @param token
* @return
*/
public ConfigDataCreateResponse create(ConfigDataCreateRequest request, Token token) {
ConfigDataCreateResponse response = new ConfigDataCreateResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
{// 配置名称唯一检查
ConfigDataFindRequest configDataFindRequest = new ConfigDataFindRequest();
configDataFindRequest.setConfName(request.getConfName());
ConfigDataFindResponse configDataFindResponse = this.find(configDataFindRequest, token);
if (configDataFindResponse.hasError()) {
response.addErrors(configDataFindResponse.getErrors());
return response;
} else if (configDataFindResponse.getTotalCount() > 0) {
response.addError(ErrorType.UNIQUENESS_ERROR, "[confName]配置名称已存在,请检查!");
return response;
}
}
long id = IDgenerator.nextId();
ConfigData entity = MapperUtil.map(request, ConfigData.class);
entity.setId(id);
long result = configDataMapper.insert(entity, token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE);
return response;
}
response.setId(id);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
public ConfigDataDeleteResponse delete(ConfigDataDeleteRequest request, Token token) {
ConfigDataDeleteResponse response = new ConfigDataDeleteResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
long result = configDataMapper.delete(request.getId(), token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE);
return response;
}
response.setResult(result);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
public ConfigDataUpdateResponse update(ConfigDataUpdateRequest request, Token token) {
ConfigDataUpdateResponse response = new ConfigDataUpdateResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
ConfigData entity = configDataMapper.getById(request.getId(), token);
if (entity == null) {
response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE);
return response;
}
MapperUtil.map(request, entity);
long result = configDataMapper.update(entity, token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE);
return response;
}
response.setResult(result);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
@Transactional(readOnly = true)
public ConfigDataFindResponse find(ConfigDataFindRequest request, Token token) {
ConfigDataFindResponse response = new ConfigDataFindResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
if (request.getPageSize() != 0) {
PageHelper.startPage(request.getPageNumber(), request.getPageSize());
}
if (StringUtil.isNotEmpty(request.getSortKey())) {
PageHelper.orderBy(request.getSortKey() + " " + request.getSortType());
}
PageInfo<ConfigData> pageInfo = new PageInfo<>(configDataMapper.find(request, token));
response.setResult(pageInfo.getList());
response.setTotalCount(pageInfo.getTotal());
return response;
}
}

@ -0,0 +1,57 @@
package xyz.wbsite.module.admin.mgr;
import xyz.wbsite.module.admin.req.ConfigCreateRequest;
import xyz.wbsite.module.admin.req.ConfigDeleteRequest;
import xyz.wbsite.module.admin.req.ConfigFindRequest;
import xyz.wbsite.module.admin.req.ConfigUpdateRequest;
import xyz.wbsite.module.admin.rsp.ConfigCreateResponse;
import xyz.wbsite.module.admin.rsp.ConfigDeleteResponse;
import xyz.wbsite.module.admin.rsp.ConfigFindResponse;
import xyz.wbsite.module.admin.rsp.ConfigUpdateResponse;
import xyz.wbsite.frame.base.Token;
/**
*
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public interface ConfigManager {
/**
*
*
* @param request
* @param token
* @return
*/
ConfigCreateResponse create(ConfigCreateRequest request, Token token);
/**
*
*
* @param request
* @param token
* @return
*/
ConfigDeleteResponse delete(ConfigDeleteRequest request, Token token);
/**
*
*
* @param request
* @param token
* @return
*/
ConfigUpdateResponse update(ConfigUpdateRequest request, Token token);
/**
*
*
* @param request
* @param token
* @return
*/
ConfigFindResponse find(ConfigFindRequest request, Token token);
}

@ -1,44 +1,41 @@
package xyz.wbsite.module.conf.mgr;
package xyz.wbsite.module.admin.mgr;
import xyz.wbsite.frame.utils.IDgenerator;
import xyz.wbsite.frame.utils.Message;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.module.admin.ent.Config;
import xyz.wbsite.module.admin.mpr.ConfigMapper;
import xyz.wbsite.module.admin.req.ConfigCreateRequest;
import xyz.wbsite.module.admin.req.ConfigDeleteRequest;
import xyz.wbsite.module.admin.req.ConfigFindRequest;
import xyz.wbsite.module.admin.req.ConfigUpdateRequest;
import xyz.wbsite.module.admin.rsp.ConfigCreateResponse;
import xyz.wbsite.module.admin.rsp.ConfigDeleteResponse;
import xyz.wbsite.module.admin.rsp.ConfigFindResponse;
import xyz.wbsite.module.admin.rsp.ConfigUpdateResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xyz.wbsite.frame.auth.Token;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.SortType;
import xyz.wbsite.frame.utils.IDgenerator;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.utils.Message;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.module.conf.ent.Mapping;
import xyz.wbsite.module.conf.mpr.MappingMapper;
import xyz.wbsite.module.conf.req.MappingCreateRequest;
import xyz.wbsite.module.conf.req.MappingDeleteRequest;
import xyz.wbsite.module.conf.req.MappingFindRequest;
import xyz.wbsite.module.conf.req.MappingGetRequest;
import xyz.wbsite.module.conf.req.MappingUpdateRequest;
import xyz.wbsite.module.conf.rsp.MappingCreateResponse;
import xyz.wbsite.module.conf.rsp.MappingDeleteResponse;
import xyz.wbsite.module.conf.rsp.MappingFindResponse;
import xyz.wbsite.module.conf.rsp.MappingGetResponse;
import xyz.wbsite.module.conf.rsp.MappingUpdateResponse;
/**
* MAPPING -
* CONFIG -
*
* @author wangbing
* @version 0.0.1
* @since 2020-03-18
* @since 2021-02-07
*/
@Transactional
@Service
public class MappingManagerImpl implements MappingManager {
public class ConfigManagerImpl implements ConfigManager {
@Autowired
private MappingMapper mappingMapper;
private ConfigMapper configMapper;
/**
*
@ -47,19 +44,32 @@ public class MappingManagerImpl implements MappingManager {
* @param token
* @return
*/
public MappingCreateResponse create(MappingCreateRequest request, Token token) {
MappingCreateResponse response = new MappingCreateResponse();
public ConfigCreateResponse create(ConfigCreateRequest request, Token token) {
ConfigCreateResponse response = new ConfigCreateResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
{// 配置名称唯一检查
ConfigFindRequest configFindRequest = new ConfigFindRequest();
configFindRequest.setConfName(request.getConfName());
ConfigFindResponse configFindResponse = this.find(configFindRequest, token);
if (configFindResponse.hasError()) {
response.addErrors(configFindResponse.getErrors());
return response;
} else if (configFindResponse.getTotalCount() > 0) {
response.addError(ErrorType.UNIQUENESS_ERROR, "[confName]配置名称已存在,请检查!");
return response;
}
}
long id = IDgenerator.nextId();
Mapping entity = MapperUtil.map(request, Mapping.class);
Config entity = MapperUtil.map(request, Config.class);
entity.setId(id);
long result = mappingMapper.insert(entity, token);
long result = configMapper.insert(entity, token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE);
return response;
@ -76,15 +86,15 @@ public class MappingManagerImpl implements MappingManager {
* @param token
* @return
*/
public MappingDeleteResponse delete(MappingDeleteRequest request, Token token) {
MappingDeleteResponse response = new MappingDeleteResponse();
public ConfigDeleteResponse delete(ConfigDeleteRequest request, Token token) {
ConfigDeleteResponse response = new ConfigDeleteResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
long result = mappingMapper.delete(request, token);
long result = configMapper.delete(request.getId(), token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE);
return response;
@ -101,15 +111,22 @@ public class MappingManagerImpl implements MappingManager {
* @param token
* @return
*/
public MappingUpdateResponse update(MappingUpdateRequest request, Token token) {
MappingUpdateResponse response = new MappingUpdateResponse();
public ConfigUpdateResponse update(ConfigUpdateRequest request, Token token) {
ConfigUpdateResponse response = new ConfigUpdateResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
long result = mappingMapper.update(request, token);
Config entity = configMapper.getById(request.getId(), token);
if (entity == null) {
response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE);
return response;
}
MapperUtil.map(request, entity);
long result = configMapper.update(entity, token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE);
return response;
@ -127,8 +144,8 @@ public class MappingManagerImpl implements MappingManager {
* @return
*/
@Transactional(readOnly = true)
public MappingFindResponse find(MappingFindRequest request, Token token) {
MappingFindResponse response = new MappingFindResponse();
public ConfigFindResponse find(ConfigFindRequest request, Token token) {
ConfigFindResponse response = new ConfigFindResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
@ -139,40 +156,13 @@ public class MappingManagerImpl implements MappingManager {
PageHelper.startPage(request.getPageNumber(), request.getPageSize());
}
if (StringUtil.isNotEmpty(request.getSortKey())) {
PageHelper.orderBy(request.getSortKey() + " " + (request.getSortType() != null ? request.getSortType() : SortType.ASC));
PageHelper.orderBy(request.getSortKey() + " " + request.getSortType());
}
PageInfo<Mapping> pageInfo = new PageInfo<>(mappingMapper.find(request, token));
PageInfo<Config> pageInfo = new PageInfo<>(configMapper.find(request, token));
response.setResult(pageInfo.getList());
response.setTotalCount(pageInfo.getTotal());
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
@Transactional(readOnly = true)
public MappingGetResponse get(MappingGetRequest request, Token token) {
MappingGetResponse response = new MappingGetResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
Mapping po = mappingMapper.get(request, token);
if (po != null) {
response.setMapping(po);
} else {
response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE);
}
return response;
}
}

@ -0,0 +1,57 @@
package xyz.wbsite.module.admin.mgr;
import xyz.wbsite.module.admin.req.LocationsCreateRequest;
import xyz.wbsite.module.admin.req.LocationsDeleteRequest;
import xyz.wbsite.module.admin.req.LocationsFindRequest;
import xyz.wbsite.module.admin.req.LocationsUpdateRequest;
import xyz.wbsite.module.admin.rsp.LocationsCreateResponse;
import xyz.wbsite.module.admin.rsp.LocationsDeleteResponse;
import xyz.wbsite.module.admin.rsp.LocationsFindResponse;
import xyz.wbsite.module.admin.rsp.LocationsUpdateResponse;
import xyz.wbsite.frame.base.Token;
/**
*
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public interface LocationsManager {
/**
*
*
* @param request
* @param token
* @return
*/
LocationsCreateResponse create(LocationsCreateRequest request, Token token);
/**
*
*
* @param request
* @param token
* @return
*/
LocationsDeleteResponse delete(LocationsDeleteRequest request, Token token);
/**
*
*
* @param request
* @param token
* @return
*/
LocationsUpdateResponse update(LocationsUpdateRequest request, Token token);
/**
*
*
* @param request
* @param token
* @return
*/
LocationsFindResponse find(LocationsFindRequest request, Token token);
}

@ -0,0 +1,168 @@
package xyz.wbsite.module.admin.mgr;
import xyz.wbsite.frame.utils.IDgenerator;
import xyz.wbsite.frame.utils.Message;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.module.admin.ent.Locations;
import xyz.wbsite.module.admin.mpr.LocationsMapper;
import xyz.wbsite.module.admin.req.LocationsCreateRequest;
import xyz.wbsite.module.admin.req.LocationsDeleteRequest;
import xyz.wbsite.module.admin.req.LocationsFindRequest;
import xyz.wbsite.module.admin.req.LocationsUpdateRequest;
import xyz.wbsite.module.admin.rsp.LocationsCreateResponse;
import xyz.wbsite.module.admin.rsp.LocationsDeleteResponse;
import xyz.wbsite.module.admin.rsp.LocationsFindResponse;
import xyz.wbsite.module.admin.rsp.LocationsUpdateResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* LOCATIONS -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
@Transactional
@Service
public class LocationsManagerImpl implements LocationsManager {
@Autowired
private LocationsMapper locationsMapper;
/**
*
*
* @param request
* @param token
* @return
*/
public LocationsCreateResponse create(LocationsCreateRequest request, Token token) {
LocationsCreateResponse response = new LocationsCreateResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
{// 配置标题唯一检查
LocationsFindRequest locationsFindRequest = new LocationsFindRequest();
locationsFindRequest.setLocalTitle(request.getLocalTitle());
LocationsFindResponse locationsFindResponse = this.find(locationsFindRequest, token);
if (locationsFindResponse.hasError()) {
response.addErrors(locationsFindResponse.getErrors());
return response;
} else if (locationsFindResponse.getTotalCount() > 0) {
response.addError(ErrorType.UNIQUENESS_ERROR, "[localTitle]配置标题已存在,请检查!");
return response;
}
}
long id = IDgenerator.nextId();
Locations entity = MapperUtil.map(request, Locations.class);
entity.setId(id);
long result = locationsMapper.insert(entity, token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE);
return response;
}
response.setId(id);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
public LocationsDeleteResponse delete(LocationsDeleteRequest request, Token token) {
LocationsDeleteResponse response = new LocationsDeleteResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
long result = locationsMapper.delete(request.getId(), token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE);
return response;
}
response.setResult(result);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
public LocationsUpdateResponse update(LocationsUpdateRequest request, Token token) {
LocationsUpdateResponse response = new LocationsUpdateResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
Locations entity = locationsMapper.getById(request.getId(), token);
if (entity == null) {
response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE);
return response;
}
MapperUtil.map(request, entity);
long result = locationsMapper.update(entity, token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE);
return response;
}
response.setResult(result);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
@Transactional(readOnly = true)
public LocationsFindResponse find(LocationsFindRequest request, Token token) {
LocationsFindResponse response = new LocationsFindResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
if (request.getPageSize() != 0) {
PageHelper.startPage(request.getPageNumber(), request.getPageSize());
}
if (StringUtil.isNotEmpty(request.getSortKey())) {
PageHelper.orderBy(request.getSortKey() + " " + request.getSortType());
}
PageInfo<Locations> pageInfo = new PageInfo<>(locationsMapper.find(request, token));
response.setResult(pageInfo.getList());
response.setTotalCount(pageInfo.getTotal());
return response;
}
}

@ -0,0 +1,194 @@
package xyz.wbsite.module.admin.mgr;
import xyz.wbsite.frame.utils.IDgenerator;
import xyz.wbsite.frame.utils.Message;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.module.admin.ent.Services;
import xyz.wbsite.module.admin.mpr.ServicesMapper;
import xyz.wbsite.module.admin.req.ServicesCreateRequest;
import xyz.wbsite.module.admin.req.ServicesDeleteRequest;
import xyz.wbsite.module.admin.req.ServicesFindRequest;
import xyz.wbsite.module.admin.req.ServicesUpdateRequest;
import xyz.wbsite.module.admin.rsp.ServicesCreateResponse;
import xyz.wbsite.module.admin.rsp.ServicesDeleteResponse;
import xyz.wbsite.module.admin.rsp.ServicesFindResponse;
import xyz.wbsite.module.admin.rsp.ServicesUpdateResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* SERVICES -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
@Transactional
@Service
public class ServicesManagerImpl implements ServicesManager {
@Autowired
private ServicesMapper servicesMapper;
/**
*
*
* @param request
* @param token
* @return
*/
public ServicesCreateResponse create(ServicesCreateRequest request, Token token) {
ServicesCreateResponse response = new ServicesCreateResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
{// 主机标题唯一检查
ServicesFindRequest servicesFindRequest = new ServicesFindRequest();
servicesFindRequest.setTitle(request.getTitle());
ServicesFindResponse servicesFindResponse = this.find(servicesFindRequest, token);
if (servicesFindResponse.hasError()) {
response.addErrors(servicesFindResponse.getErrors());
return response;
} else if (servicesFindResponse.getTotalCount() > 0) {
response.addError(ErrorType.UNIQUENESS_ERROR, "[title]主机标题已存在,请检查!");
return response;
}
}
{// 主机域名唯一检查
ServicesFindRequest servicesFindRequest = new ServicesFindRequest();
servicesFindRequest.setDomain(request.getDomain());
ServicesFindResponse servicesFindResponse = this.find(servicesFindRequest, token);
if (servicesFindResponse.hasError()) {
response.addErrors(servicesFindResponse.getErrors());
return response;
} else if (servicesFindResponse.getTotalCount() > 0) {
response.addError(ErrorType.UNIQUENESS_ERROR, "[domain]主机域名已存在,请检查!");
return response;
}
}
{// 服务端口唯一检查
ServicesFindRequest servicesFindRequest = new ServicesFindRequest();
servicesFindRequest.setPort(request.getPort());
ServicesFindResponse servicesFindResponse = this.find(servicesFindRequest, token);
if (servicesFindResponse.hasError()) {
response.addErrors(servicesFindResponse.getErrors());
return response;
} else if (servicesFindResponse.getTotalCount() > 0) {
response.addError(ErrorType.UNIQUENESS_ERROR, "[port]服务端口已存在,请检查!");
return response;
}
}
long id = IDgenerator.nextId();
Services entity = MapperUtil.map(request, Services.class);
entity.setId(id);
long result = servicesMapper.insert(entity, token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE);
return response;
}
response.setId(id);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
public ServicesDeleteResponse delete(ServicesDeleteRequest request, Token token) {
ServicesDeleteResponse response = new ServicesDeleteResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
long result = servicesMapper.delete(request.getId(), token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE);
return response;
}
response.setResult(result);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
public ServicesUpdateResponse update(ServicesUpdateRequest request, Token token) {
ServicesUpdateResponse response = new ServicesUpdateResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
Services entity = servicesMapper.getById(request.getId(), token);
if (entity == null) {
response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE);
return response;
}
MapperUtil.map(request, entity);
long result = servicesMapper.update(entity, token);
if (1L != result) {
response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE);
return response;
}
response.setResult(result);
return response;
}
/**
*
*
* @param request
* @param token
* @return
*/
@Transactional(readOnly = true)
public ServicesFindResponse find(ServicesFindRequest request, Token token) {
ServicesFindResponse response = new ServicesFindResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
if (request.getPageSize() != 0) {
PageHelper.startPage(request.getPageNumber(), request.getPageSize());
}
if (StringUtil.isNotEmpty(request.getSortKey())) {
PageHelper.orderBy(request.getSortKey() + " " + request.getSortType());
}
PageInfo<Services> pageInfo = new PageInfo<>(servicesMapper.find(request, token));
response.setResult(pageInfo.getList());
response.setTotalCount(pageInfo.getTotal());
return response;
}
}

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="xyz.wbsite.module.admin.mpr.ConfigDataMapper">
<sql id="table">"NA_CONFIG_DATA"</sql>
<sql id="entityColumnList">
"ID","TARGET_ID","CONF_NAME","CONF_TYPE","CONF_VALUE","CONF_NOTE","ROW_VERSION","IS_DELETED","CREATE_BY","CREATE_TIME","LAST_UPDATE_BY","LAST_UPDATE_TIME"
</sql>
<resultMap id="configData" type="xyz.wbsite.module.admin.ent.ConfigData">
<result column="ID" jdbcType="BIGINT" property="id"/>
<result column="TARGET_ID" jdbcType="BIGINT" property="targetId"/>
<result column="CONF_NAME" jdbcType="VARCHAR" property="confName"/>
<result column="CONF_TYPE" jdbcType="VARCHAR" property="confType"/>
<result column="CONF_VALUE" jdbcType="VARCHAR" property="confValue"/>
<result column="CONF_NOTE" jdbcType="VARCHAR" property="confNote"/>
<result column="ROW_VERSION" jdbcType="BIGINT" property="rowVersion"/>
<result column="IS_DELETED" jdbcType="BIT" property="isDeleted"/>
<result column="CREATE_BY" jdbcType="BIGINT" property="createBy"/>
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
<result column="LAST_UPDATE_BY" jdbcType="BIGINT" property="lastUpdateBy"/>
<result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
</resultMap>
<insert id="insert">
INSERT INTO
<include refid="table"/>
(
<include refid="entityColumnList"/>
)
VALUES
(
#{request.id},
#{request.targetId,jdbcType=BIGINT},
#{request.confName,jdbcType=VARCHAR},
#{request.confType,jdbcType=VARCHAR},
#{request.confValue,jdbcType=VARCHAR},
#{request.confNote,jdbcType=VARCHAR},
0,
0,
#{token.userId,jdbcType=NUMERIC},
datetime('now','localtime'),
NULL,
NULL
)
</insert>
<insert id="insertBatch">
INSERT INTO
<include refid="table"/>
(
<include refid="entityColumnList"/>
)
VALUES
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item.id},
#{item.targetId,jdbcType=BIGINT},
#{item.confName,jdbcType=VARCHAR},
#{item.confType,jdbcType=VARCHAR},
#{item.confValue,jdbcType=VARCHAR},
#{item.confNote,jdbcType=VARCHAR},
0,
0,
#{token.userId,jdbcType=NUMERIC},
datetime('now','localtime'),
NULL,
NULL
</foreach >
</insert>
<update id="delete">
UPDATE
<include refid="table"/>
SET "IS_DELETED" = 1
WHERE "IS_DELETED" = 0
AND "ID" = #{id}
</update>
<update id="deleteBatch">
UPDATE
<include refid="table"/>
SET "IS_DELETED" = 1
WHERE "IS_DELETED" = 0
AND "ID" IN
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="update">
UPDATE
<include refid="table"/>
SET
TARGET_ID = #{request.targetId,jdbcType=BIGINT},
CONF_NAME = #{request.confName,jdbcType=VARCHAR},
CONF_TYPE = #{request.confType,jdbcType=VARCHAR},
CONF_VALUE = #{request.confValue,jdbcType=VARCHAR},
CONF_NOTE = #{request.confNote,jdbcType=VARCHAR},
"ROW_VERSION" = "ROW_VERSION" + 1,
"LAST_UPDATE_BY" = #{token.userId},
"LAST_UPDATE_TIME" = datetime('now','localtime')
WHERE "IS_DELETED" = 0
AND "ID" = #{request.id}
AND "ROW_VERSION" = #{request.rowVersion}
</update>
<select id="select" resultMap="configData">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
<if test="request.targetId != null">
AND "TARGET_ID" = #{request.targetId}
</if>
<if test="request.confName != null and request.confName != ''">
AND "CONF_NAME" = #{request.confName}
</if>
<if test="request.confType != null and request.confType != ''">
AND "CONF_TYPE" = #{request.confType}
</if>
</select>
<select id="find" resultMap="configData">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
<if test="request.targetId != null">
AND "TARGET_ID" = #{request.targetId}
</if>
<if test="request.confName != null and request.confName != ''">
AND "CONF_NAME" = #{request.confName}
</if>
<if test="request.confNameLike != null and request.confNameLike != ''">
AND "CONF_NAME" LIKE '%'||#{request.confNameLike}||'%'
</if>
<if test="request.confType != null and request.confType != ''">
AND "CONF_TYPE" = #{request.confType}
</if>
<if test="request.confValueLike != null and request.confValueLike != ''">
AND "CONF_VALUE" LIKE '%'||#{request.confValueLike}||'%'
</if>
<if test="request.confNoteLike != null and request.confNoteLike != ''">
AND "CONF_NOTE" LIKE '%'||#{request.confNoteLike}||'%'
</if>
<if test="request.startDate != null">
AND strftime('%s',"CREATE_TIME", 'utc')*1000 &gt;= #{request.startDate}
</if>
<if test="request.endDate != null">
AND strftime('%s',"CREATE_TIME", 'utc')*1000 &lt;= #{request.endDate}
</if>
</select>
<select id="search" resultMap="configData">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
</select>
<select id="getById" resultMap="configData">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
AND "ID" = #{id}
</select>
<select id="getByIds" resultMap="configData">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
AND "ID" IN
<foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="xyz.wbsite.module.admin.mpr.ConfigMapper">
<sql id="table">"NA_CONFIG"</sql>
<sql id="entityColumnList">
"ID","CONF_NAME","CONF_TYPE","CONF_VALUE","CONF_NOTE","ROW_VERSION","IS_DELETED","CREATE_BY","CREATE_TIME","LAST_UPDATE_BY","LAST_UPDATE_TIME"
</sql>
<resultMap id="config" type="xyz.wbsite.module.admin.ent.Config">
<result column="ID" jdbcType="BIGINT" property="id"/>
<result column="CONF_NAME" jdbcType="VARCHAR" property="confName"/>
<result column="CONF_TYPE" jdbcType="VARCHAR" property="confType"/>
<result column="CONF_VALUE" jdbcType="VARCHAR" property="confValue"/>
<result column="CONF_NOTE" jdbcType="VARCHAR" property="confNote"/>
<result column="ROW_VERSION" jdbcType="BIGINT" property="rowVersion"/>
<result column="IS_DELETED" jdbcType="BIT" property="isDeleted"/>
<result column="CREATE_BY" jdbcType="BIGINT" property="createBy"/>
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
<result column="LAST_UPDATE_BY" jdbcType="BIGINT" property="lastUpdateBy"/>
<result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
</resultMap>
<insert id="insert">
INSERT INTO
<include refid="table"/>
(
<include refid="entityColumnList"/>
)
VALUES
(
#{request.id},
#{request.confName,jdbcType=VARCHAR},
#{request.confType,jdbcType=VARCHAR},
#{request.confValue,jdbcType=VARCHAR},
#{request.confNote,jdbcType=VARCHAR},
0,
0,
#{token.userId,jdbcType=NUMERIC},
datetime('now','localtime'),
NULL,
NULL
)
</insert>
<insert id="insertBatch">
INSERT INTO
<include refid="table"/>
(
<include refid="entityColumnList"/>
)
VALUES
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item.id},
#{item.confName,jdbcType=VARCHAR},
#{item.confType,jdbcType=VARCHAR},
#{item.confValue,jdbcType=VARCHAR},
#{item.confNote,jdbcType=VARCHAR},
0,
0,
#{token.userId,jdbcType=NUMERIC},
datetime('now','localtime'),
NULL,
NULL
</foreach >
</insert>
<update id="delete">
UPDATE
<include refid="table"/>
SET "IS_DELETED" = 1
WHERE "IS_DELETED" = 0
AND "ID" = #{id}
</update>
<update id="deleteBatch">
UPDATE
<include refid="table"/>
SET "IS_DELETED" = 1
WHERE "IS_DELETED" = 0
AND "ID" IN
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="update">
UPDATE
<include refid="table"/>
SET
CONF_NAME = #{request.confName,jdbcType=VARCHAR},
CONF_TYPE = #{request.confType,jdbcType=VARCHAR},
CONF_VALUE = #{request.confValue,jdbcType=VARCHAR},
CONF_NOTE = #{request.confNote,jdbcType=VARCHAR},
"ROW_VERSION" = "ROW_VERSION" + 1,
"LAST_UPDATE_BY" = #{token.userId},
"LAST_UPDATE_TIME" = datetime('now','localtime')
WHERE "IS_DELETED" = 0
AND "ID" = #{request.id}
AND "ROW_VERSION" = #{request.rowVersion}
</update>
<select id="select" resultMap="config">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
<if test="request.confName != null and request.confName != ''">
AND "CONF_NAME" = #{request.confName}
</if>
<if test="request.confType != null and request.confType != ''">
AND "CONF_TYPE" = #{request.confType}
</if>
</select>
<select id="find" resultMap="config">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
<if test="request.confName != null and request.confName != ''">
AND "CONF_NAME" = #{request.confName}
</if>
<if test="request.confNameLike != null and request.confNameLike != ''">
AND "CONF_NAME" LIKE '%'||#{request.confNameLike}||'%'
</if>
<if test="request.confType != null and request.confType != ''">
AND "CONF_TYPE" = #{request.confType}
</if>
<if test="request.confValueLike != null and request.confValueLike != ''">
AND "CONF_VALUE" LIKE '%'||#{request.confValueLike}||'%'
</if>
<if test="request.confNoteLike != null and request.confNoteLike != ''">
AND "CONF_NOTE" LIKE '%'||#{request.confNoteLike}||'%'
</if>
<if test="request.startDate != null">
AND strftime('%s',"CREATE_TIME", 'utc')*1000 &gt;= #{request.startDate}
</if>
<if test="request.endDate != null">
AND strftime('%s',"CREATE_TIME", 'utc')*1000 &lt;= #{request.endDate}
</if>
</select>
<select id="search" resultMap="config">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
</select>
<select id="getById" resultMap="config">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
AND "ID" = #{id}
</select>
<select id="getByIds" resultMap="config">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
AND "ID" IN
<foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>

@ -0,0 +1,100 @@
package xyz.wbsite.module.admin.mpr;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.module.admin.ent.Locations;
import xyz.wbsite.module.admin.req.LocationsFindRequest;
import java.util.List;
/**
* LOCATIONS -
*
* @author wangbing
* @since 2021-02-07
*/
@Mapper
public interface LocationsMapper {
/**
*
*
* @param request
* @param token
* @return
*/
long insert(@Param("request") Locations request, @Param("token") Token token);
/**
*
*
* @param list
* @param token
* @return
*/
long insertBatch(@Param("list") List<Locations> list, @Param("token") Token token);
/**
*
*
* @param id
* @param token
* @return
*/
long delete(@Param("id") Long id, @Param("token") Token token);
/**
*
*
* @param list
* @param token
* @return
*/
long deleteBatch(@Param("list") List<Long> list, @Param("token") Token token);
/**
*
*
* @param request
* @param token
* @return
*/
long update(@Param("request") Locations request, @Param("token") Token token);
/**
*
*
* @param request
* @param token
* @return
*/
List<Locations> select(@Param("request") Locations request, @Param("token") Token token);
/**
*
*
* @param request
* @param token
* @return
*/
List<Locations> find(@Param("request") LocationsFindRequest request, @Param("token") Token token);
/**
*
*
* @param id
* @param token
* @return
*/
Locations getById(@Param("id") Long id, @Param("token") Token token);
/**
*
*
* @param ids
* @param token
* @return
*/
List<Locations> getByIds(@Param("ids") Long[] ids, @Param("token") Token token);
}

@ -0,0 +1,207 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="xyz.wbsite.module.admin.mpr.ServicesMapper">
<sql id="table">"NA_SERVICES"</sql>
<sql id="entityColumnList">
"ID","TITLE","DOMAIN","TYPE","PORT","VALID","FILTER","FILTER_CONF","ROW_VERSION","IS_DELETED","CREATE_BY","CREATE_TIME","LAST_UPDATE_BY","LAST_UPDATE_TIME"
</sql>
<resultMap id="services" type="xyz.wbsite.module.admin.ent.Services">
<result column="ID" jdbcType="BIGINT" property="id"/>
<result column="TITLE" jdbcType="VARCHAR" property="title"/>
<result column="DOMAIN" jdbcType="VARCHAR" property="domain"/>
<result column="TYPE" jdbcType="VARCHAR" property="type"/>
<result column="PORT" jdbcType="INTEGER" property="port"/>
<result column="VALID" jdbcType="BIT" property="valid"/>
<result column="FILTER" jdbcType="BIT" property="filter"/>
<result column="FILTER_CONF" jdbcType="VARCHAR" property="filterConf"/>
<result column="ROW_VERSION" jdbcType="BIGINT" property="rowVersion"/>
<result column="IS_DELETED" jdbcType="BIT" property="isDeleted"/>
<result column="CREATE_BY" jdbcType="BIGINT" property="createBy"/>
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
<result column="LAST_UPDATE_BY" jdbcType="BIGINT" property="lastUpdateBy"/>
<result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
</resultMap>
<insert id="insert">
INSERT INTO
<include refid="table"/>
(
<include refid="entityColumnList"/>
)
VALUES
(
#{request.id},
#{request.title,jdbcType=VARCHAR},
#{request.domain,jdbcType=VARCHAR},
#{request.type,jdbcType=VARCHAR},
#{request.port,jdbcType=INTEGER},
#{request.valid,jdbcType=BIT},
#{request.filter,jdbcType=BIT},
#{request.filterConf,jdbcType=VARCHAR},
0,
0,
#{token.userId,jdbcType=NUMERIC},
datetime('now','localtime'),
NULL,
NULL
)
</insert>
<insert id="insertBatch">
INSERT INTO
<include refid="table"/>
(
<include refid="entityColumnList"/>
)
VALUES
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item.id},
#{item.title,jdbcType=VARCHAR},
#{item.domain,jdbcType=VARCHAR},
#{item.type,jdbcType=VARCHAR},
#{item.port,jdbcType=INTEGER},
#{item.valid,jdbcType=BIT},
#{item.filter,jdbcType=BIT},
#{item.filterConf,jdbcType=VARCHAR},
0,
0,
#{token.userId,jdbcType=NUMERIC},
datetime('now','localtime'),
NULL,
NULL
</foreach >
</insert>
<update id="delete">
UPDATE
<include refid="table"/>
SET "IS_DELETED" = 1
WHERE "IS_DELETED" = 0
AND "ID" = #{id}
</update>
<update id="deleteBatch">
UPDATE
<include refid="table"/>
SET "IS_DELETED" = 1
WHERE "IS_DELETED" = 0
AND "ID" IN
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="update">
UPDATE
<include refid="table"/>
SET
TITLE = #{request.title,jdbcType=VARCHAR},
DOMAIN = #{request.domain,jdbcType=VARCHAR},
TYPE = #{request.type,jdbcType=VARCHAR},
PORT = #{request.port,jdbcType=INTEGER},
VALID = #{request.valid,jdbcType=BIT},
FILTER = #{request.filter,jdbcType=BIT},
FILTER_CONF = #{request.filterConf,jdbcType=VARCHAR},
"ROW_VERSION" = "ROW_VERSION" + 1,
"LAST_UPDATE_BY" = #{token.userId},
"LAST_UPDATE_TIME" = datetime('now','localtime')
WHERE "IS_DELETED" = 0
AND "ID" = #{request.id}
AND "ROW_VERSION" = #{request.rowVersion}
</update>
<select id="select" resultMap="services">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
<if test="request.title != null and request.title != ''">
AND "TITLE" = #{request.title}
</if>
<if test="request.domain != null and request.domain != ''">
AND "DOMAIN" = #{request.domain}
</if>
<if test="request.type != null and request.type != ''">
AND "TYPE" = #{request.type}
</if>
<if test="request.port != null">
AND "PORT" = #{request.port}
</if>
<if test="request.valid != null">
AND "VALID" = #{request.valid}
</if>
<if test="request.filter != null">
AND "FILTER" = #{request.filter}
</if>
</select>
<select id="find" resultMap="services">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
<if test="request.title != null and request.title != ''">
AND "TITLE" = #{request.title}
</if>
<if test="request.titleLike != null and request.titleLike != ''">
AND "TITLE" LIKE '%'||#{request.titleLike}||'%'
</if>
<if test="request.domain != null and request.domain != ''">
AND "DOMAIN" = #{request.domain}
</if>
<if test="request.type != null and request.type != ''">
AND "TYPE" = #{request.type}
</if>
<if test="request.port != null">
AND "PORT" = #{request.port}
</if>
<if test="request.valid != null">
AND "VALID" = #{request.valid}
</if>
<if test="request.filter != null">
AND "FILTER" = #{request.filter}
</if>
<if test="request.startDate != null">
AND strftime('%s',"CREATE_TIME", 'utc')*1000 &gt;= #{request.startDate}
</if>
<if test="request.endDate != null">
AND strftime('%s',"CREATE_TIME", 'utc')*1000 &lt;= #{request.endDate}
</if>
</select>
<select id="search" resultMap="services">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
</select>
<select id="getById" resultMap="services">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
AND "ID" = #{id}
</select>
<select id="getByIds" resultMap="services">
SELECT
<include refid="entityColumnList"/>
FROM
<include refid="table"/>
WHERE "IS_DELETED" = 0
AND "ID" IN
<foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>

@ -0,0 +1,93 @@
package xyz.wbsite.module.admin.req;
import xyz.wbsite.frame.base.BaseRequest;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
import org.hibernate.validator.constraints.Length;
import xyz.wbsite.frame.validation.Select;
/**
* ConfigDataCreateRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class ConfigDataCreateRequest extends BaseRequest {
/**
* .
*/
@NotNull(message = "[targetId]目标主键不能为NULL")
private Long targetId;
/**
* .
*/
@NotBlank(message = "[confName]配置名称不能为空")
@Length(min = 0, max = 50, message = "[confName]配置名称长度不合法(0-50)")
private String confName;
/**
* .
* HTTP:
* SERVER:
* LOCATION:
*/
@NotNull(message = "[confType]配置类型不能为NULL")
@Select({"HTTP", "SERVER", "LOCATION"})
private String confType;
/**
* .
*/
@NotBlank(message = "[confValue]配置属值不能为空")
@Length(min = 0, max = 255, message = "[confValue]配置属值长度不合法(0-255)")
private String confValue;
/**
* .
*/
@Length(min = 0, max = 255, message = "[confNote]配置备注长度不合法(0-255)")
private String confNote;
public Long getTargetId() {
return this.targetId;
}
public void setTargetId(Long targetId) {
this.targetId = targetId;
}
public String getConfName() {
return this.confName;
}
public void setConfName(String confName) {
this.confName = confName;
}
public String getConfType() {
return this.confType;
}
public void setConfType(String confType) {
this.confType = confType;
}
public String getConfValue() {
return this.confValue;
}
public void setConfValue(String confValue) {
this.confValue = confValue;
}
public String getConfNote() {
return this.confNote;
}
public void setConfNote(String confNote) {
this.confNote = confNote;
}
}

@ -0,0 +1,123 @@
package xyz.wbsite.module.admin.req;
import xyz.wbsite.frame.base.BaseFindRequest;
import java.util.Date;
import xyz.wbsite.frame.validation.Select;
/**
* ConfigDataFindRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class ConfigDataFindRequest extends BaseFindRequest {
/**
* .
*/
private Long targetId;
/**
* .
*/
private String confName;
/**
* .
*/
private String confNameLike;
/**
* .
* HTTP:
* SERVER:
* LOCATION:
*/
@Select({"HTTP", "SERVER", "LOCATION"})
private String confType;
/**
* .
*/
private String confValueLike;
/**
* .
*/
private String confNoteLike;
/**
* .
*/
private Date startDate;
/**
* .
*/
private Date endDate;
public Long getTargetId() {
return this.targetId;
}
public void setTargetId(Long targetId) {
this.targetId = targetId;
}
public String getConfName() {
return this.confName;
}
public void setConfName(String confName) {
this.confName = confName;
}
public String getConfNameLike() {
return this.confNameLike;
}
public void setConfNameLike(String confNameLike) {
this.confNameLike = confNameLike;
}
public String getConfType() {
return this.confType;
}
public void setConfType(String confType) {
this.confType = confType;
}
public String getConfValueLike() {
return this.confValueLike;
}
public void setConfValueLike(String confValueLike) {
this.confValueLike = confValueLike;
}
public String getConfNoteLike() {
return this.confNoteLike;
}
public void setConfNoteLike(String confNoteLike) {
this.confNoteLike = confNoteLike;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
}

@ -0,0 +1,110 @@
package xyz.wbsite.module.admin.req;
import xyz.wbsite.frame.base.BaseFindRequest;
import java.util.Date;
import xyz.wbsite.frame.validation.Select;
/**
* ConfigFindRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class ConfigFindRequest extends BaseFindRequest {
/**
* .
*/
private String confName;
/**
* .
*/
private String confNameLike;
/**
* .
* HTTP:
* SERVER:
* LOCATION:
*/
@Select({"HTTP", "SERVER", "LOCATION"})
private String confType;
/**
* .
*/
private String confValueLike;
/**
* .
*/
private String confNoteLike;
/**
* .
*/
private Date startDate;
/**
* .
*/
private Date endDate;
public String getConfName() {
return this.confName;
}
public void setConfName(String confName) {
this.confName = confName;
}
public String getConfNameLike() {
return this.confNameLike;
}
public void setConfNameLike(String confNameLike) {
this.confNameLike = confNameLike;
}
public String getConfType() {
return this.confType;
}
public void setConfType(String confType) {
this.confType = confType;
}
public String getConfValueLike() {
return this.confValueLike;
}
public void setConfValueLike(String confValueLike) {
this.confValueLike = confValueLike;
}
public String getConfNoteLike() {
return this.confNoteLike;
}
public void setConfNoteLike(String confNoteLike) {
this.confNoteLike = confNoteLike;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
}

@ -0,0 +1,93 @@
package xyz.wbsite.module.admin.req;
import xyz.wbsite.frame.base.BaseUpdateRequest;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import xyz.wbsite.frame.validation.Select;
/**
* ConfigUpdateRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class ConfigUpdateRequest extends BaseUpdateRequest {
/**
* .
*/
@NotNull(message = "[id]主键不能为NULL")
private Long id;
/**
* .
*/
@NotBlank(message = "[confName]配置名称不能为空")
@Length(min = 0, max = 50, message = "[confName]配置名称长度不合法(0-50)")
private String confName;
/**
* .
* HTTP:
* SERVER:
* LOCATION:
*/
@NotNull(message = "[confType]配置类型不能为NULL")
@Select({"HTTP", "SERVER", "LOCATION"})
private String confType;
/**
* .
*/
@Length(min = 0, max = 255, message = "[confValue]配置属值长度不合法(0-255)")
private String confValue;
/**
* .
*/
@Length(min = 0, max = 255, message = "[confNote]配置备注长度不合法(0-255)")
private String confNote;
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getConfName() {
return this.confName;
}
public void setConfName(String confName) {
this.confName = confName;
}
public String getConfType() {
return this.confType;
}
public void setConfType(String confType) {
this.confType = confType;
}
public String getConfValue() {
return this.confValue;
}
public void setConfValue(String confValue) {
this.confValue = confValue;
}
public String getConfNote() {
return this.confNote;
}
public void setConfNote(String confNote) {
this.confNote = confNote;
}
}

@ -0,0 +1,30 @@
package xyz.wbsite.module.admin.req;
import xyz.wbsite.frame.base.BaseRequest;
import javax.validation.constraints.NotNull;
/**
* LocationsDeleteRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class LocationsDeleteRequest extends BaseRequest {
/**
* .
*/
@NotNull(message = "[id]主键不能为空")
private Long id;
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
}

@ -0,0 +1,144 @@
package xyz.wbsite.module.admin.req;
import xyz.wbsite.frame.base.BaseFindRequest;
import java.util.Date;
/**
* LocationsFindRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class LocationsFindRequest extends BaseFindRequest {
/**
* .
*/
private Long serviceId;
/**
* .
*/
private String localTitle;
/**
* .
*/
private String localTitleLike;
/**
* .
*/
private String localNoteLike;
/**
* .
*/
private String localPath;
/**
* .
*/
private String localPathLike;
/**
* .
*/
private Boolean localValid;
/**
* .
*/
private Boolean filter;
/**
* .
*/
private Date startDate;
/**
* .
*/
private Date endDate;
public Long getServiceId() {
return this.serviceId;
}
public void setServiceId(Long serviceId) {
this.serviceId = serviceId;
}
public String getLocalTitle() {
return this.localTitle;
}
public void setLocalTitle(String localTitle) {
this.localTitle = localTitle;
}
public String getLocalTitleLike() {
return this.localTitleLike;
}
public void setLocalTitleLike(String localTitleLike) {
this.localTitleLike = localTitleLike;
}
public String getLocalNoteLike() {
return this.localNoteLike;
}
public void setLocalNoteLike(String localNoteLike) {
this.localNoteLike = localNoteLike;
}
public String getLocalPath() {
return this.localPath;
}
public void setLocalPath(String localPath) {
this.localPath = localPath;
}
public String getLocalPathLike() {
return this.localPathLike;
}
public void setLocalPathLike(String localPathLike) {
this.localPathLike = localPathLike;
}
public Boolean getLocalValid() {
return this.localValid;
}
public void setLocalValid(Boolean localValid) {
this.localValid = localValid;
}
public Boolean getFilter() {
return this.filter;
}
public void setFilter(Boolean filter) {
this.filter = filter;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
}

@ -0,0 +1,122 @@
package xyz.wbsite.module.admin.req;
import xyz.wbsite.frame.base.BaseRequest;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
import org.hibernate.validator.constraints.Length;
import xyz.wbsite.frame.validation.Select;
/**
* ServicesCreateRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class ServicesCreateRequest extends BaseRequest {
/**
* .
*/
@NotBlank(message = "[title]主机标题不能为空")
@Length(min = 0, max = 50, message = "[title]主机标题长度不合法(0-50)")
private String title;
/**
* .
*/
@NotBlank(message = "[domain]主机域名不能为空")
@Length(min = 0, max = 50, message = "[domain]主机域名长度不合法(0-50)")
private String domain;
/**
* .
* :
* :
* :
* :
* :
*/
@NotNull(message = "[type]服务类型不能为NULL")
@Select({"反向代理", "负载均衡", "正向代理", "文件代理", "端口转发"})
private String type;
/**
* .
*/
@NotNull(message = "[port]服务端口不能为NULL")
private Integer port;
/**
* .
*/
private Boolean valid;
/**
* .
*/
@NotNull(message = "[filter]启用过滤不能为NULL")
private Boolean filter;
/**
* .
*/
@Length(min = 0, max = 500, message = "[filterConf]过滤配置长度不合法(0-500)")
private String filterConf;
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDomain() {
return this.domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public Integer getPort() {
return this.port;
}
public void setPort(Integer port) {
this.port = port;
}
public Boolean getValid() {
return this.valid;
}
public void setValid(Boolean valid) {
this.valid = valid;
}
public Boolean getFilter() {
return this.filter;
}
public void setFilter(Boolean filter) {
this.filter = filter;
}
public String getFilterConf() {
return this.filterConf;
}
public void setFilterConf(String filterConf) {
this.filterConf = filterConf;
}
}

@ -0,0 +1,137 @@
package xyz.wbsite.module.admin.req;
import xyz.wbsite.frame.base.BaseUpdateRequest;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import xyz.wbsite.frame.validation.Select;
/**
* ServicesUpdateRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class ServicesUpdateRequest extends BaseUpdateRequest {
/**
* .
*/
@NotNull(message = "[id]主键不能为NULL")
private Long id;
/**
* .
*/
@NotBlank(message = "[title]主机标题不能为空")
@Length(min = 0, max = 50, message = "[title]主机标题长度不合法(0-50)")
private String title;
/**
* .
*/
@NotBlank(message = "[domain]主机域名不能为空")
@Length(min = 0, max = 50, message = "[domain]主机域名长度不合法(0-50)")
private String domain;
/**
* .
* :
* :
* :
* :
* :
*/
@NotNull(message = "[type]服务类型不能为NULL")
@Select({"反向代理", "负载均衡", "正向代理", "文件代理", "端口转发"})
private String type;
/**
* .
*/
@NotNull(message = "[port]服务端口不能为NULL")
private Integer port;
/**
* .
*/
private Boolean valid;
/**
* .
*/
@NotNull(message = "[filter]启用过滤不能为NULL")
private Boolean filter;
/**
* .
*/
@Length(min = 0, max = 500, message = "[filterConf]过滤配置长度不合法(0-500)")
private String filterConf;
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDomain() {
return this.domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public Integer getPort() {
return this.port;
}
public void setPort(Integer port) {
this.port = port;
}
public Boolean getValid() {
return this.valid;
}
public void setValid(Boolean valid) {
this.valid = valid;
}
public Boolean getFilter() {
return this.filter;
}
public void setFilter(Boolean filter) {
this.filter = filter;
}
public String getFilterConf() {
return this.filterConf;
}
public void setFilterConf(String filterConf) {
this.filterConf = filterConf;
}
}

@ -1,18 +1,18 @@
package xyz.wbsite.module.conf.rsp;
package xyz.wbsite.module.admin.rsp;
import xyz.wbsite.frame.base.BaseResponse;
/**
* MappingUpdateResponse -
* ConfigDataDeleteResponse -
*
* @author wangbing
* @version 0.0.1
* @since 2020-03-18
* @since 2021-02-07
*/
public class MappingUpdateResponse extends BaseResponse {
public class ConfigDataDeleteResponse extends BaseResponse {
/**
*
*
*/
private Long result;

@ -0,0 +1,26 @@
package xyz.wbsite.module.admin.rsp;
import xyz.wbsite.frame.base.BaseResponse;
/**
* LocationsCreateResponse -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class LocationsCreateResponse extends BaseResponse {
/**
*
*/
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}

@ -0,0 +1,26 @@
package xyz.wbsite.module.admin.rsp;
import xyz.wbsite.frame.base.BaseResponse;
/**
* ServicesCreateResponse -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class ServicesCreateResponse extends BaseResponse {
/**
*
*/
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}

@ -1,15 +1,15 @@
package xyz.wbsite.module.conf.rsp;
package xyz.wbsite.module.admin.rsp;
import xyz.wbsite.frame.base.BaseResponse;
/**
* MappingDeleteResponse -
* ServicesDeleteResponse -
*
* @author wangbing
* @version 0.0.1
* @since 2020-03-18
* @since 2021-02-07
*/
public class MappingDeleteResponse extends BaseResponse {
public class ServicesDeleteResponse extends BaseResponse {
/**
*

@ -0,0 +1,14 @@
package xyz.wbsite.module.admin.rsp;
import xyz.wbsite.frame.base.BaseFindResponse;
import xyz.wbsite.module.admin.ent.Services;
/**
* ServicesFindResponse -
*
* @author wangbing
* @version 0.0.1
* @since 2021-02-07
*/
public class ServicesFindResponse extends BaseFindResponse<Services> {
}

@ -1,86 +0,0 @@
package xyz.wbsite.module.conf.ent;
import xyz.wbsite.frame.base.BaseEntity;
/**
* MAPPING -
*
* @author wangbing
* @version 0.0.1
* @since 2020-03-18
*/
public class Mapping extends BaseEntity {
/**
* NAME -
*/
private String name;
/**
* PORT -
*/
private String port;
/**
* PATH -
*/
private String path;
/**
* TYPE -
*/
private String type;
/**
* LOCATION -
*/
private String location;
/**
* NOTE -
*/
private String note;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getPort() {
return this.port;
}
public void setPort(String port) {
this.port = port;
}
public String getPath() {
return this.path;
}
public void setPath(String path) {
this.path = path;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public String getLocation() {
return this.location;
}
public void setLocation(String location) {
this.location = location;
}
public String getNote() {
return this.note;
}
public void setNote(String note) {
this.note = note;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.