Commit 18144407 authored by trumansdo's avatar trumansdo
Browse files

应用codestyle


千万千万要用vscode打开前端项目,或者关闭eslint,移除它
Signed-off-by: default avatartrumansdo <1012243881@qq.com>
parent 9b3d96a6
......@@ -11,21 +11,18 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* 没有找到匹配的Controller
* @author xiandafu
*
* @author xiandafu
*/
@Controller
public class ControllerNotFound {
@Autowired
WebSimulate webSimulate;
Log log = LogFactory.getLog(ControllerNotFound.class);
@RequestMapping("/**/*.do")
public void error(HttpServletRequest request, HttpServletResponse response) {
response.setContentType("text/html;charset=UTF-8");
log.info("没有配置 url "+request.getRequestURI()+",确认所访问Controller是否存在,是否被Spring Boot管理");
throw new RuntimeException("未找到Controller类处理此请求 "+request.getRequestURI());
}
@Autowired WebSimulate webSimulate;
Log log = LogFactory.getLog(ControllerNotFound.class);
@RequestMapping("/**/*.do")
public void error(HttpServletRequest request, HttpServletResponse response) {
response.setContentType("text/html;charset=UTF-8");
log.info("没有配置 url " + request.getRequestURI() + ",确认所访问Controller是否存在,是否被Spring Boot管理");
throw new RuntimeException("未找到Controller类处理此请求 " + request.getRequestURI());
}
}
......@@ -41,453 +41,425 @@ import com.ibeetl.admin.core.util.PlatformException;
@Controller
public class CoreCodeGenController {
private final Log log = LogFactory.getLog(this.getClass());
private static final String MODEL = "/core/codeGen";
@Autowired
CoreCodeGenService codeGenService;
@GetMapping(MODEL + "/index.do")
public ModelAndView index() {
ModelAndView view = new ModelAndView("/core/codeGen/index.html");
return view;
}
@PostMapping(MODEL + "/refresh.json")
@ResponseBody
public JsonResult<Boolean> refresh() {
codeGenService.refresh();
return JsonResult.success();
}
@GetMapping(MODEL + "/tableDetail.do")
public ModelAndView tableDetail(String table) {
ModelAndView view = new ModelAndView("/core/codeGen/edit.html");
Entity entity = codeGenService.getEntityInfo(table);
view.addObject("entity", entity);
return view;
}
@GetMapping(MODEL + "/project.do")
public ModelAndView project() {
ModelAndView view = new ModelAndView("/core/codeGen/project.html");
File file = new File(MavenProjectTarget.detectRootPath());
String root = file.getParent();
//设置生成项目为当前运行项目的上一级项目
view.addObject("path",root+File.separator+"sample");
view.addObject("basePackage","com.corp.xxx");
return view;
private final Log log = LogFactory.getLog(this.getClass());
private static final String MODEL = "/core/codeGen";
@Autowired CoreCodeGenService codeGenService;
@GetMapping(MODEL + "/index.do")
public ModelAndView index() {
ModelAndView view = new ModelAndView("/core/codeGen/index.html");
return view;
}
@PostMapping(MODEL + "/refresh.json")
@ResponseBody
public JsonResult<Boolean> refresh() {
codeGenService.refresh();
return JsonResult.success();
}
@GetMapping(MODEL + "/tableDetail.do")
public ModelAndView tableDetail(String table) {
ModelAndView view = new ModelAndView("/core/codeGen/edit.html");
Entity entity = codeGenService.getEntityInfo(table);
view.addObject("entity", entity);
return view;
}
@GetMapping(MODEL + "/project.do")
public ModelAndView project() {
ModelAndView view = new ModelAndView("/core/codeGen/project.html");
File file = new File(MavenProjectTarget.detectRootPath());
String root = file.getParent();
// 设置生成项目为当前运行项目的上一级项目
view.addObject("path", root + File.separator + "sample");
view.addObject("basePackage", "com.corp.xxx");
return view;
}
@PostMapping(MODEL + "/projectGen.json")
@ResponseBody
public JsonResult project(String path, String basePackage, String includeConsole)
throws IOException {
// includeConsole 当前版本忽略,总是添加一个系统管理功能,可以在pom中移除console
// 生成maven项目结构
File maven = new File(path);
maven.mkdirs();
File src = new File(maven, "src");
src.mkdirs();
File main = new File(src, "main");
main.mkdir();
File test = new File(src, "test");
test.mkdir();
File javsSource = new File(main, "java");
javsSource.mkdir();
File resource = new File(main, "resources");
resource.mkdir();
File sql = new File(resource, "sql");
sql.mkdir();
File staticFile = new File(resource, "static");
staticFile.mkdir();
File templatesFile = new File(resource, "templates");
templatesFile.mkdir();
String codePath = basePackage.replace(".", "/");
File codeFile = new File(javsSource, codePath);
codeFile.mkdirs();
Configuration conf = Configuration.defaultConfiguration();
String tempalteRoot = "codeTemplate/maven/";
ClasspathResourceLoader loader =
new ClasspathResourceLoader(Thread.currentThread().getContextClassLoader(), tempalteRoot);
GroupTemplate gt = new GroupTemplate(loader, conf);
FileWriter fw = null;
// 先生成入口程序
Template mainJavaTempalte = gt.getTemplate("/main.java");
mainJavaTempalte.binding("basePackage", basePackage);
fw = new FileWriter(new File(codeFile, "MainApplication.java"));
mainJavaTempalte.renderTo(fw);
// 生成pom文件
Template pomTemplate = gt.getTemplate("/pomTemplate.xml");
int index = basePackage.lastIndexOf(".");
String projectGrop = basePackage.substring(0, index);
String projectName = basePackage.substring(index + 1);
pomTemplate.binding("group", projectGrop);
pomTemplate.binding("project", projectName);
fw = new FileWriter(new File(maven, "pom.xml"));
pomTemplate.renderTo(fw);
// 复制当前项目的配置文件
File config = copy(resource, "application.properties");
copy(resource, "beetl.properties");
copy(resource, "btsql-ext.properties");
copy(resource, "banner.txt");
return JsonResult.success();
}
private File copy(File root, String fileName) throws IOException {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream input = loader.getResourceAsStream(fileName);
if (input == null) {
log.info("copy " + fileName + " error,不存在");
return null;
}
@PostMapping(MODEL + "/projectGen.json")
@ResponseBody
public JsonResult project(String path,String basePackage,String includeConsole) throws IOException {
//includeConsole 当前版本忽略,总是添加一个系统管理功能,可以在pom中移除console
//生成maven项目结构
File maven = new File(path);
maven.mkdirs();
File src = new File(maven,"src");
src.mkdirs();
File main = new File(src,"main");
main.mkdir();
File test = new File(src,"test");
test.mkdir();
File javsSource = new File(main,"java");
javsSource.mkdir();
File resource = new File(main,"resources");
resource.mkdir();
File sql = new File(resource,"sql");
sql.mkdir();
File staticFile = new File(resource,"static");
staticFile.mkdir();
File templatesFile = new File(resource,"templates");
templatesFile.mkdir();
String codePath = basePackage.replace(".", "/");
File codeFile = new File(javsSource,codePath);
codeFile.mkdirs();
Configuration conf = Configuration.defaultConfiguration();
String tempalteRoot = "codeTemplate/maven/";
ClasspathResourceLoader loader = new ClasspathResourceLoader(Thread.currentThread().getContextClassLoader(),tempalteRoot);
GroupTemplate gt = new GroupTemplate(loader,conf);
FileWriter fw = null;
//先生成入口程序
Template mainJavaTempalte = gt.getTemplate("/main.java");
mainJavaTempalte.binding("basePackage", basePackage);
fw = new FileWriter(new File(codeFile,"MainApplication.java"));
mainJavaTempalte.renderTo(fw);
//生成pom文件
Template pomTemplate = gt.getTemplate("/pomTemplate.xml");
int index = basePackage.lastIndexOf(".");
String projectGrop = basePackage.substring(0, index);
String projectName = basePackage.substring(index+1);
pomTemplate.binding("group", projectGrop);
pomTemplate.binding("project", projectName);
fw = new FileWriter(new File(maven,"pom.xml"));
pomTemplate.renderTo(fw);
//复制当前项目的配置文件
File config = copy(resource,"application.properties");
copy(resource,"beetl.properties");
copy(resource,"btsql-ext.properties");
copy(resource,"banner.txt");
return JsonResult.success();
File target = new File(root, fileName);
FileOutputStream output = new FileOutputStream(target);
try {
byte[] buf = new byte[1024];
int bytesRead;
while ((bytesRead = input.read(buf)) > 0) {
output.write(buf, 0, bytesRead);
}
} finally {
input.close();
output.close();
}
private File copy(File root,String fileName) throws IOException {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream input = loader.getResourceAsStream(fileName);
if(input==null) {
log.info("copy "+fileName+" error,不存在");
return null;
}
File target = new File(root,fileName);
FileOutputStream output = new FileOutputStream(target);
try {
byte[] buf = new byte[1024];
int bytesRead;
while ((bytesRead = input.read(buf)) > 0) {
output.write(buf, 0, bytesRead);
}
} finally {
input.close();
output.close();
}
return target;
return target;
}
@PostMapping(MODEL + "/table.json")
@ResponseBody
public JsonResult<List<Entity>> getTable() {
List<Entity> list = codeGenService.getAllEntityInfo();
return JsonResult.success(list);
}
@PostMapping(MODEL + "/tableDetail.json")
@ResponseBody
public JsonResult<Entity> getInfo(String table) {
Entity entity = codeGenService.getEntityInfo(table);
if (entity == null) {
JsonResult.failMessage("表不存在");
}
return JsonResult.success(entity);
}
@PostMapping(MODEL + "/gen.json")
@ResponseBody
public JsonResult gen(EntityInfo data, String path) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
MavenProjectTarget target = new MavenProjectTarget(entity, basePackage);
// 生成到path目录下,按照maven工程解构生成
File file = new File(path);
if (!file.exists()) {
throw new PlatformException("路径不存在 " + path);
}
target.setTargetPath(path);
target.setUrlBase(urlBase);
JSGen jsGen = new JSGen();
jsGen.make(target, entity);
HtmlGen htmlGen = new HtmlGen();
htmlGen.make(target, entity);
String preffix = urlBase.replace('/', '.');
String basicFunctionCode = preffix + "." + entity.getCode();
JavaCodeGen javaGen = new JavaCodeGen(basePackage, entity, basicFunctionCode);
javaGen.make(target, entity);
MdGen mdGen = new MdGen();
mdGen.make(target, entity);
if (entity.isAutoAddMenu() || entity.isAutoAddFunction()) {
// 自动增加功能点
long functionId = this.codeGenService.insertFunction(entity, urlBase);
if (entity.isAutoAddMenu()) {
this.codeGenService.insertMenu(functionId, entity, urlBase);
}
}
@PostMapping(MODEL + "/table.json")
@ResponseBody
public JsonResult<List<Entity>> getTable() {
List<Entity> list = codeGenService.getAllEntityInfo();
return JsonResult.success(list);
}
@PostMapping(MODEL + "/tableDetail.json")
@ResponseBody
public JsonResult<Entity> getInfo(String table) {
Entity entity = codeGenService.getEntityInfo(table);
if (entity == null) {
JsonResult.failMessage("表不存在");
}
return JsonResult.success(entity);
}
@PostMapping(MODEL + "/gen.json")
@ResponseBody
public JsonResult gen(EntityInfo data,String path) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
MavenProjectTarget target = new MavenProjectTarget(entity, basePackage);
//生成到path目录下,按照maven工程解构生成
File file = new File(path);
if(!file.exists()) {
throw new PlatformException("路径不存在 "+path);
}
target.setTargetPath(path);
target.setUrlBase(urlBase);
JSGen jsGen = new JSGen();
jsGen.make(target, entity);
HtmlGen htmlGen = new HtmlGen();
htmlGen.make(target, entity);
String preffix = urlBase.replace('/', '.');
String basicFunctionCode = preffix+"."+entity.getCode();
JavaCodeGen javaGen = new JavaCodeGen(basePackage, entity,basicFunctionCode);
javaGen.make(target, entity);
MdGen mdGen = new MdGen();
mdGen.make(target, entity);
if(entity.isAutoAddMenu()||entity.isAutoAddFunction()) {
//自动增加功能点
long functionId = this.codeGenService.insertFunction(entity, urlBase);
if(entity.isAutoAddMenu()) {
this.codeGenService.insertMenu(functionId, entity, urlBase);
}
}
return JsonResult.success();
}
@PostMapping(MODEL + "/getPath.json")
@ResponseBody
public JsonResult<String> getPath() {
String path = MavenProjectTarget.detectRootPath();
return JsonResult.success(path);
}
@PostMapping(MODEL + "/html.json")
@ResponseBody
public JsonResult<Map<String, String>> html(EntityInfo data) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
WebTarget webTarget = new WebTarget(entity, basePackage);
webTarget.setUrlBase(urlBase);
HtmlGen htmlGen = new HtmlGen();
htmlGen.make(webTarget, entity);
Map<String, String> content = new HashMap<String, String>();
for (Entry<Object, String> entry : webTarget.map.entrySet()) {
AutoGen gen = (AutoGen) entry.getKey();
String code = entry.getValue();
content.put(gen.getName(), code);
}
return JsonResult.success(content);
}
@PostMapping(MODEL + "/js.json")
@ResponseBody
public JsonResult<Map<String, String>> js(EntityInfo data) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
WebTarget webTarget = new WebTarget(entity, basePackage);
webTarget.setUrlBase(urlBase);
JSGen jsGen = new JSGen();
jsGen.make(webTarget, entity);
Map<String, String> content = new HashMap<String, String>();
for (Entry<Object, String> entry : webTarget.map.entrySet()) {
AutoGen gen = (AutoGen) entry.getKey();
String code = entry.getValue();
content.put(gen.getName(), code);
}
return JsonResult.success(content);
}
@PostMapping(MODEL + "/java.json")
@ResponseBody
public JsonResult<Map<String, String>> javaCode(EntityInfo data) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
WebTarget webTarget = new WebTarget(entity, basePackage);
webTarget.setUrlBase(urlBase);
String preffix = urlBase.replace('/', '.');
String basicFunctionCode = preffix+"."+entity.getCode();
JavaCodeGen javaGen = new JavaCodeGen(basePackage,entity,basicFunctionCode);
javaGen.make(webTarget, entity);
Map<String, String> content = new HashMap<String, String>();
for (Entry<Object, String> entry : webTarget.map.entrySet()) {
AutoGen gen = (AutoGen) entry.getKey();
String code = entry.getValue();
content.put(gen.getName(), code);
}
return JsonResult.success(content);
}
@PostMapping(MODEL + "/sql.json")
@ResponseBody
public JsonResult<Map<String, String>> sql(EntityInfo data) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
WebTarget webTarget = new WebTarget(entity, basePackage);
webTarget.setUrlBase(urlBase);
MdGen javaGen = new MdGen();
javaGen.make(webTarget, entity);
Map<String, String> content = new HashMap<String, String>();
for (Entry<Object, String> entry : webTarget.map.entrySet()) {
AutoGen gen = (AutoGen) entry.getKey();
String code = entry.getValue();
content.put(gen.getName(), code);
}
return JsonResult.success(content);
}
private Entity getEntitiyInfo(EntityInfo data) {
Entity info = data.getEntity();
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
Entity entity = codeGenService.getEntityInfo(info.getTableName());
entity.setCode(info.getCode());
entity.setName(info.getName());
entity.setDisplayName(info.getDisplayName());
entity.setSystem(info.getSystem());
entity.setAttachment(data.entity.isAttachment());
entity.setIncludeExcel(data.entity.isIncludeExcel());
entity.setAutoAddFunction(info.isAutoAddFunction());
entity.setAutoAddMenu(info.isAutoAddFunction());
for (int i = 0; i < entity.getList().size(); i++) {
Attribute attr = entity.getList().get(i);
attr.setDisplayName(info.getList().get(i).getDisplayName());
attr.setShowInQuery(info.getList().get(i).isShowInQuery());
attr.setDictType(info.getList().get(i).getDictType());
attr.setVerifyList(info.getList().get(i).getVerifyList());
if(attr.getName().equals(data.getNameAttr())) {
entity.setNameAttribute(attr);
}
}
if (StringUtils.isEmpty(entity.getCode()) || StringUtils.isEmpty(entity.getSystem())) {
throw new PlatformException("code,system不能为空");
}
return entity;
}
@GetMapping(MODEL + "/{table}/test.json")
@ResponseBody
public void test(@PathVariable String table) {
String urlBase = "cms";
Entity entity = new Entity();
entity.setCode("blog");
entity.setName("CmsBlog");
entity.setDisplayName("博客");
entity.setTableName("CMS_BLOG");
entity.setSystem("console");
Attribute idAttr = new Attribute();
idAttr.setColName("id");
idAttr.setJavaType("Long");
idAttr.setName("id");
idAttr.setDisplayName("编号");
idAttr.setId(true);
entity.setIdAttribute(idAttr);
Attribute nameAttr = new Attribute();
nameAttr.setColName("title");
nameAttr.setJavaType("String");
nameAttr.setName("title");
nameAttr.setDisplayName("标题");
nameAttr.setShowInQuery(true);
Attribute contentAttr = new Attribute();
contentAttr.setColName("content");
contentAttr.setJavaType("String");
contentAttr.setName("content");
contentAttr.setDisplayName("内容");
contentAttr.setShowInQuery(true);
Attribute createTimeAttr = new Attribute();
createTimeAttr.setColName("create_time");
createTimeAttr.setJavaType("Date");
createTimeAttr.setName("createTime");
createTimeAttr.setDisplayName("创建日期");
createTimeAttr.setShowInQuery(true);
Attribute createUserIdAttr = new Attribute();
createUserIdAttr.setColName("create_user_id");
createUserIdAttr.setJavaType("Long");
createUserIdAttr.setName("createUserId");
createUserIdAttr.setDisplayName("创建人");
createUserIdAttr.setShowInQuery(true);
Attribute typeAttr = new Attribute();
typeAttr.setColName("type");
typeAttr.setJavaType("String");
typeAttr.setName("type");
typeAttr.setDisplayName("博客类型");
typeAttr.setShowInQuery(true);
entity.getList().add(idAttr);
entity.getList().add(nameAttr);
entity.getList().add(contentAttr);
entity.getList().add(createTimeAttr);
entity.getList().add(createUserIdAttr);
entity.getList().add(typeAttr);
entity.setNameAttribute(nameAttr);
entity.setComment("这是一个测试模型");
// ConsoleTarget target = new ConsoleTarget();
String basePackage = "com.ibeetl.admin.console";
MavenProjectTarget target = new MavenProjectTarget(entity, basePackage);
target.setUrlBase("admin");
JSGen jsGen = new JSGen();
jsGen.make(target, entity);
HtmlGen htmlGen = new HtmlGen();
htmlGen.make(target, entity);
String preffix = urlBase.replace('/', '.');
String basicFunctionCode = preffix+"."+entity.getCode();
JavaCodeGen javaGen = new JavaCodeGen(basePackage, entity,basicFunctionCode);
javaGen.make(target, entity);
MdGen mdGen = new MdGen();
mdGen.make(target, entity);
}
}
class EntityInfo {
Entity entity;
String urlBase;
String basePackage;
String nameAttr;
public Entity getEntity() {
return entity;
}
public void setEntity(Entity entity) {
this.entity = entity;
}
public String getUrlBase() {
return urlBase;
}
public void setUrlBase(String urlBase) {
this.urlBase = urlBase;
}
public String getBasePackage() {
return basePackage;
}
public void setBasePackage(String basePackage) {
this.basePackage = basePackage;
}
return JsonResult.success();
}
@PostMapping(MODEL + "/getPath.json")
@ResponseBody
public JsonResult<String> getPath() {
String path = MavenProjectTarget.detectRootPath();
return JsonResult.success(path);
}
@PostMapping(MODEL + "/html.json")
@ResponseBody
public JsonResult<Map<String, String>> html(EntityInfo data) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
WebTarget webTarget = new WebTarget(entity, basePackage);
webTarget.setUrlBase(urlBase);
HtmlGen htmlGen = new HtmlGen();
htmlGen.make(webTarget, entity);
Map<String, String> content = new HashMap<String, String>();
for (Entry<Object, String> entry : webTarget.map.entrySet()) {
AutoGen gen = (AutoGen) entry.getKey();
String code = entry.getValue();
content.put(gen.getName(), code);
}
return JsonResult.success(content);
}
@PostMapping(MODEL + "/js.json")
@ResponseBody
public JsonResult<Map<String, String>> js(EntityInfo data) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
WebTarget webTarget = new WebTarget(entity, basePackage);
webTarget.setUrlBase(urlBase);
JSGen jsGen = new JSGen();
jsGen.make(webTarget, entity);
Map<String, String> content = new HashMap<String, String>();
for (Entry<Object, String> entry : webTarget.map.entrySet()) {
AutoGen gen = (AutoGen) entry.getKey();
String code = entry.getValue();
content.put(gen.getName(), code);
}
return JsonResult.success(content);
}
@PostMapping(MODEL + "/java.json")
@ResponseBody
public JsonResult<Map<String, String>> javaCode(EntityInfo data) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
WebTarget webTarget = new WebTarget(entity, basePackage);
webTarget.setUrlBase(urlBase);
String preffix = urlBase.replace('/', '.');
String basicFunctionCode = preffix + "." + entity.getCode();
JavaCodeGen javaGen = new JavaCodeGen(basePackage, entity, basicFunctionCode);
javaGen.make(webTarget, entity);
Map<String, String> content = new HashMap<String, String>();
for (Entry<Object, String> entry : webTarget.map.entrySet()) {
AutoGen gen = (AutoGen) entry.getKey();
String code = entry.getValue();
content.put(gen.getName(), code);
}
public String getNameAttr() {
return nameAttr;
return JsonResult.success(content);
}
@PostMapping(MODEL + "/sql.json")
@ResponseBody
public JsonResult<Map<String, String>> sql(EntityInfo data) {
Entity entity = getEntitiyInfo(data);
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
WebTarget webTarget = new WebTarget(entity, basePackage);
webTarget.setUrlBase(urlBase);
MdGen javaGen = new MdGen();
javaGen.make(webTarget, entity);
Map<String, String> content = new HashMap<String, String>();
for (Entry<Object, String> entry : webTarget.map.entrySet()) {
AutoGen gen = (AutoGen) entry.getKey();
String code = entry.getValue();
content.put(gen.getName(), code);
}
return JsonResult.success(content);
}
private Entity getEntitiyInfo(EntityInfo data) {
Entity info = data.getEntity();
String urlBase = data.getUrlBase();
String basePackage = data.getBasePackage();
Entity entity = codeGenService.getEntityInfo(info.getTableName());
entity.setCode(info.getCode());
entity.setName(info.getName());
entity.setDisplayName(info.getDisplayName());
entity.setSystem(info.getSystem());
entity.setAttachment(data.entity.isAttachment());
entity.setIncludeExcel(data.entity.isIncludeExcel());
entity.setAutoAddFunction(info.isAutoAddFunction());
entity.setAutoAddMenu(info.isAutoAddFunction());
for (int i = 0; i < entity.getList().size(); i++) {
Attribute attr = entity.getList().get(i);
attr.setDisplayName(info.getList().get(i).getDisplayName());
attr.setShowInQuery(info.getList().get(i).isShowInQuery());
attr.setDictType(info.getList().get(i).getDictType());
attr.setVerifyList(info.getList().get(i).getVerifyList());
if (attr.getName().equals(data.getNameAttr())) {
entity.setNameAttribute(attr);
}
}
public void setNameAttr(String nameAttr) {
this.nameAttr = nameAttr;
if (StringUtils.isEmpty(entity.getCode()) || StringUtils.isEmpty(entity.getSystem())) {
throw new PlatformException("code,system不能为空");
}
return entity;
}
@GetMapping(MODEL + "/{table}/test.json")
@ResponseBody
public void test(@PathVariable String table) {
String urlBase = "cms";
Entity entity = new Entity();
entity.setCode("blog");
entity.setName("CmsBlog");
entity.setDisplayName("博客");
entity.setTableName("CMS_BLOG");
entity.setSystem("console");
Attribute idAttr = new Attribute();
idAttr.setColName("id");
idAttr.setJavaType("Long");
idAttr.setName("id");
idAttr.setDisplayName("编号");
idAttr.setId(true);
entity.setIdAttribute(idAttr);
Attribute nameAttr = new Attribute();
nameAttr.setColName("title");
nameAttr.setJavaType("String");
nameAttr.setName("title");
nameAttr.setDisplayName("标题");
nameAttr.setShowInQuery(true);
Attribute contentAttr = new Attribute();
contentAttr.setColName("content");
contentAttr.setJavaType("String");
contentAttr.setName("content");
contentAttr.setDisplayName("内容");
contentAttr.setShowInQuery(true);
Attribute createTimeAttr = new Attribute();
createTimeAttr.setColName("create_time");
createTimeAttr.setJavaType("Date");
createTimeAttr.setName("createTime");
createTimeAttr.setDisplayName("创建日期");
createTimeAttr.setShowInQuery(true);
Attribute createUserIdAttr = new Attribute();
createUserIdAttr.setColName("create_user_id");
createUserIdAttr.setJavaType("Long");
createUserIdAttr.setName("createUserId");
createUserIdAttr.setDisplayName("创建人");
createUserIdAttr.setShowInQuery(true);
Attribute typeAttr = new Attribute();
typeAttr.setColName("type");
typeAttr.setJavaType("String");
typeAttr.setName("type");
typeAttr.setDisplayName("博客类型");
typeAttr.setShowInQuery(true);
entity.getList().add(idAttr);
entity.getList().add(nameAttr);
entity.getList().add(contentAttr);
entity.getList().add(createTimeAttr);
entity.getList().add(createUserIdAttr);
entity.getList().add(typeAttr);
entity.setNameAttribute(nameAttr);
entity.setComment("这是一个测试模型");
// ConsoleTarget target = new ConsoleTarget();
String basePackage = "com.ibeetl.admin.console";
MavenProjectTarget target = new MavenProjectTarget(entity, basePackage);
target.setUrlBase("admin");
JSGen jsGen = new JSGen();
jsGen.make(target, entity);
HtmlGen htmlGen = new HtmlGen();
htmlGen.make(target, entity);
String preffix = urlBase.replace('/', '.');
String basicFunctionCode = preffix + "." + entity.getCode();
JavaCodeGen javaGen = new JavaCodeGen(basePackage, entity, basicFunctionCode);
javaGen.make(target, entity);
MdGen mdGen = new MdGen();
mdGen.make(target, entity);
}
}
class EntityInfo {
Entity entity;
String urlBase;
String basePackage;
String nameAttr;
public Entity getEntity() {
return entity;
}
public void setEntity(Entity entity) {
this.entity = entity;
}
public String getUrlBase() {
return urlBase;
}
public void setUrlBase(String urlBase) {
this.urlBase = urlBase;
}
public String getBasePackage() {
return basePackage;
}
public void setBasePackage(String basePackage) {
this.basePackage = basePackage;
}
public String getNameAttr() {
return nameAttr;
}
public void setNameAttr(String nameAttr) {
this.nameAttr = nameAttr;
}
}
package com.ibeetl.admin.core.web;
import java.util.List;
import org.apache.commons.logging.Log;
......@@ -17,43 +16,37 @@ import com.ibeetl.admin.core.service.CorePlatformService;
@Controller
@SuppressWarnings("unchecked")
public class CoreDictController {
private final Log log = LogFactory.getLog(this.getClass());
private static final String MODEL = "/core/dict";
@Autowired
CorePlatformService platformService;
@Autowired
CoreDictService dictService;
/**
* 查看字典类型对应的列表
* @param type
* @return
*/
@RequestMapping(MODEL + "/view.json")
@ResponseBody
public JsonResult<List<CoreDict>> view(String type) {
List<CoreDict> list = dictService.findAllByType(type);
return JsonResult.success(list);
}
/**
* 查看字典值的子字典
* @param value
* @return
*/
@RequestMapping(MODEL + "/viewChildren.json")
@ResponseBody
public JsonResult<List<CoreDict>> viewChild(String group,String value) {
CoreDict dict = dictService.findCoreDict(group,value);
List<CoreDict> list = dictService.findChildByParent(dict.getId());
return JsonResult.success(list);
}
private final Log log = LogFactory.getLog(this.getClass());
private static final String MODEL = "/core/dict";
@Autowired CorePlatformService platformService;
@Autowired CoreDictService dictService;
/**
* 查看字典类型对应的列表
*
* @param type
* @return
*/
@RequestMapping(MODEL + "/view.json")
@ResponseBody
public JsonResult<List<CoreDict>> view(String type) {
List<CoreDict> list = dictService.findAllByType(type);
return JsonResult.success(list);
}
/**
* 查看字典值的子字典
*
* @param value
* @return
*/
@RequestMapping(MODEL + "/viewChildren.json")
@ResponseBody
public JsonResult<List<CoreDict>> viewChild(String group, String value) {
CoreDict dict = dictService.findCoreDict(group, value);
List<CoreDict> list = dictService.findChildByParent(dict.getId());
return JsonResult.success(list);
}
}
......@@ -28,235 +28,226 @@ import com.ibeetl.admin.core.web.dto.SystemMenuView;
@Controller
@SuppressWarnings("unchecked")
public class CoreUserController {
private final Log log = LogFactory.getLog(this.getClass());
private static final String MODEL = "/core/user";
private final Log log = LogFactory.getLog(this.getClass());
private static final String MODEL = "/core/user";
@Autowired
CorePlatformService platformService;
@Autowired CorePlatformService platformService;
@Autowired
CoreUserService userService;
@Autowired CoreUserService userService;
@Autowired
HttpRequestLocal httpRequestLocal;
@Autowired HttpRequestLocal httpRequestLocal;
@Autowired PasswordEncryptService passwordEncryptService;
@PostMapping(MODEL + "/login.json")
@ResponseBody
public JsonResult<UserLoginInfo> login(String code, String password) {
UserLoginInfo info = userService.login(code, password);
if (info == null) {
@Autowired
PasswordEncryptService passwordEncryptService ;
@PostMapping(MODEL + "/login.json")
@ResponseBody
public JsonResult<UserLoginInfo> login(String code, String password) {
UserLoginInfo info = userService.login(code, password);
if (info == null) {
return JsonResult.failMessage("用户名密码错");
}
CoreUser user = info.getUser();
CoreOrg currentOrg = info.getOrgs().get(0);
for (CoreOrg org : info.getOrgs()) {
if (org.getId() == user.getOrgId()) {
currentOrg = org;
break;
}
}
info.setCurrentOrg(currentOrg);
// 记录登录信息到session
this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs());
return JsonResult.success(info);
}
/**
* 用户所在部门
*
* @return
*/
@PostMapping(MODEL + "/myOrgs.json")
@ResponseBody
public JsonResult<List<CoreOrg>> myOrgs() {
List<CoreOrg> orgs = (List<CoreOrg>) httpRequestLocal.getSessionValue(CorePlatformService.ACCESS_USER_ORGS);
return JsonResult.success(orgs);
}
/**
* 切换部门
*
* @param code
* @param orgId
* @return
*/
@PostMapping(MODEL + "/setOrg.json")
@ResponseBody
public JsonResult login(Long orgId) {
CoreUser user = platformService.getCurrentUser();
// 检查是否存在orgId
List<CoreOrg> orgs = platformService.getCurrentOrgs();
CoreOrg currentOrg = null;
for (CoreOrg org : orgs) {
if (orgId == org.getId()) {
currentOrg = org;
break;
}
}
if (currentOrg == null) {
// 非法切换
return JsonResult.failMessage("切换到不存在的部门");
}
httpRequestLocal.setSessionValue(CorePlatformService.ACCESS_CURRENT_ORG, currentOrg);
return JsonResult.success();
}
@PostMapping(MODEL + "/changePassword.json")
@ResponseBody
public JsonResult chnagePassword(String password, String newPassword) {
CoreUser temp = platformService.getCurrentUser();
CoreUser realUser = userService.getUserById(temp.getId());
String pwd = passwordEncryptService.password(password);
if (realUser.getPassword().equals(pwd)) {
realUser.setPassword(passwordEncryptService.password(newPassword));
userService.update(realUser);
return JsonResult.success();
} else {
return JsonResult.failMessage("密码错误");
}
}
/**
* 用户能查看的菜单
*
* @return
*/
@PostMapping(MODEL + "/menu/menuTree.json")
@ResponseBody
public JsonResult<List<MenuNodeView>> menus() {
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem item = platformService.getMenuItem(currentUser.getId(), orgId);
List<MenuNodeView> view = this.build(item);
return JsonResult.success(view);
}
/**
* 获取系统
*
* @return
*/
@PostMapping(MODEL + "/menu/system.json")
@ResponseBody
public JsonResult<List<SystemMenuView>> getSystem() {
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
List<MenuItem> list = menuItem.getChildren();
List<SystemMenuView> systems = new ArrayList<SystemMenuView>();
for (MenuItem item : list) {
systems.add(new SystemMenuView(item.getId(), item.getData().getCode(), item.getData().getName()));
}
return JsonResult.success(systems);
}
/**
* 获取系统对应的菜单树
*
* @return
*/
@PostMapping(MODEL + "/menu/systemMenu.json")
@ResponseBody
public JsonResult<List<MenuNodeView>> getMenuBySystem(long systemId) {
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
MenuItem item = menuItem.findChild(systemId);
List<MenuNodeView> view = this.build(item);
return JsonResult.success(view);
}
/**
* 用户所在公司的组织机构树
*
* @return
*/
@PostMapping(MODEL + "/org.json")
@ResponseBody
public JsonResult<OrgItem> getUserCompany() {
OrgItem orgItem = platformService.getUserOrgTree();
return JsonResult.success(orgItem);
}
/**
* 获取系统的菜单树
*
* @return
*/
@PostMapping(MODEL + "/menu/tree.json")
@ResponseBody
public JsonResult<List<MenuNodeView>> getMenuTree() {
MenuItem menuItem = platformService.buildMenu();
List<MenuNodeView> view = this.build(menuItem);
return JsonResult.success(view);
}
/**
* 获取功能点树
* @return
*/
@PostMapping(MODEL + "/function/tree.json")
@ResponseBody
public JsonResult<List<FunctionNodeView> > getFunctionTree() {
FunctionItem root = this.platformService.buildFunction();
List<FunctionNodeView> tree = buildFunctionTree(root);
return JsonResult.success(tree);
return JsonResult.failMessage("用户名密码错");
}
CoreUser user = info.getUser();
CoreOrg currentOrg = info.getOrgs().get(0);
for (CoreOrg org : info.getOrgs()) {
if (org.getId() == user.getOrgId()) {
currentOrg = org;
break;
}
}
private List<MenuNodeView> build(MenuItem node) {
List<MenuItem> list = node.getChildren();
if (list.size() == 0) {
return Collections.EMPTY_LIST;
}
info.setCurrentOrg(currentOrg);
// 记录登录信息到session
this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs());
return JsonResult.success(info);
}
/**
* 用户所在部门
*
* @return
*/
@PostMapping(MODEL + "/myOrgs.json")
@ResponseBody
public JsonResult<List<CoreOrg>> myOrgs() {
List<CoreOrg> orgs =
(List<CoreOrg>) httpRequestLocal.getSessionValue(CorePlatformService.ACCESS_USER_ORGS);
return JsonResult.success(orgs);
}
/**
* 切换部门
*
* @param code
* @param orgId
* @return
*/
@PostMapping(MODEL + "/setOrg.json")
@ResponseBody
public JsonResult login(Long orgId) {
CoreUser user = platformService.getCurrentUser();
// 检查是否存在orgId
List<CoreOrg> orgs = platformService.getCurrentOrgs();
CoreOrg currentOrg = null;
for (CoreOrg org : orgs) {
if (orgId == org.getId()) {
currentOrg = org;
break;
}
}
if (currentOrg == null) {
// 非法切换
return JsonResult.failMessage("切换到不存在的部门");
}
List<MenuNodeView> views = new ArrayList<MenuNodeView>(list.size());
httpRequestLocal.setSessionValue(CorePlatformService.ACCESS_CURRENT_ORG, currentOrg);
return JsonResult.success();
}
@PostMapping(MODEL + "/changePassword.json")
@ResponseBody
public JsonResult chnagePassword(String password, String newPassword) {
CoreUser temp = platformService.getCurrentUser();
CoreUser realUser = userService.getUserById(temp.getId());
String pwd = passwordEncryptService.password(password);
if (realUser.getPassword().equals(pwd)) {
realUser.setPassword(passwordEncryptService.password(newPassword));
userService.update(realUser);
return JsonResult.success();
} else {
return JsonResult.failMessage("密码错误");
}
}
/**
* 用户能查看的菜单
*
* @return
*/
@PostMapping(MODEL + "/menu/menuTree.json")
@ResponseBody
public JsonResult<List<MenuNodeView>> menus() {
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem item = platformService.getMenuItem(currentUser.getId(), orgId);
List<MenuNodeView> view = this.build(item);
return JsonResult.success(view);
}
/**
* 获取系统
*
* @return
*/
@PostMapping(MODEL + "/menu/system.json")
@ResponseBody
public JsonResult<List<SystemMenuView>> getSystem() {
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
List<MenuItem> list = menuItem.getChildren();
List<SystemMenuView> systems = new ArrayList<SystemMenuView>();
for (MenuItem item : list) {
systems.add(
new SystemMenuView(item.getId(), item.getData().getCode(), item.getData().getName()));
}
return JsonResult.success(systems);
}
/**
* 获取系统对应的菜单树
*
* @return
*/
@PostMapping(MODEL + "/menu/systemMenu.json")
@ResponseBody
public JsonResult<List<MenuNodeView>> getMenuBySystem(long systemId) {
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
MenuItem item = menuItem.findChild(systemId);
List<MenuNodeView> view = this.build(item);
return JsonResult.success(view);
}
/**
* 用户所在公司的组织机构树
*
* @return
*/
@PostMapping(MODEL + "/org.json")
@ResponseBody
public JsonResult<OrgItem> getUserCompany() {
OrgItem orgItem = platformService.getUserOrgTree();
return JsonResult.success(orgItem);
}
/**
* 获取系统的菜单树
*
* @return
*/
@PostMapping(MODEL + "/menu/tree.json")
@ResponseBody
public JsonResult<List<MenuNodeView>> getMenuTree() {
MenuItem menuItem = platformService.buildMenu();
List<MenuNodeView> view = this.build(menuItem);
return JsonResult.success(view);
}
/**
* 获取功能点树
*
* @return
*/
@PostMapping(MODEL + "/function/tree.json")
@ResponseBody
public JsonResult<List<FunctionNodeView>> getFunctionTree() {
FunctionItem root = this.platformService.buildFunction();
List<FunctionNodeView> tree = buildFunctionTree(root);
return JsonResult.success(tree);
}
private List<MenuNodeView> build(MenuItem node) {
List<MenuItem> list = node.getChildren();
if (list.size() == 0) {
return Collections.EMPTY_LIST;
}
for (MenuItem item : list) {
MenuNodeView view = new MenuNodeView();
view.setCode(item.getData().getCode());
view.setName(item.getData().getName());
view.setIcon(item.getData().getIcon());
view.setId(item.getData().getId());
view.setPath((String) item.getData().get("accessUrl"));
List<MenuNodeView> children = this.build(item);
view.setChildren(children);
views.add(view);
}
return views;
}
private List<FunctionNodeView> buildFunctionTree(FunctionItem node){
List<FunctionItem> list = node.getChildren();
if(list.size()==0){
return Collections.EMPTY_LIST;
}
List<FunctionNodeView> views = new ArrayList<FunctionNodeView>(list.size());
for(FunctionItem item :list){
FunctionNodeView view = new FunctionNodeView();
view.setCode(item.getData().getCode());
view.setName(item.getData().getName());
view.setId(item.getData().getId());
view.setAccessUrl(item.getData().getAccessUrl());
List<FunctionNodeView> children = this.buildFunctionTree(item);
view.setChildren(children);
views.add(view);
}
return views;
}
List<MenuNodeView> views = new ArrayList<MenuNodeView>(list.size());
for (MenuItem item : list) {
MenuNodeView view = new MenuNodeView();
view.setCode(item.getData().getCode());
view.setName(item.getData().getName());
view.setIcon(item.getData().getIcon());
view.setId(item.getData().getId());
view.setPath((String) item.getData().get("accessUrl"));
List<MenuNodeView> children = this.build(item);
view.setChildren(children);
views.add(view);
}
return views;
}
private List<FunctionNodeView> buildFunctionTree(FunctionItem node) {
List<FunctionItem> list = node.getChildren();
if (list.size() == 0) {
return Collections.EMPTY_LIST;
}
List<FunctionNodeView> views = new ArrayList<FunctionNodeView>(list.size());
for (FunctionItem item : list) {
FunctionNodeView view = new FunctionNodeView();
view.setCode(item.getData().getCode());
view.setName(item.getData().getName());
view.setId(item.getData().getId());
view.setAccessUrl(item.getData().getAccessUrl());
List<FunctionNodeView> children = this.buildFunctionTree(item);
view.setChildren(children);
views.add(view);
}
return views;
}
}
......@@ -28,83 +28,103 @@ import com.ibeetl.admin.core.util.FileUtil;
@Controller
public class FileSystemContorller {
private final Log log = LogFactory.getLog(this.getClass());
@Autowired
CorePlatformService platformService ;
private static final String MODEL = "/core/file";
/*附件类操作*/
@PostMapping(MODEL + "/uploadAttachment.json")
@ResponseBody
public JsonResult uploadFile(@RequestParam("file") MultipartFile file,String batchFileUUID,String bizType,String bizId) throws IOException {
if(file.isEmpty()) {
return JsonResult.fail();
}
CoreUser user = platformService.getCurrentUser();
CoreOrg org = platformService.getCurrentOrg();
FileItem fileItem = fileService.createFileItem(file.getOriginalFilename(), bizType, bizId, user.getId(), org.getId(), batchFileUUID,null);
OutputStream os = fileItem.openOutpuStream();
FileUtil.copy(file.getInputStream(), os);
return JsonResult.success(fileItem);
}
@PostMapping(MODEL + "/deleteAttachment.json")
@ResponseBody
public JsonResult deleteFile(Long fileId,String batchFileUUID ) throws IOException {
fileService.removeFile(fileId, batchFileUUID);
return JsonResult.success();
private final Log log = LogFactory.getLog(this.getClass());
@Autowired CorePlatformService platformService;
private static final String MODEL = "/core/file";
/*附件类操作*/
@PostMapping(MODEL + "/uploadAttachment.json")
@ResponseBody
public JsonResult uploadFile(
@RequestParam("file") MultipartFile file, String batchFileUUID, String bizType, String bizId)
throws IOException {
if (file.isEmpty()) {
return JsonResult.fail();
}
@GetMapping(MODEL + "/download/{fileId}/{batchFileUUID}/{name}")
public ModelAndView download(HttpServletResponse response,@PathVariable Long fileId,@PathVariable String batchFileUUID ) throws IOException {
FileItem item = fileService.getFileItemById(fileId,batchFileUUID);
response.setHeader("Content-Disposition", "attachment; filename="+URLEncoder.encode(item.getName(),"UTF-8"));
item.copy(response.getOutputStream());
return null;
CoreUser user = platformService.getCurrentUser();
CoreOrg org = platformService.getCurrentOrg();
FileItem fileItem =
fileService.createFileItem(
file.getOriginalFilename(),
bizType,
bizId,
user.getId(),
org.getId(),
batchFileUUID,
null);
OutputStream os = fileItem.openOutpuStream();
FileUtil.copy(file.getInputStream(), os);
return JsonResult.success(fileItem);
}
@PostMapping(MODEL + "/deleteAttachment.json")
@ResponseBody
public JsonResult deleteFile(Long fileId, String batchFileUUID) throws IOException {
fileService.removeFile(fileId, batchFileUUID);
return JsonResult.success();
}
@GetMapping(MODEL + "/download/{fileId}/{batchFileUUID}/{name}")
public ModelAndView download(
HttpServletResponse response, @PathVariable Long fileId, @PathVariable String batchFileUUID)
throws IOException {
FileItem item = fileService.getFileItemById(fileId, batchFileUUID);
response.setHeader(
"Content-Disposition",
"attachment; filename=" + URLEncoder.encode(item.getName(), "UTF-8"));
item.copy(response.getOutputStream());
return null;
}
/*execl 导入导出*/
@Autowired FileService fileService;
@GetMapping(MODEL + "/get.do")
public ModelAndView index(HttpServletResponse response, String id) throws IOException {
String path = id;
response.setContentType("text/html; charset = UTF-8");
FileItem fileItem = fileService.loadFileItemByPath(path);
response.setHeader(
"Content-Disposition",
"attachment; filename=" + java.net.URLEncoder.encode(fileItem.getName(), "UTF-8"));
fileItem.copy(response.getOutputStream());
if (fileItem.isTemp()) {
fileItem.delete();
}
/*execl 导入导出*/
@Autowired
FileService fileService;
@GetMapping(MODEL + "/get.do")
public ModelAndView index(HttpServletResponse response,String id) throws IOException {
String path = id;
response.setContentType("text/html; charset = UTF-8");
FileItem fileItem = fileService.loadFileItemByPath(path);
response.setHeader("Content-Disposition", "attachment; filename="+java.net.URLEncoder.encode(fileItem.getName(), "UTF-8"));
fileItem.copy(response.getOutputStream());
if(fileItem.isTemp()) {
fileItem.delete();
}
return null;
}
@GetMapping(MODEL + "/downloadTemplate.do")
public ModelAndView dowloadTemplate(HttpServletResponse response,String path) throws IOException {
response.setContentType("text/html; charset = UTF-8");
int start1 = path.lastIndexOf("\\");
int start2 = path.lastIndexOf("/");
if(start2>start1) {
start1 = start2;
}
String file = path.substring(start1+1);
response.setHeader("Content-Disposition", "attachment; filename="+java.net.URLEncoder.encode(file,"UTF-8"));
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("excelTemplates/"+path);
FileUtil.copy(input, response.getOutputStream());
return null;
return null;
}
@GetMapping(MODEL + "/downloadTemplate.do")
public ModelAndView dowloadTemplate(HttpServletResponse response, String path)
throws IOException {
response.setContentType("text/html; charset = UTF-8");
int start1 = path.lastIndexOf("\\");
int start2 = path.lastIndexOf("/");
if (start2 > start1) {
start1 = start2;
}
@GetMapping(MODEL + "/simpleUpload.do")
public ModelAndView simpleUploadPage(String uploadUrl,String templatePath,String fileType) throws IOException {
ModelAndView view = new ModelAndView("/common/simpleUpload.html");
view.addObject("uploadUrl",uploadUrl);
view.addObject("templatePath",templatePath);
view.addObject("fileType",fileType);
return view;
}
String file = path.substring(start1 + 1);
response.setHeader(
"Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(file, "UTF-8"));
InputStream input =
Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("excelTemplates/" + path);
FileUtil.copy(input, response.getOutputStream());
return null;
}
@GetMapping(MODEL + "/simpleUpload.do")
public ModelAndView simpleUploadPage(String uploadUrl, String templatePath, String fileType)
throws IOException {
ModelAndView view = new ModelAndView("/common/simpleUpload.html");
view.addObject("uploadUrl", uploadUrl);
view.addObject("templatePath", templatePath);
view.addObject("fileType", fileType);
return view;
}
}
......@@ -23,71 +23,66 @@ import com.ibeetl.admin.core.util.PlatformException;
@Controller
public class IndexController {
@Autowired
CorePlatformService platformService;
@Autowired CorePlatformService platformService;
@Autowired
CoreUserService userService;
@Autowired CoreUserService userService;
@Autowired
HttpRequestLocal httpRequestLocal;
@Autowired HttpRequestLocal httpRequestLocal;
@RequestMapping("/")
public ModelAndView login() {
ModelAndView view = new ModelAndView("/login.html");
return view;
}
@RequestMapping("/")
public ModelAndView login() {
ModelAndView view = new ModelAndView("/login.html");
return view;
}
@PostMapping("/login.do")
public ModelAndView login(String code, String password) {
UserLoginInfo info = userService.login(code, password);
if (info == null) {
throw new PlatformException("用户名密码错");
}
CoreUser user = info.getUser();
CoreOrg currentOrg = info.getOrgs().get(0);
for (CoreOrg org : info.getOrgs()) {
if (org.getId() == user.getOrgId()) {
currentOrg = org;
break;
}
}
@PostMapping("/user/login")
public ModelAndView login(String code, String password) {
UserLoginInfo info = userService.login(code, password);
if (info == null) {
throw new PlatformException("用户名密码错");
}
CoreUser user = info.getUser();
CoreOrg currentOrg = info.getOrgs().get(0);
for (CoreOrg org : info.getOrgs()) {
if (org.getId() == user.getOrgId()) {
currentOrg = org;
break;
}
}
info.setCurrentOrg(currentOrg);
// 记录登录信息到session
this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs());
ModelAndView view = new ModelAndView("redirect:/index.do");
return view;
}
info.setCurrentOrg(currentOrg);
// 记录登录信息到session
this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs());
ModelAndView view = new ModelAndView("redirect:/index.do");
return view;
}
@RequestMapping("/index.do")
public ModelAndView index() {
ModelAndView view = new ModelAndView("/index.html");
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
view.addObject("menus", menuItem);
return view;
}
@RequestMapping("/index.do")
public ModelAndView index() {
ModelAndView view = new ModelAndView("/index.html");
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
view.addObject("menus", menuItem);
return view;
}
@RequestMapping("/logout.do")
public ModelAndView logout(HttpServletRequest request) {
HttpSession session = request.getSession();
Enumeration eum = session.getAttributeNames();
while(eum.hasMoreElements()) {
String key = (String)eum.nextElement();
session.removeAttribute(key);
}
ModelAndView view = new ModelAndView("redirect:/");
return view;
}
@RequestMapping("/changeOrg.do")
public ModelAndView changeOrg(HttpServletRequest request,Long orgId) {
platformService.changeOrg(orgId);
ModelAndView view = new ModelAndView("redirect:/index.do");
return view;
}
@RequestMapping("/logout.do")
public ModelAndView logout(HttpServletRequest request) {
HttpSession session = request.getSession();
Enumeration eum = session.getAttributeNames();
while (eum.hasMoreElements()) {
String key = (String) eum.nextElement();
session.removeAttribute(key);
}
ModelAndView view = new ModelAndView("redirect:/");
return view;
}
@RequestMapping("/changeOrg.do")
public ModelAndView changeOrg(HttpServletRequest request, Long orgId) {
platformService.changeOrg(orgId);
ModelAndView view = new ModelAndView("redirect:/index.do");
return view;
}
}
......@@ -2,100 +2,95 @@ package com.ibeetl.admin.core.web;
/**
* 描述: json格式数据返回对象,使用CustomJsonResultSerializer 来序列化
*
* @author : lijiazhi
*/
public class JsonResult<T> {
private String code;
private String msg;
private T data;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
@Override
public String toString() {
return "code=" + code + " message=" + msg + " data=" + data;
}
public static <T> JsonResult<T> fail() {
JsonResult<T> ret = new JsonResult<T>();
ret.setCode(JsonReturnCode.FAIL.getCode());
ret.setMsg(JsonReturnCode.FAIL.getDesc());
return ret;
}
public static <T> JsonResult<T> fail(T data) {
JsonResult<T> ret = JsonResult.fail();
ret.setData(data);
return ret;
}
public static <T> JsonResult<T> failMessage(String msg) {
JsonResult<T> ret = JsonResult.fail();
ret.setMsg(msg);
return ret;
}
public static <T> JsonResult<T> successMessage(String msg) {
JsonResult<T> ret = JsonResult.success();
ret.setMsg(msg);
return ret;
}
public static <T> JsonResult<T> success() {
JsonResult<T> ret = new JsonResult<T>();
ret.setCode(JsonReturnCode.SUCCESS.getCode());
ret.setMsg(JsonReturnCode.SUCCESS.getDesc());
return ret;
}
public static <T> JsonResult<T> success(T data) {
JsonResult<T> ret = JsonResult.success();
ret.setData(data);
return ret;
}
public static <T> JsonResult<T> http404(T data) {
JsonResult<T> ret = new JsonResult<T>();
ret.setCode(JsonReturnCode.NOT_FOUND.getCode());
ret.setMsg(JsonReturnCode.NOT_FOUND.getDesc());
ret.setData(data);
return ret;
}
public static <T> JsonResult<T> http403(T data) {
JsonResult<T> ret = new JsonResult<T>();
ret.setCode(JsonReturnCode.ACCESS_ERROR.getCode());
ret.setMsg(JsonReturnCode.ACCESS_ERROR.getDesc());
ret.setData(data);
return ret;
}
private String code;
private String msg;
private T data;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
@Override
public String toString() {
return "code=" + code + " message=" + msg + " data=" + data;
}
public static <T> JsonResult<T> fail() {
JsonResult<T> ret = new JsonResult<T>();
ret.setCode(JsonReturnCode.FAIL.getCode());
ret.setMsg(JsonReturnCode.FAIL.getDesc());
return ret;
}
public static <T> JsonResult<T> fail(T data) {
JsonResult<T> ret = JsonResult.fail();
ret.setData(data);
return ret;
}
public static <T> JsonResult<T> failMessage(String msg) {
JsonResult<T> ret = JsonResult.fail();
ret.setMsg(msg);
return ret;
}
public static <T> JsonResult<T> successMessage(String msg) {
JsonResult<T> ret = JsonResult.success();
ret.setMsg(msg);
return ret;
}
public static <T> JsonResult<T> success() {
JsonResult<T> ret = new JsonResult<T>();
ret.setCode(JsonReturnCode.SUCCESS.getCode());
ret.setMsg(JsonReturnCode.SUCCESS.getDesc());
return ret;
}
public static <T> JsonResult<T> success(T data) {
JsonResult<T> ret = JsonResult.success();
ret.setData(data);
return ret;
}
public static <T> JsonResult<T> http404(T data) {
JsonResult<T> ret = new JsonResult<T>();
ret.setCode(JsonReturnCode.NOT_FOUND.getCode());
ret.setMsg(JsonReturnCode.NOT_FOUND.getDesc());
ret.setData(data);
return ret;
}
public static <T> JsonResult<T> http403(T data) {
JsonResult<T> ret = new JsonResult<T>();
ret.setCode(JsonReturnCode.ACCESS_ERROR.getCode());
ret.setMsg(JsonReturnCode.ACCESS_ERROR.getDesc());
ret.setData(data);
return ret;
}
}
......@@ -2,41 +2,42 @@ package com.ibeetl.admin.core.web;
/**
* 描述: json格式数据返回码
*<ul>
* <li>100 : 用户未登录 </li>
* <li>200 : 成功 </li>
* <li>300 : 失败 </li>
*
* <ul>
* <li>100 : 用户未登录
* <li>200 : 成功
* <li>300 : 失败
* </ul>
*
* @author : Administrator
*/
public enum JsonReturnCode {
NOT_LOGIN("401", "未登录"),
SUCCESS("200", "成功"),
FAIL("500", "内部失败"),
ACCESS_ERROR("403", "禁止访问"),
NOT_FOUND("404", "页面未发现");
private String code;
private String desc;
NOT_LOGIN("401","未登录"),
SUCCESS ("200","成功"),
FAIL ("500","内部失败"),
ACCESS_ERROR ("403","禁止访问"),
NOT_FOUND ("404","页面未发现");
private String code;
private String desc;
JsonReturnCode(String code, String desc) {
this.code = code;
this.desc = desc;
}
JsonReturnCode(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public void setCode(String code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
......@@ -5,50 +5,59 @@ import java.util.List;
public class FunctionNodeView {
private String name;
private String code;
private String accessUrl;
private Long id;
String icon;
List<FunctionNodeView> children=new ArrayList<FunctionNodeView>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<FunctionNodeView> getChildren() {
return children;
}
public void setChildren(List<FunctionNodeView> children) {
this.children = children;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getAccessUrl() {
return accessUrl;
}
public void setAccessUrl(String accessUrl) {
this.accessUrl = accessUrl;
}
private String name;
private String code;
private String accessUrl;
private Long id;
String icon;
List<FunctionNodeView> children = new ArrayList<FunctionNodeView>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<FunctionNodeView> getChildren() {
return children;
}
public void setChildren(List<FunctionNodeView> children) {
this.children = children;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getAccessUrl() {
return accessUrl;
}
public void setAccessUrl(String accessUrl) {
this.accessUrl = accessUrl;
}
}
......@@ -5,59 +5,58 @@ import java.util.List;
public class MenuNodeView {
private String name;
private String code;
private Long id;
private String path;
private String icon;
private List<MenuNodeView> children = new ArrayList<MenuNodeView>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<MenuNodeView> getChildren() {
return children;
}
public void setChildren(List<MenuNodeView> children) {
this.children = children;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
private String name;
private String code;
private Long id;
private String path;
private String icon;
private List<MenuNodeView> children = new ArrayList<MenuNodeView>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<MenuNodeView> getChildren() {
return children;
}
public void setChildren(List<MenuNodeView> children) {
this.children = children;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
}
......@@ -2,47 +2,46 @@ package com.ibeetl.admin.core.web.dto;
public class SystemMenuView {
String code;
Long id;
String name;
String icon;
public SystemMenuView(Long id, String code, String name) {
this.id = id;
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
String code;
Long id;
String name;
String icon;
public SystemMenuView(Long id, String code, String name) {
this.id = id;
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
}
......@@ -8,58 +8,57 @@ import java.lang.reflect.Field;
/**
* 子类继承此类获得翻页功能
*
* @author lijiazhi
*/
public class PageParam {
private Integer page = null;
private Integer limit = null;
private Integer page = null;
private Integer limit = null;
public Integer getPage() {
return page;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public void setPage(Integer page) {
this.page = page;
}
@JsonIgnore
public PageQuery getPageQuery() {
Field[] fs =this.getClass().getDeclaredFields();
for(Field f:fs){
Query query = f.getAnnotation(Query.class);
if(query==null){
continue ;
@JsonIgnore
public PageQuery getPageQuery() {
Field[] fs = this.getClass().getDeclaredFields();
for (Field f : fs) {
Query query = f.getAnnotation(Query.class);
if (query == null) {
continue;
}
if (query.fuzzy()) {
try {
if (f.getType() == String.class) {
f.setAccessible(true);
Object o = f.get(this);
if (o != null && !o.toString().isEmpty()) {
f.set(this, "%" + o.toString() + "%");
}
if (query.fuzzy()) {
try {
if ( f.getType() == String.class) {
f.setAccessible(true);
Object o = f.get(this);
if (o != null && !o.toString().isEmpty()) {
f.set(this,"%"+o.toString()+"%");
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
PageQuery query = new PageQuery();
query.setParas(this);
if (page != null) {
query.setPageNumber(page);
query.setPageSize(limit);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return query;
}
}
PageQuery query = new PageQuery();
query.setParas(this);
if (page != null) {
query.setPageNumber(page);
query.setPageSize(limit);
}
return query;
}
public Integer getLimit() {
return limit;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
}
......@@ -4,20 +4,21 @@ import java.util.ArrayList;
import java.util.List;
public class QueryData {
List<QueryItem> all = new ArrayList<>();
List<QueryItem> defaultItems = new ArrayList<>();
public List<QueryItem> getQueryItems(){
return all;
}
public List<QueryItem> getDefaultItems(){
return defaultItems;
}
public void addQueryItem(QueryItem item){
all.add(item);
if(item.isShow()){
defaultItems.add(item);
}
}
List<QueryItem> all = new ArrayList<>();
List<QueryItem> defaultItems = new ArrayList<>();
public List<QueryItem> getQueryItems() {
return all;
}
public List<QueryItem> getDefaultItems() {
return defaultItems;
}
public void addQueryItem(QueryItem item) {
all.add(item);
if (item.isShow()) {
defaultItems.add(item);
}
}
}
......@@ -2,61 +2,71 @@ package com.ibeetl.admin.core.web.query;
/**
* 查询选项
* @author lijiazhi
*
* @author lijiazhi
*/
public class QueryItem {
private String fieldName;
private String name;
private int type =1 ;
private boolean show=false;
private String dictName="";
private boolean fuzzy = false;
private String group = null;
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public boolean isShow() {
return show;
}
public void setShow(boolean show) {
this.show = show;
}
public String getDictName() {
return dictName;
}
public void setDictName(String dictName) {
this.dictName = dictName;
}
public boolean isFuzzy() {
return fuzzy;
}
public void setFuzzy(boolean fuzzy) {
this.fuzzy = fuzzy;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
private String fieldName;
private String name;
private int type = 1;
private boolean show = false;
private String dictName = "";
private boolean fuzzy = false;
private String group = null;
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public boolean isShow() {
return show;
}
public void setShow(boolean show) {
this.show = show;
}
public String getDictName() {
return dictName;
}
public void setDictName(String dictName) {
this.dictName = dictName;
}
public boolean isFuzzy() {
return fuzzy;
}
public void setFuzzy(boolean fuzzy) {
this.fuzzy = fuzzy;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
}
......@@ -8,38 +8,38 @@ import com.ibeetl.admin.core.util.ClassLoaderUtil;
/**
* 页面查询条件
* @author lijiazhi
*
* @author lijiazhi
*/
public class QueryParser {
ConcurrentHashMap<String, QueryData> cache = new ConcurrentHashMap<> ();
public QueryData getData(String querClass){
if(cache.containsKey(querClass)){
return cache.get(querClass);
}
Class cls = ClassLoaderUtil.loadClass(querClass);
Field[] fs =cls.getDeclaredFields();
QueryData data = new QueryData();
for(Field f:fs){
Query query = f.getAnnotation(Query.class);
if(query==null){
continue ;
}
QueryItem item = new QueryItem();
item.setFieldName(f.getName());
item.setName(query.name());
item.setShow(query.display());
item.setType(query.type());
item.setDictName(query.dict());
item.setFuzzy(query.fuzzy());
item.setGroup(query.group());
data.addQueryItem(item);
}
cache.put(querClass, data);
return data;
}
ConcurrentHashMap<String, QueryData> cache = new ConcurrentHashMap<>();
public QueryData getData(String querClass) {
if (cache.containsKey(querClass)) {
return cache.get(querClass);
}
Class cls = ClassLoaderUtil.loadClass(querClass);
Field[] fs = cls.getDeclaredFields();
QueryData data = new QueryData();
for (Field f : fs) {
Query query = f.getAnnotation(Query.class);
if (query == null) {
continue;
}
QueryItem item = new QueryItem();
item.setFieldName(f.getName());
item.setName(query.name());
item.setShow(query.display());
item.setType(query.type());
item.setDictName(query.dict());
item.setFuzzy(query.fuzzy());
item.setGroup(query.group());
data.addQueryItem(item);
}
cache.put(querClass, data);
return data;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spring Boot开发平台</title>
<link rel="stylesheet" href="${ctxPath}/plugins/layui/css/layui.css">
<script src="${ctxPath}/plugins/layui/layui.js"></script>
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style rel="stylesheet" type="text/css">
.layui-tab-title li:first-child > i {
display: none;
}
</style>
<meta charset="UTF-8">
<title>Spring Boot开发平台</title>
<link rel="stylesheet" href="${ctxPath}/plugins/layui/css/layui.css">
<script src="${ctxPath}/plugins/layui/layui.js"></script>
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style rel="stylesheet" type="text/css">
.layui-tab-title li:first-child > i {
display: none;
}
</style>
</head>
<body class="layui-layout-body">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>用户登录</legend>
</fieldset>
<form class="layui-form" action="${ctxPath}/login.do" method="post">
<div class="layui-form-item">
<label class="layui-form-label">用户名</label>
<div class="layui-input-block">
<input type="text" name="code" lay-verify="title" autocomplete="off"
placeholder="请输入用户名" class="layui-input" value="admin">
<input type="text" name="code" lay-verify="title" autocomplete="off"
placeholder="请输入用户名" class="layui-input" value="admin">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-block">
<input type="password" name="password" lay-verify="required" name="" placeholder="请输入密码" autocomplete="off"
class="layui-input" value="123456">
<input type="password" name="password" lay-verify="required" name="" placeholder="请输入密码"
autocomplete="off"
class="layui-input" value="123456">
</div>
</div>
<div class="layui-form-item">
......@@ -42,6 +43,6 @@
<button class="layui-btn" lay-submit="" lay-filter="demo1">立即登录</button>
</div>
</div>
</form>
</form>
</body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<code_scheme name="GoogleStyle">
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="false" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
<option name="USE_RELATIVE_INDENTS" value="false" />
</value>
</option>
<option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="true" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
</value>
</option>
<option name="RIGHT_MARGIN" value="100" />
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
<option name="JD_P_AT_EMPTY_LINES" value="false" />
<option name="JD_KEEP_EMPTY_PARAMETER" value="false" />
<option name="JD_KEEP_EMPTY_EXCEPTION" value="false" />
<option name="JD_KEEP_EMPTY_RETURN" value="false" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="0" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_FOR" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="TERNARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="1" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="WRAP_COMMENTS" value="true" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
<AndroidXmlCodeStyleSettings>
<option name="USE_CUSTOM_SETTINGS" value="true" />
<option name="LAYOUT_SETTINGS">
<value>
<option name="INSERT_BLANK_LINE_BEFORE_TAG" value="false" />
</value>
</option>
</AndroidXmlCodeStyleSettings>
<JSCodeStyleSettings>
<option name="INDENT_CHAINED_CALLS" value="false" />
</JSCodeStyleSettings>
<Python>
<option name="USE_CONTINUATION_INDENT_FOR_ARGUMENTS" value="true" />
</Python>
<TypeScriptCodeStyleSettings>
<option name="INDENT_CHAINED_CALLS" value="false" />
</TypeScriptCodeStyleSettings>
<XML>
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="CSS">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="ECMA Script Level 4">
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_FOR" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="TERNARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="1" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="HTML">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_RESOURCES" value="false" />
<option name="ALIGN_MULTILINE_FOR" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="TERNARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="1" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="WRAP_COMMENTS" value="true" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JSON">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JavaScript">
<option name="RIGHT_MARGIN" value="80" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_FOR" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="TERNARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="1" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="PROTO">
<option name="RIGHT_MARGIN" value="80" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="protobuf">
<option name="RIGHT_MARGIN" value="80" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="Python">
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="RIGHT_MARGIN" value="80" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="SASS">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="SCSS">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="TypeScript">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:.*Style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_width</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_height</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_weight</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_margin</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_marginTop</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_marginBottom</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_marginStart</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_marginEnd</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_marginLeft</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_marginRight</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:layout_.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:padding</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:paddingTop</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:paddingBottom</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:paddingStart</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:paddingEnd</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:paddingLeft</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:paddingRight</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res-auto</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/tools</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<Objective-C>
<option name="INDENT_NAMESPACE_MEMBERS" value="0" />
<option name="INDENT_C_STRUCT_MEMBERS" value="2" />
<option name="INDENT_CLASS_MEMBERS" value="2" />
<option name="INDENT_VISIBILITY_KEYWORDS" value="1" />
<option name="INDENT_INSIDE_CODE_BLOCK" value="2" />
<option name="KEEP_STRUCTURES_IN_ONE_LINE" value="true" />
<option name="FUNCTION_PARAMETERS_WRAP" value="5" />
<option name="FUNCTION_CALL_ARGUMENTS_WRAP" value="5" />
<option name="TEMPLATE_CALL_ARGUMENTS_WRAP" value="5" />
<option name="TEMPLATE_CALL_ARGUMENTS_ALIGN_MULTILINE" value="true" />
<option name="ALIGN_INIT_LIST_IN_COLUMNS" value="false" />
<option name="SPACE_BEFORE_SUPERCLASS_COLON" value="false" />
</Objective-C>
<Objective-C-extensions>
<option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
<option name="RELEASE_STYLE" value="IVAR" />
<option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cc" header="h" />
<pair source="c" header="h" />
</extensions>
</Objective-C-extensions>
<codeStyleSettings language="ObjectiveC">
<option name="RIGHT_MARGIN" value="80" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="BLANK_LINES_BEFORE_IMPORTS" value="0" />
<option name="BLANK_LINES_AFTER_IMPORTS" value="0" />
<option name="BLANK_LINES_AROUND_CLASS" value="0" />
<option name="BLANK_LINES_AROUND_METHOD" value="0" />
<option name="BLANK_LINES_AROUND_METHOD_IN_INTERFACE" value="0" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="false" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
......@@ -5,12 +5,13 @@ const context = '@@wavesContext'
function handleClick(el, binding) {
function handle(e) {
const customOpts = Object.assign({}, binding.value)
const opts = Object.assign({
ele: el, // 波纹作用元素
type: 'hit', // hit 点击位置扩散 center中心点扩展
color: 'rgba(0, 0, 0, 0.15)' // 波纹颜色
},
customOpts
const opts = Object.assign(
{
ele: el, // 波纹作用元素
type: 'hit', // hit 点击位置扩散 center中心点扩展
color: 'rgba(0, 0, 0, 0.15)' // 波纹颜色
},
customOpts
)
const target = opts.ele
if (target) {
......@@ -21,23 +22,30 @@ function handleClick(el, binding) {
if (!ripple) {
ripple = document.createElement('span')
ripple.className = 'waves-ripple'
ripple.style.height = ripple.style.width = Math.max(rect.width, rect.height) + 'px'
ripple.style.height = ripple.style.width =
Math.max(rect.width, rect.height) + 'px'
target.appendChild(ripple)
} else {
ripple.className = 'waves-ripple'
}
switch (opts.type) {
case 'center':
ripple.style.top = rect.height / 2 - ripple.offsetHeight / 2 + 'px'
ripple.style.left = rect.width / 2 - ripple.offsetWidth / 2 + 'px'
break
default:
ripple.style.top =
(e.pageY - rect.top - ripple.offsetHeight / 2 - document.documentElement.scrollTop ||
document.body.scrollTop) + 'px'
ripple.style.left =
(e.pageX - rect.left - ripple.offsetWidth / 2 - document.documentElement.scrollLeft ||
document.body.scrollLeft) + 'px'
case 'center':
ripple.style.top = rect.height / 2 - ripple.offsetHeight / 2 + 'px'
ripple.style.left = rect.width / 2 - ripple.offsetWidth / 2 + 'px'
break
default:
ripple.style.top =
(e.pageY -
rect.top -
ripple.offsetHeight / 2 -
document.documentElement.scrollTop || document.body.scrollTop) +
'px'
ripple.style.left =
(e.pageX -
rect.left -
ripple.offsetWidth / 2 -
document.documentElement.scrollLeft || document.body.scrollLeft) +
'px'
}
ripple.style.backgroundColor = opts.color
ripple.className = 'waves-ripple z-active'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment