| | |
| | | import org.yeshi.utils.generater.util.NameUtil; |
| | | import org.yeshi.utils.generater.vo.ExceptionVO; |
| | | import org.yeshi.utils.generater.vo.admin.controller.AdminControllerInfoVO; |
| | | import org.yeshi.utils.generater.vo.admin.controller.AdminVOVO; |
| | | import org.yeshi.utils.generater.vo.dao.MongoDBDaoVO; |
| | | import org.yeshi.utils.generater.vo.dao.MyBatisDBDaoVO; |
| | | import org.yeshi.utils.generater.vo.service.QueryVO; |
| | |
| | | FileUtil.saveAsFileByte(data.getBytes("UTF-8"), path); |
| | | } |
| | | |
| | | public void createException(Class base) throws Exception { |
| | | public void createException(ClassInfo base) throws Exception { |
| | | if (config.getService().getException() == null) { |
| | | throw new Exception("尚未配置异常信息"); |
| | | } |
| | |
| | | String exceptionName = NameUtil.getDefaultExceptionName(config.getEntity()); |
| | | String path = getDirPath(config.getService().getException().getPkg()); |
| | | try { |
| | | ExceptionVO vo = new ExceptionVO.Builder().setEntity(config.getEntity()).setPackageName(config.getService().getException().getPkg()).setBase(new ClassInfo(base.getSimpleName(), base.getName())).build(); |
| | | ExceptionVO vo = new ExceptionVO.Builder().setEntity(config.getEntity()).setPackageName(config.getService().getException().getPkg()).setBase(base).build(); |
| | | String result = GeneraterUtil.createException(vo); |
| | | //保存 |
| | | saveFile(result, new File(path, exceptionName + ".java").getAbsolutePath()); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void createAdminVO() throws Exception { |
| | | if (StringUtil.isNullOrEmpty(config.getService().getAdminVOPackage())) { |
| | | throw new Exception("尚未配置AdminVO"); |
| | | } |
| | | |
| | | String name = NameUtil.getDefaultExceptionName(config.getEntity()); |
| | | String path = getDirPath(config.getService().getAdminVOPackage()); |
| | | try { |
| | | AdminVOVO vo = new AdminVOVO.Builder().setEntity(config.getEntity()).setPackageName(config.getService().getAdminVOPackage()).build(); |
| | | String result = GeneraterUtil.createAdminVO(vo); |
| | | //保存 |
| | | saveFile(result, new File(path, name + ".java").getAbsolutePath()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void createDao() throws Exception { |
| | | |
| | |
| | | } |
| | | |
| | | if (config.getService().getException() != null) { |
| | | createException(Exception.class); |
| | | if (config.getService().getException().getBase() != null) { |
| | | createException(config.getService().getException().getBase()); |
| | | } else { |
| | | createException(ClassInfo.create(Exception.class)); |
| | | } |
| | | } |
| | | |
| | | if (config.getService().getAdminVOPackage() != null) { |
| | | createAdminVO(); |
| | | } |
| | | |
| | | QueryVO queryVO = createQuery(config.getService().getQueryPackage()); |
| | |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.print(getHtmlNameFromEntityName("TTestEEntity")); |
| | | public static void main(String[] args) throws Exception { |
| | | // System.out.print(getHtmlNameFromEntityName("TTestEEntity")); |
| | | // AdminVOVO vo = new AdminVOVO.Builder().setEntity(TestEntity3.class).setPackageName("test.vo.admin").build(); |
| | | // String result = GeneraterUtil.createAdminVO(vo); |
| | | // System.out.println(result); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | import org.yeshi.utils.generater.entity.admin.AdminGeneraterInfo; |
| | | import org.yeshi.utils.generater.vo.ExceptionVO; |
| | | import org.yeshi.utils.generater.vo.admin.controller.AdminControllerInfoVO; |
| | | import org.yeshi.utils.generater.vo.admin.controller.AdminVOVO; |
| | | import org.yeshi.utils.generater.vo.admin.page.FormAddInfoVO; |
| | | import org.yeshi.utils.generater.vo.admin.page.FormUpdateInfoVO; |
| | | import org.yeshi.utils.generater.vo.admin.page.ListInfoVO; |
| | |
| | | return result; |
| | | } |
| | | |
| | | public static String createAdminVO(AdminVOVO vo) throws IOException { |
| | | String result = FreemarkerUtils.generateInputStream(vo, GeneraterUtil.class.getClassLoader().getResourceAsStream("generater/admin/adminVO.template")); |
| | | System.out.println(result); |
| | | return result; |
| | | } |
| | | |
| | | public static String createMongoDBDao(MongoDBDaoVO vo) throws IOException { |
| | | String result = FreemarkerUtils.generateInputStream(vo, GeneraterUtil.class.getClassLoader().getResourceAsStream("generater/dao/mongoDBDao.template")); |
| | | System.out.println(result); |
| | |
| | | |
| | | //显示类型 |
| | | enum ShowType { |
| | | TEXT, IMG,SWITCH; |
| | | TEXT,DATETIME, IMG,SWITCH; |
| | | } |
| | | |
| | | |
| | |
| | | private String columnName; |
| | | private String columnMehtod; |
| | | private String type; |
| | | private String setColumnMehtodName; |
| | | |
| | | |
| | | public ColumnData() { |
| | |
| | | this.columnName = columnName; |
| | | this.type = type; |
| | | this.columnMehtod = "get" + (columnName.subSequence(0, 1) + "").toUpperCase() + columnName.subSequence(1, columnName.length()) + "()"; |
| | | this.setColumnMehtodName = "set" + (columnName.subSequence(0, 1) + "").toUpperCase() + columnName.subSequence(1, columnName.length()); |
| | | } |
| | | |
| | | public String getColumnName() { |
| | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getSetColumnMehtodName() { |
| | | return setColumnMehtodName; |
| | | } |
| | | |
| | | public void setSetColumnMehtodName(String setColumnMehtodName) { |
| | | this.setColumnMehtodName = setColumnMehtodName; |
| | | } |
| | | } |
| | |
| | | FormComponentSelect formComponentSelect = (FormComponentSelect) component; |
| | | if (formComponentSelect.getApi() != null) { |
| | | params.put("apiPath", formComponentSelect.getApi().getPath()); |
| | | if(formComponentSelect.getApi().getParams()!=null) { |
| | | List<KeyValue> list = new ArrayList<>(); |
| | | for (Iterator<String> its = formComponentSelect.getApi().getParams().keySet().iterator(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | |
| | | } |
| | | params.put("apiParams", list); |
| | | } |
| | | } |
| | | |
| | | if (formComponentSelect.getValues() != null) { |
| | | List<KeyValue> list = new ArrayList<>(); |
| | |
| | | * @date 2021/9/23 14:00 |
| | | */ |
| | | public enum FormVerifyType { |
| | | number("数字"), phone("电话号码"), email("邮箱"), date("日期"), url("链接"), identity("身份证"), regex("正则"),none("无验证规则"); |
| | | number("数字"), phone("电话号码"), email("邮箱"), date("日期"),datetime("时间"), url("链接"), identity("身份证"), regex("正则"),none("无验证规则"); |
| | | |
| | | |
| | | private FormVerifyType(String desc) { |
| | |
| | | import org.dom4j.io.SAXReader; |
| | | import org.dom4j.io.XMLWriter; |
| | | import org.dom4j.tree.AbstractAttribute; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | public class ColumnUtil { |
| | | |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @description 根据属性获取sql中的驼峰字段 |
| | | * @date 15:44 2022/3/31 |
| | | * @param: property |
| | | * @return java.lang.String |
| | | **/ |
| | | public static String getColumnFromProperty(String property) { |
| | | StringBuffer buffer = new StringBuffer(); |
| | | List<String> temp = new ArrayList<>(); |
| | | for (int i = 0; i < property.length(); i++) { |
| | | //是否为大写 |
| | | if (property.charAt(i) >= 65 && property.charAt(i) <= 90) { |
| | | temp.add(property.charAt(i) + ""); |
| | | } else { |
| | | //消费之前的 |
| | | if (temp.size() > 0) { |
| | | buffer.append(("_" + StringUtil.concat(temp, "")).toLowerCase()); |
| | | temp.clear(); |
| | | } |
| | | buffer.append(property.charAt(i)); |
| | | } |
| | | } |
| | | |
| | | if (temp.size() > 0) { |
| | | buffer.append(("_" + StringUtil.concat(temp, "")).toLowerCase()); |
| | | temp.clear(); |
| | | } |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | | public static void addColumnToMapper(String path, String columnName, String property, String type) { |
| | | File xmlPath = new File(path); |
New file |
| | |
| | | package org.yeshi.utils.generater.vo.admin.controller; |
| | | |
| | | import org.springframework.data.annotation.Transient; |
| | | import org.yeshi.utils.generater.entity.ClassInfo; |
| | | import org.yeshi.utils.generater.entity.ColumnData; |
| | | |
| | | import java.lang.annotation.Annotation; |
| | | import java.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: AdminVO |
| | | * @description: TODO |
| | | * @date 2022/4/7 18:24 |
| | | */ |
| | | public class AdminVOVO { |
| | | |
| | | private String name; |
| | | private String packageName; |
| | | private ClassInfo entity; |
| | | private List<ColumnData> columns; |
| | | |
| | | public static class Builder { |
| | | private Class entity; |
| | | private String packageName; |
| | | |
| | | public Builder setEntity(Class entity) { |
| | | this.entity = entity; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setPackageName(String packageName) { |
| | | this.packageName = packageName; |
| | | return this; |
| | | } |
| | | |
| | | public AdminVOVO build() throws Exception { |
| | | if (entity == null) { |
| | | throw new Exception("entity不能为空"); |
| | | } |
| | | if (packageName == null) { |
| | | throw new Exception("packageName不能为空"); |
| | | } |
| | | AdminVOVO vo = new AdminVOVO(); |
| | | vo.setEntity(ClassInfo.create(entity)); |
| | | vo.setName(entity.getSimpleName() + "AdminVO"); |
| | | vo.setPackageName(packageName); |
| | | List<ColumnData> columnList = new ArrayList<>(); |
| | | Field[] fields = entity.getDeclaredFields(); |
| | | for (Field fd : fields) { |
| | | //private/public 非final,static属性才会参与解析 |
| | | if (fd.getModifiers() != 1 && fd.getModifiers() != 2) { |
| | | continue; |
| | | } |
| | | boolean valid = true; |
| | | |
| | | Annotation[] as = fd.getAnnotations(); |
| | | for (Annotation a : as) { |
| | | //不参与解析 |
| | | if (a instanceof Transient || a instanceof java.beans.Transient) { |
| | | valid = false; |
| | | break; |
| | | } |
| | | } |
| | | if (!valid) { |
| | | continue; |
| | | } |
| | | |
| | | String property = fd.getName(); |
| | | |
| | | if(property.equalsIgnoreCase("createTime")||property.equalsIgnoreCase("updateTime")){ |
| | | continue; |
| | | } |
| | | |
| | | String type = fd.getType().getSimpleName(); |
| | | ColumnData columnData = new ColumnData(property, type); |
| | | columnList.add(columnData); |
| | | } |
| | | vo.setColumns(columnList); |
| | | return vo; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getPackageName() { |
| | | return packageName; |
| | | } |
| | | |
| | | public void setPackageName(String packageName) { |
| | | this.packageName = packageName; |
| | | } |
| | | |
| | | public ClassInfo getEntity() { |
| | | return entity; |
| | | } |
| | | |
| | | public void setEntity(ClassInfo entity) { |
| | | this.entity = entity; |
| | | } |
| | | |
| | | public List<ColumnData> getColumns() { |
| | | return columns; |
| | | } |
| | | |
| | | public void setColumns(List<ColumnData> columns) { |
| | | this.columns = columns; |
| | | } |
| | | } |
| | |
| | | } |
| | | FormHttpRequestInfoVO requestInfoVO = new FormHttpRequestInfoVO(); |
| | | Map<String, String> apiParams = new HashMap<>(); |
| | | if (row.getParams().get("apiParams") != null) { |
| | | if (((List) row.getParams().get("apiParams")).size() > 0) { |
| | | List<KeyValue> apiParamsList = (List<KeyValue>) row.getParams().get("apiParams"); |
| | | for (KeyValue kv : apiParamsList) { |
| | | apiParams.put(kv.getKey(), kv.getValue()); |
| | | } |
| | | } |
| | | } |
| | | requestInfoVO.setParams(apiParams); |
| | | requestInfoVO.setUrl(apiPath); |
| | | //TODO 暂时固定为post,后面再支持其他的功能 |
| | |
| | | } |
| | | FormHttpRequestInfoVO requestInfoVO = new FormHttpRequestInfoVO(); |
| | | Map<String, String> apiParams = new HashMap<>(); |
| | | if(row.getParams().get("apiParams")!=null) { |
| | | if (((List) row.getParams().get("apiParams")).size() > 0) { |
| | | List<KeyValue> apiParamsList = (List<KeyValue>) row.getParams().get("apiParams"); |
| | | for (KeyValue kv : apiParamsList) { |
| | | apiParams.put(kv.getKey(), kv.getValue()); |
| | | } |
| | | } |
| | | } |
| | | requestInfoVO.setParams(apiParams); |
| | | requestInfoVO.setUrl(apiPath); |
| | | //TODO 暂时固定为post,后面再支持其他的功能 |
| | |
| | | import org.yeshi.utils.generater.entity.admin.AdminGeneraterInfo; |
| | | import org.yeshi.utils.generater.entity.admin.FormRowData; |
| | | import org.yeshi.utils.generater.entity.admin.FormVerifyType; |
| | | import org.yeshi.utils.generater.mybatis.ColumnUtil; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | ListInfoVO vo = new ListInfoVO(); |
| | | vo.setListApi(generaterInfo.getControllerData().getMapping() + "/list"); |
| | | if (generaterInfo.getAddFormRows() != null && generaterInfo.getAddFormRows().size() > 0) { |
| | | vo.setAddPagePath(generaterInfo.getEntity().getSimpleName().toLowerCase() + "_add.html"); |
| | | vo.setAddPagePath(ColumnUtil.getColumnFromProperty(generaterInfo.getEntity().getSimpleName()) + "_add.html"); |
| | | } |
| | | |
| | | if (generaterInfo.getUpdateFormRows() != null && generaterInfo.getUpdateFormRows().size() > 0) { |
| | | vo.setUpdatePagePath(generaterInfo.getEntity().getSimpleName().toLowerCase() + "_update.html"); |
| | | vo.setUpdatePagePath(ColumnUtil.getColumnFromProperty(generaterInfo.getEntity().getSimpleName()) + "_update.html"); |
| | | } |
| | | vo.setSearchFormRows(generaterInfo.getSearchFormRows()); |
| | | vo.setShowFileds(generaterInfo.getShowDataList()); |
| | |
| | | } |
| | | FormHttpRequestInfoVO requestInfoVO = new FormHttpRequestInfoVO(); |
| | | Map<String, String> apiParams = new HashMap<>(); |
| | | if (row.getParams().get("apiParams") != null) { |
| | | if (((List) row.getParams().get("apiParams")).size() > 0) { |
| | | List<KeyValue> apiParamsList = (List<KeyValue>) row.getParams().get("apiParams"); |
| | | for (KeyValue kv : apiParamsList) { |
| | | apiParams.put(kv.getKey(), kv.getValue()); |
| | | } |
| | | } |
| | | } |
| | | requestInfoVO.setParams(apiParams); |
| | | requestInfoVO.setUrl(apiPath); |
| | | //TODO 暂时固定为post,后面再支持其他的功能 |
| | |
| | | import org.yeshi.utils.generater.entity.*; |
| | | import org.yeshi.utils.generater.mybatis.Column; |
| | | import org.yeshi.utils.generater.mybatis.ColumnParseUtil; |
| | | import org.yeshi.utils.generater.mybatis.ColumnUtil; |
| | | import org.yeshi.utils.generater.mybatis.Table; |
| | | import org.yeshi.utils.generater.vo.ExceptionVO; |
| | | import org.yeshi.utils.generater.vo.xmlconfig.dao.DaoData; |
| | |
| | | } |
| | | |
| | | String property = fd.getName(); |
| | | String column = fd.getName(); |
| | | String column = null; |
| | | for (Annotation a : as) { |
| | | //不参与解析 |
| | | if (a instanceof Column) { |
| | | column = ((Column) a).name(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //驼峰写法,首字母小写 |
| | | if (column == null) { |
| | | column = ColumnUtil.getColumnFromProperty(fd.getName()); |
| | | } |
| | | |
| | | MybatisColumnData columData = new MybatisColumnData(column, property, fd.getType().getSimpleName(), ColumnParseUtil.getJDBCType(fd.getType().getName())); |
| | |
| | | |
| | | if (daoData != null) { |
| | | //查询条件从外部传入 |
| | | if (daoData.getQueryList() != null) |
| | | for (DaoQuery query : daoData.getQueryList()) { |
| | | if (query.getName().equalsIgnoreCase(columData.getProperty())) { |
| | | if (fd.getType().getSimpleName().equalsIgnoreCase("Date")) { |
| | |
| | | } else { |
| | | daoQueryColumnList.add(new DaoQueryColumnData(columData.getProperty(), columData, fd.getType().getSimpleName(), query.getQueryType())); |
| | | } |
| | | } else if (query.getName().equalsIgnoreCase(columData.getColumn())) { |
| | | daoQueryColumnList.add(new DaoQueryColumnData(columData.getColumn(), columData, fd.getType().getSimpleName(), query.getQueryType())); |
| | | } |
| | | } |
| | | |
| | |
| | | public void setTable(String table) { |
| | | this.table = table; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import org.yeshi.utils.generater.annotation.admin.DaoQueryCondition; |
| | | import org.yeshi.utils.generater.annotation.admin.Show; |
| | | import org.yeshi.utils.generater.annotation.admin.form.Text; |
| | | import org.yeshi.utils.generater.entity.ClassInfo; |
| | | import org.yeshi.utils.generater.entity.admin.FormVerifyType; |
| | | import org.yeshi.utils.generater.vo.xmlconfig.admin.*; |
| | | import org.yeshi.utils.generater.vo.xmlconfig.admin.form.*; |
| | |
| | | */ |
| | | public class XmlConfigParseUtil { |
| | | |
| | | public static GenertorConfig parse(InputStream inputStream) throws Exception { |
| | | public static GenertorConfig parse(InputStream inputStream, ClassLoader classLoader) throws Exception { |
| | | if (inputStream == null) { |
| | | throw new FileNotFoundException(); |
| | | } |
| | |
| | | } |
| | | Node rootNode = nodelist.item(0); |
| | | String clazz = rootNode.getAttributes().getNamedItem("class").getNodeValue(); |
| | | genertorConfig.setEntity(Class.forName(clazz)); |
| | | genertorConfig.setEntity(classLoader.loadClass(clazz)); |
| | | |
| | | nodelist = rootNode.getChildNodes(); |
| | | for (int i = 0; i < nodelist.getLength(); i++) { |
| | |
| | | genertorConfig.setAdmin(parseAdmin(node)); |
| | | } |
| | | break; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | data.setInterPackage(getNodeAttributeValue(node, "interPackage")); |
| | | data.setImplPackage(getNodeAttributeValue(node, "implPackage")); |
| | | data.setQueryPackage(getNodeAttributeValue(node, "queryPackage")); |
| | | data.setAdminVOPackage(getNodeAttributeValue(node, "adminVOPackage")); |
| | | |
| | | NodeList nodeList = node.getChildNodes(); |
| | | for (int i = 0; i < nodeList.getLength(); i++) { |
| | |
| | | ExceptionData exceptionData = new ExceptionData(); |
| | | exceptionData.setPkg(getNodeAttributeValue(nodeList.item(i), "package")); |
| | | exceptionData.setName(getNodeAttributeValue(nodeList.item(i), "name")); |
| | | String base = getNodeAttributeValue(nodeList.item(i), "base"); |
| | | if (base != null) { |
| | | exceptionData.setBase(new ClassInfo(base.split("\\.")[base.split("\\.").length - 1], base)); |
| | | } |
| | | data.setException(exceptionData); |
| | | break; |
| | | } |
| | |
| | | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | GenertorConfig config = XmlConfigParseUtil.parse(new FileInputStream("D:\\workspace\\server\\utils\\src\\test\\test.xml")); |
| | | GenertorConfig config = XmlConfigParseUtil.parse(new FileInputStream("D:\\workspace\\server\\utils\\src\\test\\test.xml"), null); |
| | | GeneraterManagerV2.getInstance().init("D:\\workspace\\server\\utils\\src\\test\\java", config); |
| | | GeneraterManagerV2.getInstance().createWholeFunction(); |
| | | System.out.println(config); |
| | |
| | | package org.yeshi.utils.generater.vo.xmlconfig.service; |
| | | |
| | | import org.yeshi.utils.generater.entity.ClassInfo; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: ExceptionData |
| | |
| | | |
| | | private String pkg; |
| | | private String name; |
| | | private ClassInfo base; |
| | | |
| | | |
| | | public String getPkg() { |
| | | return pkg; |
| | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public ClassInfo getBase() { |
| | | return base; |
| | | } |
| | | |
| | | public void setBase(ClassInfo base) { |
| | | this.base = base; |
| | | } |
| | | } |
| | |
| | | private String queryPackage; |
| | | private ExceptionData exception; |
| | | |
| | | private String adminVOPackage; |
| | | |
| | | public String getInterPackage() { |
| | | return interPackage; |
| | | } |
| | |
| | | public void setQueryPackage(String queryPackage) { |
| | | this.queryPackage = queryPackage; |
| | | } |
| | | |
| | | public String getAdminVOPackage() { |
| | | return adminVOPackage; |
| | | } |
| | | |
| | | public void setAdminVOPackage(String adminVOPackage) { |
| | | this.adminVOPackage = adminVOPackage; |
| | | } |
| | | } |
| | |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | <link rel="stylesheet" href="./css/font.css"> |
| | | <link rel="stylesheet" href="./css/xadmin.css"> |
| | | <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="./js/xadmin.js"></script> |
| | | <script src="js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <link rel="stylesheet" href="../css/font.css"> |
| | | <link rel="stylesheet" href="../css/xadmin.css"> |
| | | <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../js/xadmin.js"></script> |
| | | <script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="../js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> |
| | | <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> |
| | | <!--[if lt IE 9]> |
| | |
| | | </script> |
| | | |
| | | <script> |
| | | layui.use(['form', 'layer', 'jquery', 'upload'], function () { |
| | | layui.use(['form', 'layer', 'jquery', 'upload', 'laydate'], function () { |
| | | $ = layui.jquery; |
| | | var form = layui.form, |
| | | layer = layui.layer, |
| | | upload = layui.upload; |
| | | upload = layui.upload, |
| | | laydate = layui.laydate; |
| | | |
| | | var verify = {}; |
| | | <#list regexVerifyList as regex> |
| | |
| | | //渲染上传控件 |
| | | uploadTool.init(upload); |
| | | |
| | | <#list rowsList as row > |
| | | <#if (row.type=="Text" && (row.params.inputType=="DATE"||row.params.inputType=="DATETIME"))> |
| | | laydate.render({ |
| | | elem: "intput[name=${row.key}]", //指定元素 |
| | | type: ${row.params.inputType?lower_case} |
| | | }); |
| | | </#if> |
| | | </#list> |
| | | |
| | | |
| | | //监听提交 |
| | | form.on('submit(add)', |
New file |
| | |
| | | package ${packageName}; |
| | | |
| | | import org.yeshi.utils.TimeUtil; |
| | | import ${entity.clazz}; |
| | | |
| | | import java.util.Date; |
| | | |
| | | public class ${name} { |
| | | <#list columns as column > |
| | | <#if column.type=='Date'> |
| | | private String ${column.columnName}; |
| | | <#elseif column.type=='Boolean'> |
| | | private String ${column.columnName}; |
| | | <#else> |
| | | private ${column.type} ${column.columnName}; |
| | | </#if> |
| | | </#list> |
| | | |
| | | public ${entity.name} toEntity(SystemEnum system) { |
| | | ${entity.name} entity = new ${entity.name}(); |
| | | <#list columns as column > |
| | | <#if column.type=='Date'> |
| | | entity.${column.setColumnMehtodName}(new Date(TimeUtil.convertToTimeTemp(${column.columnName}, "yyyy-MM-dd HH:mm:ss"))); |
| | | <#elseif column.type=='Boolean'> |
| | | entity.${column.setColumnMehtodName}("on".equalsIgnoreCase(${column.columnName}) ? true : false); |
| | | <#else> |
| | | entity.${column.setColumnMehtodName}(${column.columnName}); |
| | | </#if> |
| | | </#list> |
| | | return entity; |
| | | } |
| | | |
| | | |
| | | public static ${name} create(${entity.name} entity) { |
| | | ${name} vo = new ${name}(); |
| | | <#list columns as column > |
| | | <#if column.type=='Date'> |
| | | vo.${column.setColumnMehtodName}(TimeUtil.getGernalTime(entity.${column.columnMehtod}.getTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | <#elseif column.type=='Boolean'> |
| | | vo.${column.setColumnMehtodName}(entity.${column.columnMehtod} ? "on" : null); |
| | | <#else> |
| | | vo.${column.setColumnMehtodName}(entity.${column.columnMehtod}); |
| | | </#if> |
| | | </#list> |
| | | return vo; |
| | | } |
| | | |
| | | <#list columns as column > |
| | | <#if column.type=='Date'> |
| | | public String ${column.columnMehtod} { |
| | | return ${column.columnName}; |
| | | } |
| | | |
| | | public void ${column.setColumnMehtodName}(String ${column.columnName}) { |
| | | this.${column.columnName} = ${column.columnName}; |
| | | } |
| | | <#elseif column.type=='Boolean'> |
| | | public String ${column.columnMehtod} { |
| | | return ${column.columnName}; |
| | | } |
| | | |
| | | public void ${column.setColumnMehtodName}(String ${column.columnName}) { |
| | | this.${column.columnName} = ${column.columnName}; |
| | | } |
| | | <#else> |
| | | public ${column.type} ${column.columnMehtod} { |
| | | return ${column.columnName}; |
| | | } |
| | | |
| | | public void ${column.setColumnMehtodName}(${column.type} ${column.columnName}) { |
| | | this.${column.columnName} = ${column.columnName}; |
| | | } |
| | | </#if> |
| | | </#list> |
| | | |
| | | } |
| | |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | <link rel="stylesheet" href="./css/font.css"> |
| | | <link rel="stylesheet" href="./css/xadmin.css"> |
| | | <script src="./lib/layui/layui.js" charset="utf-8"></script> |
| | | <link rel="stylesheet" href="./css/theme3049.min.css"> |
| | | <script src="./js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="./js/xadmin.js"></script> |
| | | <script src="./js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <link rel="stylesheet" href="../css/font.css"> |
| | | <link rel="stylesheet" href="../css/xadmin.css"> |
| | | <script src="../lib/layui/layui.js" charset="utf-8"></script> |
| | | <link rel="stylesheet" href="../css/theme3049.min.css"> |
| | | <script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../js/xadmin.js"></script> |
| | | <script src="../js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> |
| | | <!--[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]--> |
| | | <script src="./js/utils.js"></script> |
| | | <script src="../js/utils.js"></script> |
| | | </head> |
| | | |
| | | <body> |
| | |
| | | |
| | | <script> |
| | | var tableIns = null; |
| | | var app=null; |
| | | $(function () { |
| | | |
| | | var app = new Vue({ |
| | | app = new Vue({ |
| | | el: "#app", |
| | | data: { |
| | | key: '', |
| | |
| | | <#list searchFormRows as row > |
| | | <#if (row.type=="Text" && row.params.inputType=="DATE")> |
| | | laydate.render({ |
| | | elem: "intput[name=${row.key}]" //指定元素 |
| | | elem: "input[name=${row.key}]" //指定元素 |
| | | }); |
| | | </#if> |
| | | </#list> |
| | |
| | | <#list showFileds as field > |
| | | <#if field.showType=='TEXT'> |
| | | {field: '${field.identifier}', width: 120, sort: false, title: "${field.title}"}, |
| | | <#elseif field.showType=='DATETIME'> |
| | | {field: '${field.identifier}', width: 150, sort: false, title: "${field.title}"}, |
| | | <#elseif field.showType=='SWITCH'> |
| | | {field: '${field.identifier}', width: 120, sort: false, title: "${field.title}",templet:function(res){ |
| | | {field: '${field.identifier}', width: 80, sort: false, title: "${field.title}",templet:function(res){ |
| | | if(res.${field.identifier}){ |
| | | return " <input type=\"checkbox\" checked='true' disabled lay-skin=\"switch\""; |
| | | }else{ |
| | |
| | | if (res.code == 0) { |
| | | //填充数据 |
| | | $("${request.fillTarget}").empty(); |
| | | $("${request.fillTarget}").append("<option value=''>请选择</option>"); |
| | | for (var i = 0; i < res.data.length; i++) { |
| | | var html = "<option value='" + res.data[i].key + "'>"; |
| | | html += res.data[i].value + "</option>"; |
| | |
| | | }, |
| | | </#if> |
| | | search: function (params) { |
| | | |
| | | var ps = {}; |
| | | for (var key in params) { |
| | | if (params[key].length > 0) { |
| | | ps[key] = params[key]; |
| | | } |
| | | } |
| | | //数据重载 |
| | | tableIns.reload({ |
| | | where: params, |
| | | where: ps, |
| | | page: { |
| | | curr: 1 //重新从第 1 页开始 |
| | | } |
| | |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | <link rel="stylesheet" href="./css/font.css"> |
| | | <link rel="stylesheet" href="./css/xadmin.css"> |
| | | <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="./js/xadmin.js"></script> |
| | | <script src="js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <link rel="stylesheet" href="../css/font.css"> |
| | | <link rel="stylesheet" href="../css/xadmin.css"> |
| | | <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../js/xadmin.js"></script> |
| | | <script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="../js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> |
| | | <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> |
| | | <!--[if lt IE 9]> |
| | |
| | | </script> |
| | | |
| | | <script> |
| | | layui.use(['form', 'layer', 'jquery', 'upload'], function () { |
| | | layui.use(['form', 'layer', 'jquery', 'upload','laydate'], function () { |
| | | $ = layui.jquery; |
| | | var form = layui.form, |
| | | layer = layui.layer, |
| | | upload = layui.upload; |
| | | upload = layui.upload, |
| | | laydate= layui.laydate; |
| | | |
| | | var verify = {}; |
| | | <#list regexVerifyList as regex> |
| | |
| | | //自定义验证规则 |
| | | form.verify(verify); |
| | | |
| | | <#list rowsList as row > |
| | | <#if (row.type=="Text" && (row.params.inputType=="DATE"||row.params.inputType=="DATETIME"))> |
| | | laydate.render({ |
| | | elem: "intput[name=${row.key}]", //指定元素 |
| | | type: ${row.params.inputType?lower_case} |
| | | }); |
| | | </#if> |
| | | </#list> |
| | | |
| | | //渲染上传控件 |
| | | uploadTool.init(upload); |
| | | |
| | |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <#list columnList as column> |
| | | <#noparse>#{</#noparse>${column.property}},jdbcType=${column.jdbcType}}, |
| | | <#noparse>#{</#noparse>${column.property},jdbcType=${column.jdbcType}}, |
| | | </#list> |
| | | |
| | | </trim> |
| | |
| | | <!ATTLIST service interPackage CDATA #REQUIRED> |
| | | <!ATTLIST service implPackage CDATA #REQUIRED> |
| | | <!ATTLIST service queryPackage CDATA #REQUIRED> |
| | | <!ATTLIST service adminVOPackage CDATA #IMPLIED> |
| | | |
| | | |
| | | <!ELEMENT exception EMPTY> |
| | | <!ATTLIST exception package CDATA #REQUIRED> |
| | | <!ATTLIST exception name CDATA #IMPLIED> |
| | | <!ATTLIST exception base CDATA #IMPLIED> |
| | | |
| | | |
| | | <!--表单配置信息 --> |
| | |
| | | <!ATTLIST column property CDATA #REQUIRED> |
| | | <!ATTLIST column title CDATA #REQUIRED> |
| | | <!ATTLIST column order CDATA "0"> |
| | | <!ATTLIST column showType (TEXT|IMG|SWITCH) #IMPLIED> |
| | | <!ATTLIST column showType (TEXT|DATETIME|IMG|SWITCH) #IMPLIED> |
| | | <!ATTLIST column imgWidth CDATA "-1"> |
| | | <!ATTLIST column imgHeight CDATA "-1"> |
| | | |
| | |
| | | |
| | | |
| | | <!ELEMENT verify EMPTY> |
| | | <!ATTLIST verify type (number|phone|email|date|url|identity|regex|none) #REQUIRED> |
| | | <!ATTLIST verify type (number|phone|email|date|datetime|url|identity|regex|none) #REQUIRED> |
| | | <!ATTLIST verify express CDATA #IMPLIED> |
| | | <!ATTLIST verify notify CDATA #IMPLIED> |
| | | <!ATTLIST verify require (true|false) #IMPLIED> |