1 Star 0 Fork 40

陈彬 / 老成FMS-UI代码在线生成器

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

一、环境与安装

tomcat 8.0+,jdk1.8+,根目录的数据库文件导入到mysql中,并修改资源包resource中的lcfms.properties保存相应的数据库名,用户名,密码即可启动。 QQ交流群:348455534

二、基础框架

底层是大家再熟悉不过的SSM,上手很容易,特别是如果你只需要使用“UI在线生成器”的时候,运行 http://localhost:8080/admin 可以看到顶部导航的右边就是“UI在线生成器”的链接。

三、老成FMS介绍

老成FMS是一个相对重量级的集成快速开发框架,前端后台数据库乃至业务都有一定的耦合度,后台使用大家再熟悉不过的JAVA SSM,前端有bootstrap,layui等。当然快速框架常用的功能都会有的,比如说栏目管理啦,用户管理啦,用户组及权限管理啦,CMS啦,生成静态页面啦等等。但这些都不是老成FMS与众不同的地方,下面我说说他的特别之处:

  1. 通用Service动态生成sql,其实就跟mybatis-plus类似,增删改查直接使用对象方法。但我觉得比mybatis-plus还更方便一些,0接口,0配置。具体类是cn.lcfms.bin.BaseService,功能保证强大,有兴趣的同学可以去看一看,支持直接传入sql语句,支持事务处理,下面有使用文档。
  2. 通用的增删改查页面,什么意思?你难道没有发现,项目每次增加一个业务,你就要复制几张jsp页面,大部分地方不变,少数几个地方修修改改,现在这些复制粘贴的地方你都可以不用写了,只需要后台传参数,有一个通用的页面,满足绝大多数功能。具体类都在cn.lcfms.bin.view这个包里。
  3. 当然万事无绝对,你的页面太复杂,通用页面满足不了,你只能老老实实写jsp,但FMS提供了前端代码生成功能,你不用再去下载调试demo,配置好参数,html代码自动生成。

四、关于路由

/WEB-INF/web.xml中可以配制你的默认路由,这里访问域名默认就跳转到/mobile/index/init,访问/admin就跳转到/admin/index/ace。很简单。

 <filter>
    <filter-name>defaultPage</filter-name>
    <filter-class>cn.lcfms.bin.DefaultPageFilter</filter-class>
    <init-param>
      <param-name>/</param-name>
      <param-value>/mobile/index/init</param-value>
    </init-param>
    <init-param>
      <param-name>/admin</param-name>
      <param-value>/admin/index/ace</param-value>
    </init-param>
  </filter>

五、关于调试

在lcfms.properties中设置,如果debug.on为true时,后台是不需要登录的,会默认使用下面配制的用户登录,还有很重要的,调试模式下,不能使用生成静态页面并获取缓存

	debug.on=true
    debug.aid=23
    debug.aname=测试用户
    debug.gid=1

六、使用教程

1、视频教程

20分钟完成增删改查并自动编写页面(必看)

2、BaseService操作手册(详见cn.lcfms.test.ServiceTest)
	/* 执行添加操作,参数是按顺序传递,其中id为主键,如果有主键会自动在sql中生成并为它赋值,所以参数里不必要有主键
	 * sql:INSERT INTO `demo` (`id`,`s`,`i`,`t`) VALUES (?,?,?,?) 
	 * param:9(Integer), abc(String), 1(Integer), a(String)
	 */
	public void t1(){		
		BaseService service = App.getService("demo");			
		service.setData("abc",1,'a').insert("s","i","t");
		//最近一次插入操作的自增id
		int insert_id = service.insert_id();
		System.out.println(insert_id);
	}
	/* 执行添加操作,参数是按map的key进行匹配
	 * 这里注意了,javabean中存在且表中也存在的字段,但值为空或者为0,将一起被添加,如果不想被添加,可以使用service.insert(t, filter),其中filter为你不想修改的字段,多个字段用逗号隔开
	 * sql:INSERT INTO `demo` (`id`,`s`,`i`,`t`) VALUES (?,?,?,?) 
	 * param:10(Integer), abcde(String), 1(Integer), s(String)
	 */
	public void t2(){		
		BaseService service = App.getService("demo");	
		HashMap<String, Object> map=new HashMap<>();
		map.put("t", 's');
		map.put("i", 1);
		map.put("s", "abcde");
		service.setData(map).insert("s","i","t");
		//最近一次插入操作的自增id
		int insert_id = service.insert_id();
		System.out.println(insert_id);
	}
	/* 添加一个实体对象到数据库,参数自动匹配“表的字段名”与“实体的属性名”,匹配成功的属性将提交到数据库
	 * sql:INSERT INTO `demo` (`id`,`s`,`i`,`t`) VALUES (?,?,?,?) 
	 * param:11(Integer), aaa(String), 5(Integer), n(String)
	 */
	public void t3(){		
		BaseService service = App.getService("demo");	
		DemoBean demo=new DemoBean();
		demo.setI(5);	
		demo.setS("aaa");
		demo.setT("n");
		service.insert(demo);
		//自增的主键id将自动映射到实体属性中
		System.out.println(demo.getId());
	}
	/* 执行删除操作
	 * sql:DELETE FROM `demo` WHERE (`id`=?) 
	 * param:1(Integer)
	 */
	public void t4(){		
		BaseService service = App.getService("demo");		
		//where("id=1")也可以,但如果1是变量的话不建议使用字符串拼接,不安全容易被注入
		service.where("`id`=#{id}").setData(1).delete();
		//最近一次sql操作影响的行数
		int affected_rows = service.affected_rows();
		System.out.println(affected_rows);
	}
	/* 根据主键id执行删除操作
	 * sql:DELETE FROM `demo` WHERE (`id`=?)
	 * param:27(Integer)
	 */
	public void t5(){		
		BaseService service = App.getService("demo");	
		//直接传主键id的值,程序会自动获取主键名并删除行
		service.deleteById(27);
		//最近一次sql操作影响的行数
		int affected_rows = service.affected_rows();
		System.out.println(affected_rows);
	}
	/* 执行修改操作,参数会按setData的顺序读取,条件参数要写在结尾,当然如果你用参数改用hashmap,可以自动匹配key的值,不需要考虑顺序
	 * sql:UPDATE `demo` SET `s`=?,`i`=?,`t`=? WHERE (`id`=?) 
	 * param:abc(String), 123(Integer), m(String), 15(Integer)
	 */
	public void t6(){		
		BaseService service = App.getService("demo");	
		service.where("id=#{id}").setData("abc",123,'m',15).update("s","i","t");
	}
	/* 根据实体对象保存修改,系统会根据属性自动匹配主键以及被修改的字段名
	 * 这里注意了,javabean中存在且表中也存在的字段,但值为空或者为0,将一起被修改,如果不想被修改,可以使用service.update(t, filter),其中filter为你不想修改的字段,多个字段用逗号隔开
	 * sql:UPDATE `demo` SET `id`=?,`s`=?,`i`=?,`t`=? WHERE (`id`=?) 
	 * param:13(Integer), aaa(String), 5(Integer), null, 13(Integer)
	 */	
	public void t7(){		
		BaseService service = App.getService("demo");	
		DemoBean demo=new DemoBean();		
		demo.setI(5);	
		demo.setS("aaa");
		demo.setId(13);
		service.update(demo);			
	}
	/*
	 * 执行各种查询方法,可以使用Vardump.print()方法打印结果
	 */
	public void t8(){	
		BaseService service = App.getService("demo");
		//查询一张表,返回List结果集
		List<HashMap<String, Object>> list = service.selectList();
		Vardump.print(list);
		//查询一张表满足条件的第一行的某一个字段,返回该字段的值
		int i=service.selectColumn("i"); 
		System.out.println(i);
		//查询满足条件的行数,返回行数int类型
		int count=service.selectCount();
		System.out.println(count);
		//查询一个javabean,返回该javabean对象
		DemoBean bean=service.selectOne(DemoBean.class, 15);
		Vardump.print(bean);
		//查询满足条件的第一个map,返回hashmap
		HashMap<String, Object> map = service.selectMap();
		Vardump.print(map);
		//查询一个分页数据,返回List结果集,其中字段count表示满足该分页的总行数
		List<HashMap<String, Object>> pagedata = service.selectPage(15, 1);	
		Vardump.print(pagedata);
	}
	/*
	 * 复杂查询的sql组成
	 * sql:SELECT `s`,`i`,`t` FROM `demo` WHERE (`s`=?) AND (id>?) AND (i<>?) AND (t!='s' or t!='o') GROUP BY `id` ORDER BY `id` ASC LIMIT 0,10 
	 * param:abc(String), 20, 15(Integer)
	 */
	public void t9(){	
		BaseService service = App.getService("demo");
		//查询的字段,支持大小写的as或者空格的别名以及sql函数
		service.column("s","i","t");
		service.column("id as ID");
		service.column("left(s,5) as ls");
		//多条件拼装,支持in,between,like,or或者条件字符串
		service.where("id>#{id}");
		service.where("s", "abc");
		service.where("i", "<>", 15);
		service.where("t!='s' or t!='o'");
		//设置动态参数
		service.setData(20);
		//limit拼装
		service.limit(0, 10);
		//order by拼装,默认是asc排序,使用desc可以service.order("id desc");
		service.order("id");
		//group by拼装
		service.groupBy("id");
		//执行查询,除了selectList()当然也支持其他的查询方法
		service.selectList();
	}
	/*
	 * 多表查询,可以使用join方法
	 * 不支持多表连查(select * from table1,table2),如果要多表连查,推荐使用sql()方法
	 */
	public void t10() {
		BaseService service = App.getService("demo");
		//查询多张表的多个字段
		service.column("demo.id as id","demo.s as s","admin.aid as aid");
		service.leftJoin("admin").on("demo.id=admin.aid");
		service.selectList();
		//也可以给表添加别名,可以用setTable()方法,也可以用App.getService("demo d");
		service.setTable("demo d");
		service.column("d.id as id","d.s as s","a.aid as aid");
		service.column("left(d.s,5) as ls");
		service.leftJoin("admin a").on("d.id=a.aid");
		service.selectList();
	}
	/*
	 * 支持函数式编程回调操作,不会用的的可以去看看java8.0的新特性lambda表达式
	 */
	public void t11() {
		BaseService service = App.getService("demo");
		//将id大于10的结果修改为id等于1,不大于的修改为id等于0
		service.column("id",(Object obj)->{
			int id=(int)obj;
			if(id>10) {
				return 1;
			}
			return 0;
		});
		service.selectList();
	}	
	/*
	 * 支持事务处理,同样使用lambda表达式
	 */
	public void t12() {
		BaseService service=App.getService("demo");
		service.transaction(()->{		
			service.setData("abc666").insert("s");		
			service.setData("abc77777777777777777").insert("s");
		});
	}	
	/* 
	 * 直接传入sql操作,支持使用setData()方法传入动态参数,动态参数必须使用#{参数名},不支持?
	 */
	public void t18(){	
		BaseService service = App.getService("demo");	
		service.setData(2).sql("select * from demo where id>#{id} limit 0,1");
		//使用getResult()方法获取最近一次查询的结果集
		List<HashMap<String, Object>> result = service.getResult();
		Vardump.print(result);	
		//也可以查看当前sql操作的所有信息,包括sql语句,参数,结果集等等
		SqlBuild sqlBuild = service.getSqlBuild();
		Vardump.print(sqlBuild);			
	}	
	/* 
	 * 也可以多次使用sql操作,然后统一查看结果
	 */	
	public void t19(){	
		BaseService service = App.getService("demo");	
		//这里如果有主键,且没有设置为自增,记得要给主键赋值,可以使用getKeyValue()方法来自动获取一个值
		service.setData(service.getKeyValue(),"abc",15,'b').sql("INSERT INTO `demo` (`id`,`s`,`i`,`t`) VALUES (#{id},#{s},#{i},#{t})");	
		service.sql("DELETE FROM `demo` WHERE `id`=5");
		service.setData(2).sql("select * from demo where id>#{id} limit 0,1");
		SqlBuild[] list = service.getSqlBuildList();
		Vardump.print(list);	
	}	
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2017 老成有木有 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

快速生成前端代码 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/ffffxx_admin/lcfms.git
git@gitee.com:ffffxx_admin/lcfms.git
ffffxx_admin
lcfms
老成FMS-UI代码在线生成器
master

搜索帮助