├── .settings ├── org.eclipse.wst.jsdt.ui.superType.name ├── org.eclipse.wst.jsdt.ui.superType.container ├── org.eclipse.wst.common.project.facet.core.xml ├── .jsdtscope ├── org.eclipse.jdt.core.prefs ├── org.eclipse.wst.common.component ├── org.eclipse.core.resources.prefs ├── com.genuitec.eclipse.j2eedt.core.prefs └── com.genuitec.eclipse.j2eedt.ui.prefs ├── src └── main │ ├── webapp │ ├── META-INF │ │ └── MANIFEST.MF │ ├── WEB-INF │ │ ├── lib │ │ │ ├── asm-5.0.2.jar │ │ │ ├── gson-2.2.4.jar │ │ │ ├── ognl-3.0.6.jar │ │ │ ├── kaptcha-2.3.2.jar │ │ │ ├── log4j-1.2.17.jar │ │ │ ├── asm-tree-5.0.2.jar │ │ │ ├── commons-io-2.2.jar │ │ │ ├── asm-commons-5.0.2.jar │ │ │ ├── commons-lang3-3.2.jar │ │ │ ├── freemarker-2.3.19.jar │ │ │ ├── xwork-core-2.3.20.jar │ │ │ ├── javassist-3.11.0.GA.jar │ │ │ ├── struts2-core-2.3.20.jar │ │ │ ├── commons-fileupload-1.3.1.jar │ │ │ └── mysql-connector-java-5.1.38-bin.jar │ │ └── web.xml │ ├── css │ │ ├── login.css │ │ ├── common │ │ │ └── custom.css │ │ └── main.css │ ├── plugins │ │ ├── bootstrap-3.3.2 │ │ │ ├── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ └── js │ │ │ │ └── npm.js │ │ ├── angularjs │ │ │ └── angular-route.min.js │ │ └── security │ │ │ └── sha1.js │ ├── view │ │ ├── welcome.html │ │ ├── about.html │ │ ├── apply.html │ │ ├── pay.html │ │ ├── review.html │ │ └── billforin.html │ ├── js │ │ ├── view │ │ │ ├── welcome.js │ │ │ ├── about.js │ │ │ ├── apply.js │ │ │ ├── pay.js │ │ │ ├── review.js │ │ │ ├── user.js │ │ │ ├── billforin.js │ │ │ └── billforout.js │ │ ├── login.js │ │ └── main.js │ ├── error │ │ ├── error.jsp │ │ ├── nopower.jsp │ │ └── notfound.jsp │ └── index.html │ ├── resources │ ├── jdbc.properties │ ├── log4j.properties │ └── struts.xml │ └── java │ └── com │ └── ming │ ├── util │ ├── ID.java │ ├── Permission.java │ ├── Validate.java │ ├── ConsoleMessage.java │ ├── KaptchaUtil.java │ ├── Condition.java │ ├── IllegalCharacterInterceptor.java │ ├── PermissionInterceptor.java │ ├── DataUtil.java │ ├── DataSecurity.java │ ├── CommonFilter.java │ ├── MailUtil.java │ ├── HtmlUtil.java │ ├── WebUtil.java │ └── SqlUtil.java │ ├── entity │ ├── Role.java │ ├── Page.java │ ├── Permission.java │ ├── Menu.java │ ├── Message.java │ ├── BillForIn.java │ ├── BillForOut.java │ └── User.java │ ├── service │ ├── IMenuService.java │ ├── IPageService.java │ ├── IRoleService.java │ ├── IUserService.java │ ├── IMessageService.java │ ├── IPermissionService.java │ ├── IBillForInService.java │ ├── IBillForOutService.java │ ├── MenuService.java │ ├── PageService.java │ ├── RoleService.java │ ├── UserService.java │ ├── MessageService.java │ ├── PermissionService.java │ └── BillForInService.java │ ├── dao │ └── BaseDao.java │ └── action │ ├── RoleAction.java │ ├── MenuAction.java │ └── BillForInAction.java ├── README.md ├── .classpath └── .project /.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/asm-5.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/asm-5.0.2.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/gson-2.2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/gson-2.2.4.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/ognl-3.0.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/ognl-3.0.6.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/kaptcha-2.3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/kaptcha-2.3.2.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/log4j-1.2.17.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/log4j-1.2.17.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/asm-tree-5.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/asm-tree-5.0.2.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/commons-io-2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/commons-io-2.2.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/asm-commons-5.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/asm-commons-5.0.2.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/commons-lang3-3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/commons-lang3-3.2.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/freemarker-2.3.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/freemarker-2.3.19.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/xwork-core-2.3.20.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/xwork-core-2.3.20.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/javassist-3.11.0.GA.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/javassist-3.11.0.GA.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/struts2-core-2.3.20.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/struts2-core-2.3.20.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/commons-fileupload-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/commons-fileupload-1.3.1.jar -------------------------------------------------------------------------------- /src/main/webapp/css/login.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | body { 4 | padding-top: 20px; 5 | } 6 | .desktop-fixed { 7 | height: 80px; 8 | } 9 | 10 | /* By Ming */ 11 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.38-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.38-bin.jar -------------------------------------------------------------------------------- /src/main/webapp/plugins/bootstrap-3.3.2/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/plugins/bootstrap-3.3.2/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/main/webapp/plugins/bootstrap-3.3.2/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/plugins/bootstrap-3.3.2/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/main/webapp/plugins/bootstrap-3.3.2/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/plugins/bootstrap-3.3.2/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/main/webapp/plugins/bootstrap-3.3.2/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingslife/MoneyManager/HEAD/src/main/webapp/plugins/bootstrap-3.3.2/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MoneyManager 2 | 财务管理系统 3 | 4 | ## 简介 5 | 该项目是我大二项目期间空闲时间写的,写写停停用了半年时间,当时是我初学Bootstrap前端框架, 后端用的是Struts2,数据库持久化部分是自己写的(数据库连接池是别人网上的代码,然后再修改的),后来又做了一些修改,不过代码没有托管,然后电脑在这个学期被偷了(大三下学期),所以都没了,这份代码是我突然想起来我在我服务器SVN上放了一份,虽然不是最新,但至少还是幸存下来了。 6 | -------------------------------------------------------------------------------- /src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | # By Ming 2 | # 2015-02-21 3 | driverName=com.mysql.jdbc.Driver 4 | url=jdbc\:mysql\://localhost\:3306/moneymanager 5 | username=root 6 | password=root 7 | maxActive=50 8 | maxIdle=10 9 | maxWait=10000 10 | -------------------------------------------------------------------------------- /src/main/webapp/css/common/custom.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | body { 4 | font-family: "Microsoft Yahei",微软雅黑,"Microsoft JhengHei",华文细黑,STHeiti,MingLiu; 5 | } 6 | th { 7 | text-align: center; 8 | } 9 | td { 10 | white-space: nowrap; 11 | overflow: hidden; 12 | text-overflow: ellipsis; 13 | } 14 | 15 | /* By Ming */ 16 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/ID.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 主键注解 10 | * @author Ming 11 | * @description 作为数据库表主键的注解 12 | * @date 2015-03-12 13 | */ 14 | @Target (ElementType.FIELD) 15 | @Retention (RetentionPolicy.RUNTIME) 16 | public @interface ID { 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/Permission.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 登录验证方法注解 10 | * @author Ming 11 | * @description 进行Struts2登录验证方法的注解 12 | * @date 2015-03-15 13 | */ 14 | @Target (ElementType.METHOD) 15 | @Retention (RetentionPolicy.RUNTIME) 16 | public @interface Permission { 17 | } 18 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/webapp/view/welcome.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

欢迎使用财务管理系统

5 |

您好,超级管理员

6 |

您有条未审核的报账申请,合计金额

7 |

您有条未支付的报账记录,合计金额

8 |
9 |
10 |
11 | 12 | -------------------------------------------------------------------------------- /src/main/webapp/plugins/bootstrap-3.3.2/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/webapp/css/main.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | body { 4 | padding-top: 75px; 5 | } 6 | .navbar-right .btn-group { 7 | margin-right: 10px; 8 | } 9 | .jumbotron h1 { 10 | margin-bottom: 30px; 11 | } 12 | .toolbar { 13 | margin-bottom: 10px; 14 | } 15 | .toolbar label { 16 | margin-left: 10px; 17 | } 18 | .search { 19 | margin-left: 5px; 20 | } 21 | .sum span { 22 | margin-right: 20px; 23 | } 24 | .page { 25 | height: 34px; 26 | margin-right: 10px; 27 | line-height: 34px; 28 | } 29 | .footer { 30 | height: 60px; 31 | margin-top: 30px; 32 | padding-top: 20px; 33 | background-color: #eee; 34 | } 35 | #replyContent { 36 | height: 100px; 37 | resize: none; 38 | } 39 | 40 | /* By Ming */ 41 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/webapp/error/error.jsp=UTF-8 3 | encoding//src/main/webapp/error/nopower.jsp=UTF-8 4 | encoding//src/main/webapp/error/notfound.jsp=UTF-8 5 | encoding//src/main/webapp/js/view/apply.js=UTF-8 6 | encoding//src/main/webapp/view=UTF-8 7 | encoding//src/main/webapp/view/about.html=UTF-8 8 | encoding//src/main/webapp/view/apply.html=UTF-8 9 | encoding//src/main/webapp/view/billforin.html=UTF-8 10 | encoding//src/main/webapp/view/billforout.html=UTF-8 11 | encoding//src/main/webapp/view/pay.html=UTF-8 12 | encoding//src/main/webapp/view/review.html=UTF-8 13 | encoding//src/main/webapp/view/user.html=UTF-8 14 | encoding//src/main/webapp/view/welcome.html=UTF-8 15 | encoding/=UTF-8 16 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/Validate.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | 4 | /** 5 | * 验证类 6 | * @author Ming 7 | * @description 验证数据合法性,未完工 8 | * @date 2015-02-21 9 | */ 10 | public class Validate { 11 | /** 12 | * 验证字符串 13 | * @param value 待验证的数据 14 | * @return 结果 15 | */ 16 | public static String string(String value) { 17 | if (value != null) 18 | return value.trim(); 19 | else 20 | return null; 21 | } 22 | 23 | /** 24 | * 验证字符串(带长度验证) 25 | * @param value 待验证的数据 26 | * @param length 长度 27 | * @return 结果 28 | */ 29 | public static String string(String value, int length) { 30 | value = string(value); 31 | if (value != null && value.length() <= length) 32 | return value; 33 | else 34 | return null; 35 | } 36 | 37 | // TODO 未完待续 38 | } 39 | -------------------------------------------------------------------------------- /src/main/webapp/js/view/welcome.js: -------------------------------------------------------------------------------- 1 | app.controller("welcomeController", function($scope) { 2 | $scope.init = function() { 3 | $.ajax({ 4 | url: "user_welcome.action", 5 | type: "POST", 6 | dataType: "json", 7 | data: {}, 8 | beforeSend: function() {}, 9 | complete: function() {}, 10 | success: function(data) { 11 | $scope.userName = data.userName; 12 | $scope.numberOfUncheck = data.numberOfUncheck; 13 | $scope.amountOfUncheck = data.amountOfUncheck; 14 | $scope.numberOfUnpaid = data.numberOfUnpaid; 15 | $scope.amountOfUnpaid = data.amountOfUnpaid; 16 | $scope.$apply(); 17 | if (data.result) 18 | alert(data.result); 19 | }, 20 | error: function() { 21 | alert("请求错误"); 22 | } 23 | }); 24 | }; 25 | $scope.init(); 26 | }); 27 | /* By Ming */ 28 | -------------------------------------------------------------------------------- /src/main/java/com/ming/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.ming.entity; 2 | 3 | import com.ming.util.ID; 4 | 5 | /** 6 | * 7 | * @author Ming 8 | * @description 9 | * @date 2015-03-12 10 | */ 11 | public class Role { 12 | @ID 13 | private Integer roleId; 14 | private String roleName; 15 | 16 | public Integer getRoleId() { 17 | return roleId; 18 | } 19 | 20 | public void setRoleId(Integer roleId) { 21 | this.roleId = roleId; 22 | } 23 | 24 | public String getRoleName() { 25 | return roleName; 26 | } 27 | 28 | public void setRoleName(String roleName) { 29 | this.roleName = roleName; 30 | } 31 | 32 | public Role() { 33 | } 34 | 35 | public Role(Integer roleId) { 36 | this.roleId = roleId; 37 | } 38 | 39 | public Role(Integer roleId, String roleName) { 40 | this.roleId = roleId; 41 | this.roleName = roleName; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/IMenuService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.entity.Menu; 7 | 8 | public interface IMenuService { 9 | public List> load(); 10 | public List> load(String condition); 11 | public List> load(String[] params, String condition); 12 | public List> load(String[] params, String condition, int curPage, int limit); 13 | public Map loadOne(String condition); 14 | public Map loadOne(String[] params, String condition); 15 | public boolean save(Menu obj); 16 | public boolean update(Menu obj); 17 | public boolean delete(Menu obj); 18 | public boolean deleteByCondition(String condition); 19 | public int count(); 20 | public int count(String condition); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/IPageService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.entity.Page; 7 | 8 | public interface IPageService { 9 | public List> load(); 10 | public List> load(String condition); 11 | public List> load(String[] params, String condition); 12 | public List> load(String[] params, String condition, int curPage, int limit); 13 | public Map loadOne(String condition); 14 | public Map loadOne(String[] params, String condition); 15 | public boolean save(Page obj); 16 | public boolean update(Page obj); 17 | public boolean delete(Page obj); 18 | public boolean deleteByCondition(String condition); 19 | public int count(); 20 | public int count(String condition); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/IRoleService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.entity.Role; 7 | 8 | public interface IRoleService { 9 | public List> load(); 10 | public List> load(String condition); 11 | public List> load(String[] params, String condition); 12 | public List> load(String[] params, String condition, int curPage, int limit); 13 | public Map loadOne(String condition); 14 | public Map loadOne(String[] params, String condition); 15 | public boolean save(Role obj); 16 | public boolean update(Role obj); 17 | public boolean delete(Role obj); 18 | public boolean deleteByCondition(String condition); 19 | public int count(); 20 | public int count(String condition); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/IUserService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.entity.User; 7 | 8 | public interface IUserService { 9 | public List> load(); 10 | public List> load(String condition); 11 | public List> load(String[] params, String condition); 12 | public List> load(String[] params, String condition, int curPage, int limit); 13 | public Map loadOne(String condition); 14 | public Map loadOne(String[] params, String condition); 15 | public boolean save(User obj); 16 | public boolean update(User obj); 17 | public boolean delete(User obj); 18 | public boolean deleteByCondition(String condition); 19 | public int count(); 20 | public int count(String condition); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/IMessageService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.entity.Message; 7 | 8 | public interface IMessageService { 9 | public List> load(); 10 | public List> load(String condition); 11 | public List> load(String[] params, String condition); 12 | public List> load(String[] params, String condition, int curPage, int limit); 13 | public Map loadOne(String condition); 14 | public Map loadOne(String[] params, String condition); 15 | public boolean save(Message obj); 16 | public boolean update(Message obj); 17 | public boolean delete(Message obj); 18 | public boolean deleteByCondition(String condition); 19 | public int count(); 20 | public int count(String condition); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/IPermissionService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.entity.Permission; 7 | 8 | public interface IPermissionService { 9 | public List> load(); 10 | public List> load(String condition); 11 | public List> load(String[] params, String condition); 12 | public List> load(String[] params, String condition, int curPage, int limit); 13 | public Map loadOne(String condition); 14 | public Map loadOne(String[] params, String condition); 15 | public boolean save(Permission obj); 16 | public boolean update(Permission obj); 17 | public boolean delete(Permission obj); 18 | public boolean deleteByCondition(String condition); 19 | public int count(); 20 | public int count(String condition); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/webapp/js/view/about.js: -------------------------------------------------------------------------------- 1 | app.controller("aboutController", function($scope) { 2 | $scope.timestamp = new Date().getTime(); 3 | $scope.resetReply = function() { 4 | $scope.replyContent = ""; 5 | }; 6 | $scope.changeValidCode = function() { 7 | $scope.timestamp = new Date().getTime(); 8 | }; 9 | $scope.submitReply = function() { 10 | $.ajax({ 11 | url: "message_reply.action", 12 | type: "POST", 13 | dataType: "json", 14 | data: { 15 | content: $scope.replyContent, 16 | validCode: $scope.validCode 17 | }, 18 | beforeSend: function() {}, 19 | complete: function() {}, 20 | success: function(data) { 21 | if (data.result === "success") { 22 | alert("您的反馈已提交成功,谢谢您的宝贵意见"); 23 | $("#reply-modal").modal("hide"); 24 | $scope.resetReply(); 25 | } else { 26 | alert(data.result); 27 | } 28 | }, 29 | error: function() { 30 | alert("请求错误"); 31 | } 32 | }); 33 | }; 34 | }); 35 | /* By Ming */ 36 | -------------------------------------------------------------------------------- /.settings/com.genuitec.eclipse.j2eedt.core.prefs: -------------------------------------------------------------------------------- 1 | defaultTldInfo=f\=http\://java.sun.com/jsf/core;http\://java.sun.com/jsf/html\=h;http\://struts.apache.org/tags-bean\=bean;http\://java.sun.com/jsp/jstl/fmt\=fmt;bean\=http\://struts.apache.org/tags-bean;nested\=http\://struts.apache.org/tags-nested;http\://java.sun.com/jsp/jstl/sql\=sql;c\=http\://java.sun.com/jsp/jstl/core;fmt\=http\://java.sun.com/jsp/jstl/fmt;http\://struts.apache.org/tags-logic\=logic;http\://java.sun.com/jsp/jstl/xml\=x;http\://java.sun.com/jsp/jstl/core\=c;logic\=http\://struts.apache.org/tags-logic;h\=http\://java.sun.com/jsf/html;http\://struts.apache.org/tags-tiles\=tiles;http\://java.sun.com/jsp/jstl/functions\=fn;tiles\=http\://struts.apache.org/tags-tiles;sql\=http\://java.sun.com/jsp/jstl/sql;http\://struts.apache.org/tags-html\=html;html\=http\://struts.apache.org/tags-html;http\://struts.apache.org/tags-nested\=nested;http\://java.sun.com/jsf/core\=f;fn\=http\://java.sun.com/jsp/jstl/functions;x\=http\://java.sun.com/jsp/jstl/xml 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /.settings/com.genuitec.eclipse.j2eedt.ui.prefs: -------------------------------------------------------------------------------- 1 | defaultTldInfo=f\=http\://java.sun.com/jsf/core;http\://java.sun.com/jsf/html\=h;http\://struts.apache.org/tags-bean\=bean;http\://java.sun.com/jsp/jstl/fmt\=fmt;nested\=http\://struts.apache.org/tags-nested;bean\=http\://struts.apache.org/tags-bean;http\://java.sun.com/jsp/jstl/sql\=sql;c\=http\://java.sun.com/jsp/jstl/core;fmt\=http\://java.sun.com/jsp/jstl/fmt;http\://struts.apache.org/tags-logic\=logic;http\://java.sun.com/jsp/jstl/xml\=x;http\://java.sun.com/jsp/jstl/core\=c;logic\=http\://struts.apache.org/tags-logic;h\=http\://java.sun.com/jsf/html;http\://struts.apache.org/tags-tiles\=tiles;http\://java.sun.com/jsp/jstl/functions\=fn;tiles\=http\://struts.apache.org/tags-tiles;sql\=http\://java.sun.com/jsp/jstl/sql;http\://struts.apache.org/tags-html\=html;http\://struts.apache.org/tags-nested\=nested;html\=http\://struts.apache.org/tags-html;http\://java.sun.com/jsf/core\=f;fn\=http\://java.sun.com/jsp/jstl/functions;x\=http\://java.sun.com/jsp/jstl/xml 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /src/main/java/com/ming/entity/Page.java: -------------------------------------------------------------------------------- 1 | package com.ming.entity; 2 | 3 | import com.ming.util.ID; 4 | 5 | /** 6 | * 7 | * @author Ming 8 | * @description 9 | * @date 2015-03-12 10 | */ 11 | public class Page { 12 | @ID 13 | private String pageId; 14 | private String page; 15 | private Integer roleId; 16 | 17 | public String getPageId() { 18 | return pageId; 19 | } 20 | 21 | public void setPageId(String pageId) { 22 | this.pageId = pageId; 23 | } 24 | 25 | public String getPage() { 26 | return page; 27 | } 28 | 29 | public void setPage(String page) { 30 | this.page = page; 31 | } 32 | 33 | public Integer getRoleId() { 34 | return roleId; 35 | } 36 | 37 | public void setRoleId(Integer roleId) { 38 | this.roleId = roleId; 39 | } 40 | 41 | public Page() { 42 | } 43 | 44 | public Page(String pageId) { 45 | this.pageId = pageId; 46 | } 47 | 48 | public Page(String pageId, String page, Integer roleId) { 49 | this.pageId = pageId; 50 | this.page = page; 51 | this.roleId = roleId; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout, R 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=[MoneyManager][%p] %d %m%n 6 | 7 | log4j.appender.R=org.apache.log4j.DailyRollingFileAppender 8 | log4j.appender.R.File=${catalina.home}/logs/MoneyManager.log 9 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 10 | log4j.appender.R.layout.ConversionPattern=%d %p [%t] %m%n 11 | 12 | log4j.logger.com.neusoft=DEBUG 13 | log4j.logger.com.opensymphony.oscache=ERROR 14 | log4j.logger.net.sf.navigator=ERROR 15 | log4j.logger.org.apache.commons=ERROR 16 | log4j.logger.org.apache.struts=WARN 17 | log4j.logger.org.displaytag=ERROR 18 | log4j.logger.org.springframework=DEBUG 19 | log4j.logger.com.ibatis.db=WARN 20 | log4j.logger.org.apache.velocity=FATAL 21 | 22 | log4j.logger.com.canoo.webtest=WARN 23 | 24 | log4j.logger.org.hibernate.ps.PreparedStatementCache=WARN 25 | log4j.logger.org.hibernate=DEBUG 26 | log4j.logger.org.logicalcobwebs=WARN 27 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/ConsoleMessage.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | import java.util.TimeZone; 7 | 8 | /** 9 | * 控制台消息类 10 | * @author Ming 11 | * @description 格式化输出控制台消息 12 | * @date 2015-02-15 13 | */ 14 | public class ConsoleMessage { 15 | private static String getCurrentDate() { 16 | TimeZone timeZone = TimeZone.getDefault(); // 获取系统当前市区 17 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a"); 18 | dateFormat.setTimeZone(timeZone); 19 | Date date = new Date(); 20 | String dateString = dateFormat.format(date); 21 | return dateString; 22 | } 23 | 24 | public static void info(String message) { 25 | System.out.println("[INFO] " + getCurrentDate() + " " + message); 26 | } 27 | 28 | public static void warn(String message) { 29 | System.out.println("[WARN] " + getCurrentDate() + " " + message); 30 | } 31 | 32 | public static void error(String message) { 33 | System.out.println("[RROR] " + getCurrentDate() + " " + message); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/IBillForInService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.entity.BillForIn; 7 | 8 | public interface IBillForInService { 9 | public List> load(); 10 | public List> load(String condition); 11 | public List> load(String[] params, String condition); 12 | public List> load(String[] params, String condition, int curPage, int limit); 13 | public Map loadOne(String condition); 14 | public Map loadOne(String[] params, String condition); 15 | public boolean save(BillForIn obj); 16 | public boolean update(BillForIn obj); 17 | public boolean delete(BillForIn obj); 18 | public boolean deleteByCondition(String condition); 19 | public int count(); 20 | public int count(String condition); 21 | 22 | public List> loadSpecial(String condition, int curPage, int limit); 23 | public Map loadOneSpecial(String condition); 24 | public int countSpecial(String condition); 25 | public double sumUp(String condition); 26 | public double sumUpMoney(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/ming/entity/Permission.java: -------------------------------------------------------------------------------- 1 | package com.ming.entity; 2 | 3 | import com.ming.util.ID; 4 | 5 | public class Permission { 6 | @ID 7 | private String id; 8 | private String actionName; 9 | private Integer roleId; 10 | private String remark; 11 | 12 | public String getId() { 13 | return id; 14 | } 15 | 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | 20 | public String getActionName() { 21 | return actionName; 22 | } 23 | 24 | public void setActionName(String actionName) { 25 | this.actionName = actionName; 26 | } 27 | 28 | public Integer getRoleId() { 29 | return roleId; 30 | } 31 | 32 | public void setRoleId(Integer roleId) { 33 | this.roleId = roleId; 34 | } 35 | 36 | public String getRemark() { 37 | return remark; 38 | } 39 | 40 | public void setRemark(String remark) { 41 | this.remark = remark; 42 | } 43 | 44 | public Permission() { 45 | } 46 | 47 | public Permission(String id) { 48 | this.id = id; 49 | } 50 | 51 | public Permission(String id, String actionName, Integer roleId, String remark) { 52 | this.id = id; 53 | this.actionName = actionName; 54 | this.roleId = roleId; 55 | this.remark = remark; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/webapp/js/login.js: -------------------------------------------------------------------------------- 1 | angular.module("app", []).controller("controller", function($scope) { 2 | $scope.timestamp = new Date().getTime(); 3 | $scope.changeValidCode = function() { 4 | $scope.timestamp = new Date().getTime(); 5 | }; 6 | $scope.login = function() { 7 | $.ajax({ 8 | url: "user_login.action", 9 | data: { 10 | username: hex_md5($scope.username), 11 | password: hex_md5($scope.password), 12 | validCode: $scope.validCode 13 | }, 14 | type: "POST", 15 | beforeSend: function() {}, 16 | complete: function() {}, 17 | success: function(data) { 18 | if (data.result === "success") { 19 | window.location.href = data.url; 20 | } else { 21 | alert(data.result); 22 | $scope.changeValidCode(); 23 | } 24 | }, 25 | error: function() { 26 | alert("请求错误"); 27 | } 28 | }); 29 | }; 30 | $scope.init = function() { 31 | $.ajax({ 32 | url: "user_test.action", 33 | data: {}, 34 | type: "POST", 35 | beforeSend: function() {}, 36 | complete: function() {}, 37 | success: function(data) { 38 | if (data.result === "success") { 39 | document.write("检测到您已登录,正在跳转中..."); 40 | window.location.href = data.url; 41 | } 42 | }, 43 | error: function() {} 44 | }); 45 | }; 46 | $scope.init(); 47 | }); 48 | /* By Ming */ 49 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/KaptchaUtil.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import com.opensymphony.xwork2.ActionContext; 4 | import com.opensymphony.xwork2.ActionSupport; 5 | 6 | /** 7 | * Kaptcha验证码工具类 8 | * @author Ming 9 | * @description 获取生成的验证码并用于验证,基于Struts2 10 | * @date 2015-06-30 11 | */ 12 | public class KaptchaUtil extends ActionSupport { 13 | private static final long serialVersionUID = 1L; 14 | 15 | /** 16 | * 获取验证码 17 | * @return 验证码 18 | */ 19 | public static String getCode() { 20 | try { 21 | String code = (String) ActionContext.getContext().getSession().get(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY); 22 | return code; 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | return null; 26 | } 27 | } 28 | 29 | public static void removeCode() { 30 | try { 31 | ActionContext.getContext().getSession().remove(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY); 32 | } catch (Exception e) { 33 | e.printStackTrace(); 34 | } 35 | } 36 | 37 | public static boolean checkCode(String validCode) { 38 | try { 39 | String code = getCode(); 40 | if (code != null && validCode != null && code.equalsIgnoreCase(validCode)) { 41 | removeCode(); 42 | return true; 43 | } else { 44 | return false; 45 | } 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | return false; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/webapp/error/error.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 | <% 3 | String path = request.getContextPath(); 4 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 | %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 服务器错误 14 | 15 | 16 | 21 | 22 | 23 | 24 |
25 |
26 |
27 |
28 |

错误:服务器错误!

29 |

返回首页

30 |
31 |
32 |
33 |
34 |
35 |

财务管理系统 © 2015

36 |
37 |
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/webapp/error/nopower.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 | <% 3 | String path = request.getContextPath(); 4 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 | %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 权限警告 14 | 15 | 16 | 21 | 22 | 23 | 24 |
25 |
26 |
27 |
28 |

警告:您没有足够的权限!

29 |

返回首页

30 |
31 |
32 |
33 |
34 |
35 |

财务管理系统 © 2015

36 |
37 |
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/webapp/error/notfound.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 | <% 3 | String path = request.getContextPath(); 4 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 | %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 页面未找到 14 | 15 | 16 | 21 | 22 | 23 | 24 |
25 |
26 |
27 |
28 |

错误:页面未找到!

29 |

返回首页

30 |
31 |
32 |
33 |
34 |
35 |

财务管理系统 © 2015

36 |
37 |
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | MoneyManager 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator 30 | 31 | 32 | 33 | 34 | com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder 35 | 36 | 37 | 38 | 39 | 40 | org.eclipse.jem.workbench.JavaEMFNature 41 | org.eclipse.wst.common.modulecore.ModuleCoreNature 42 | org.eclipse.wst.common.project.facet.core.nature 43 | org.eclipse.jdt.core.javanature 44 | org.eclipse.wst.jsdt.core.jsNature 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/Condition.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | /** 4 | * 条件实体类 5 | * 6 | * @author Ming 7 | * @description 8 | * @date 2015-07-02 9 | */ 10 | public class Condition { 11 | private String name; 12 | private String url; 13 | private String userName; 14 | private String toName; 15 | private String recordName; 16 | private String payName; 17 | private Integer status; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getUrl() { 28 | return url; 29 | } 30 | 31 | public void setUrl(String url) { 32 | this.url = url; 33 | } 34 | 35 | public String getUserName() { 36 | return userName; 37 | } 38 | 39 | public void setUserName(String userName) { 40 | this.userName = userName; 41 | } 42 | 43 | public String getToName() { 44 | return toName; 45 | } 46 | 47 | public void setToName(String toName) { 48 | this.toName = toName; 49 | } 50 | 51 | public String getRecordName() { 52 | return recordName; 53 | } 54 | 55 | public void setRecordName(String recordName) { 56 | this.recordName = recordName; 57 | } 58 | 59 | public String getPayName() { 60 | return payName; 61 | } 62 | 63 | public void setPayName(String payName) { 64 | this.payName = payName; 65 | } 66 | 67 | public Integer getStatus() { 68 | return status; 69 | } 70 | 71 | public void setStatus(Integer status) { 72 | this.status = status; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/ming/entity/Menu.java: -------------------------------------------------------------------------------- 1 | package com.ming.entity; 2 | 3 | import com.ming.util.ID; 4 | 5 | /** 6 | * 7 | * @author Ming 8 | * @description 9 | * @date 2015-06-12 10 | */ 11 | public class Menu { 12 | @ID 13 | private String menuId; 14 | private String name; 15 | private String url; 16 | private String href; 17 | private Integer no; 18 | private Integer roleId; 19 | 20 | public String getMenuId() { 21 | return menuId; 22 | } 23 | 24 | public void setMenuId(String menuId) { 25 | this.menuId = menuId; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getUrl() { 37 | return url; 38 | } 39 | 40 | public void setUrl(String url) { 41 | this.url = url; 42 | } 43 | 44 | public String getHref() { 45 | return href; 46 | } 47 | 48 | public void setHref(String href) { 49 | this.href = href; 50 | } 51 | 52 | public Integer getNo() { 53 | return no; 54 | } 55 | 56 | public void setNo(Integer no) { 57 | this.no = no; 58 | } 59 | 60 | public Integer getRoleId() { 61 | return roleId; 62 | } 63 | 64 | public void setRoleId(Integer roleId) { 65 | this.roleId = roleId; 66 | } 67 | 68 | public Menu() { 69 | } 70 | 71 | public Menu(String menuId) { 72 | this.menuId = menuId; 73 | } 74 | 75 | public Menu(String menuId, String name, String url, Integer roleId) { 76 | this.menuId = menuId; 77 | this.name = name; 78 | this.url = url; 79 | this.roleId = roleId; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/resources/struts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | /index.html 17 | /error/nopower.jsp 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/com/ming/entity/Message.java: -------------------------------------------------------------------------------- 1 | package com.ming.entity; 2 | 3 | import com.ming.util.ID; 4 | 5 | /** 6 | * 7 | * @author Ming 8 | * @description 9 | * @date 2015-07-10 10 | */ 11 | public class Message { 12 | public static final String TYPE_SUCCESS = "0"; // alert-success 13 | public static final String TYPE_INFO = "1"; // alert-info 14 | public static final String TYPE_WARNING = "2"; // alert-warning 15 | public static final String TYPE_DANGER = "3"; // alert-danger 16 | 17 | @ID 18 | private String id; 19 | private String type; 20 | private String content; 21 | private Double createTime; 22 | private String userId; 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getType() { 33 | return type; 34 | } 35 | 36 | public void setType(String type) { 37 | this.type = type; 38 | } 39 | 40 | public String getContent() { 41 | return content; 42 | } 43 | 44 | public void setContent(String content) { 45 | this.content = content; 46 | } 47 | 48 | public Double getCreateTime() { 49 | return createTime; 50 | } 51 | 52 | public void setCreateTime(Double createTime) { 53 | this.createTime = createTime; 54 | } 55 | 56 | public String getUserId() { 57 | return userId; 58 | } 59 | 60 | public void setUserId(String userId) { 61 | this.userId = userId; 62 | } 63 | 64 | public Message() { 65 | } 66 | 67 | public Message(String id) { 68 | this.id = id; 69 | } 70 | 71 | public Message(String id, String type, String content, Double createTime, String userId) { 72 | this.id = id; 73 | this.type = type; 74 | this.content = content; 75 | this.createTime = createTime; 76 | this.userId = userId; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/IllegalCharacterInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.opensymphony.xwork2.ActionContext; 7 | import com.opensymphony.xwork2.ActionInvocation; 8 | import com.opensymphony.xwork2.interceptor.AbstractInterceptor; 9 | import com.opensymphony.xwork2.util.ValueStack; 10 | 11 | /** 12 | * SQL注入拦截器 13 | * @author Ming 14 | * @description 进行非法字符的转换,防止SQL注入 15 | * @date 2015-03-19 16 | */ 17 | public class IllegalCharacterInterceptor extends AbstractInterceptor { 18 | private static final long serialVersionUID = 1L; 19 | 20 | @Override 21 | public String intercept(ActionInvocation invocation) throws Exception { 22 | ActionContext actionContext = invocation.getInvocationContext(); 23 | ValueStack valueStack = actionContext.getValueStack(); 24 | Map valueMap = actionContext.getParameters(); 25 | Map newValueMap = new HashMap(); 26 | for (Map.Entry map : valueMap.entrySet()) { 27 | String key = map.getKey(); 28 | Object value = map.getValue(); 29 | if (value != null && value instanceof String[]) { 30 | String[] oldValue = (String[]) value; 31 | String[] newValue = new String[oldValue.length]; 32 | for (int i = 0; i < oldValue.length; i++) { 33 | String oldString = oldValue[i]; 34 | String newString = oldString.replaceAll("'", "''"); 35 | newValue[i] = newString; 36 | } 37 | newValueMap.put(key, newValue); 38 | try { 39 | valueStack.setValue(key, newValue); 40 | } catch (Exception e) { 41 | } 42 | } 43 | } 44 | for (Map.Entry map : newValueMap.entrySet()) 45 | valueStack.set(map.getKey(), map.getValue()); 46 | return invocation.invoke(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | MoneyManager 4 | 5 | CommonFilter 6 | com.ming.util.CommonFilter 7 | 8 | encoding 9 | UTF-8 10 | 11 | 12 | 13 | CommonFilter 14 | /* 15 | 16 | 17 | struts2 18 | org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 19 | 20 | 21 | struts2 22 | *.action 23 | 24 | 25 | Kaptcha 26 | com.google.code.kaptcha.servlet.KaptchaServlet 27 | 28 | kaptcha.border 29 | no 30 | 31 | 32 | 33 | Kaptcha 34 | /kaptcha.jpg 35 | 36 | 37 | 404 38 | /error/notfound.jsp 39 | 40 | 41 | 500 42 | /error/error.jsp 43 | 44 | 45 | index.html 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/IBillForOutService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.entity.BillForOut; 7 | 8 | public interface IBillForOutService { 9 | public List> load(); 10 | public List> load(String condition); 11 | public List> load(String[] params, String condition); 12 | public List> load(String[] params, String condition, int curPage, int limit); 13 | public Map loadOne(String condition); 14 | public Map loadOne(String[] params, String condition); 15 | public boolean save(BillForOut obj); 16 | public boolean update(BillForOut obj); 17 | public boolean delete(BillForOut obj); 18 | public boolean deleteByCondition(String condition); 19 | public int count(); 20 | public int count(String condition); 21 | 22 | public List> loadSpecial(String condition, int curPage, int limit); 23 | public Map loadOneSpecial(String condition); 24 | public int countSpecial(String condition); 25 | public List> loadMineSpecial(String userId, String condition, int curPage, int limit); 26 | public int countMineSpecial(String userId, String condition); 27 | public List> loadReviewSpecial(String condition, int curPage, int limit); 28 | public Map loadOneReviewSpecial(String condition); 29 | public int countReviewSpecial(String condition); 30 | public List> loadPaySpecial(String userId, String condition, int curPage, int limit); 31 | public int countPaySpecial(String userId, String condition); 32 | public double sumUp(String condition); 33 | public double sumUpMine(String userId, String condition); 34 | public double sumUpReview(String condition); 35 | public double sumUpPay(String userId, String condition); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/MenuService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.dao.CommonDao; 7 | import com.ming.entity.Menu; 8 | 9 | /** 10 | * MenuService 11 | * @author Ming 12 | * @description 13 | * @date 2015-06-12 14 | */ 15 | public class MenuService implements IMenuService { 16 | private static final CommonDao db = new CommonDao(); 17 | 18 | @Override 19 | public List> load() { 20 | return db.load(Menu.class); 21 | } 22 | 23 | @Override 24 | public List> load(String condition) { 25 | return db.load(Menu.class, condition); 26 | } 27 | 28 | @Override 29 | public List> load(String[] params, String condition) { 30 | return db.load(params, Menu.class, condition); 31 | } 32 | 33 | @Override 34 | public List> load(String[] params, String condition, int curPage, int limit) { 35 | return db.load(params, Menu.class, condition, curPage, limit); 36 | } 37 | 38 | @Override 39 | public Map loadOne(String condition) { 40 | return db.loadOne(Menu.class, condition); 41 | } 42 | 43 | @Override 44 | public Map loadOne(String[] params, String condition) { 45 | return db.loadOne(params, Menu.class, condition); 46 | } 47 | 48 | @Override 49 | public boolean save(Menu obj) { 50 | return db.insert(obj); 51 | } 52 | 53 | @Override 54 | public boolean update(Menu obj) { 55 | return db.update(obj); 56 | } 57 | 58 | @Override 59 | public boolean delete(Menu obj) { 60 | return db.delete(obj); 61 | } 62 | 63 | @Override 64 | public boolean deleteByCondition(String condition) { 65 | return db.delete(Menu.class, condition); 66 | } 67 | 68 | @Override 69 | public int count() { 70 | return db.count(Menu.class); 71 | } 72 | 73 | @Override 74 | public int count(String condition) { 75 | return db.count(Menu.class, condition); 76 | } 77 | 78 | public MenuService() { 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/PageService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.dao.CommonDao; 7 | import com.ming.entity.Page; 8 | 9 | /** 10 | * PageService 11 | * @author Ming 12 | * @description 13 | * @date 2015-03-24 14 | */ 15 | public class PageService implements IPageService { 16 | private static final CommonDao db = new CommonDao(); 17 | 18 | @Override 19 | public List> load() { 20 | return db.load(Page.class); 21 | } 22 | 23 | @Override 24 | public List> load(String condition) { 25 | return db.load(Page.class, condition); 26 | } 27 | 28 | @Override 29 | public List> load(String[] params, String condition) { 30 | return db.load(params, Page.class, condition); 31 | } 32 | 33 | @Override 34 | public List> load(String[] params, String condition, int curPage, int limit) { 35 | return db.load(params, Page.class, condition, curPage, limit); 36 | } 37 | 38 | @Override 39 | public Map loadOne(String condition) { 40 | return db.loadOne(Page.class, condition); 41 | } 42 | 43 | @Override 44 | public Map loadOne(String[] params, String condition) { 45 | return db.loadOne(params, Page.class, condition); 46 | } 47 | 48 | @Override 49 | public boolean save(Page obj) { 50 | return db.insert(obj); 51 | } 52 | 53 | @Override 54 | public boolean update(Page obj) { 55 | return db.update(obj); 56 | } 57 | 58 | @Override 59 | public boolean delete(Page obj) { 60 | return db.delete(obj); 61 | } 62 | 63 | @Override 64 | public boolean deleteByCondition(String condition) { 65 | return db.delete(Page.class, condition); 66 | } 67 | 68 | @Override 69 | public int count() { 70 | return db.count(Page.class); 71 | } 72 | 73 | @Override 74 | public int count(String condition) { 75 | return db.count(Page.class, condition); 76 | } 77 | 78 | public PageService() { 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.dao.CommonDao; 7 | import com.ming.entity.Role; 8 | 9 | /** 10 | * RoleService 11 | * @author Ming 12 | * @description 13 | * @date 2015-03-24 14 | */ 15 | public class RoleService implements IRoleService { 16 | private static final CommonDao db = new CommonDao(); 17 | 18 | @Override 19 | public List> load() { 20 | return db.load(Role.class); 21 | } 22 | 23 | @Override 24 | public List> load(String condition) { 25 | return db.load(Role.class, condition); 26 | } 27 | 28 | @Override 29 | public List> load(String[] params, String condition) { 30 | return db.load(params, Role.class, condition); 31 | } 32 | 33 | @Override 34 | public List> load(String[] params, String condition, int curPage, int limit) { 35 | return db.load(params, Role.class, condition, curPage, limit); 36 | } 37 | 38 | @Override 39 | public Map loadOne(String condition) { 40 | return db.loadOne(Role.class, condition); 41 | } 42 | 43 | @Override 44 | public Map loadOne(String[] params, String condition) { 45 | return db.loadOne(params, Role.class, condition); 46 | } 47 | 48 | @Override 49 | public boolean save(Role obj) { 50 | return db.insert(obj); 51 | } 52 | 53 | @Override 54 | public boolean update(Role obj) { 55 | return db.update(obj); 56 | } 57 | 58 | @Override 59 | public boolean delete(Role obj) { 60 | return db.delete(obj); 61 | } 62 | 63 | @Override 64 | public boolean deleteByCondition(String condition) { 65 | return db.delete(Role.class, condition); 66 | } 67 | 68 | @Override 69 | public int count() { 70 | return db.count(Role.class); 71 | } 72 | 73 | @Override 74 | public int count(String condition) { 75 | return db.count(Role.class, condition); 76 | } 77 | 78 | public RoleService() { 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.dao.CommonDao; 7 | import com.ming.entity.User; 8 | 9 | /** 10 | * UserService 11 | * @author Ming 12 | * @description 13 | * @date 2015-03-24 14 | */ 15 | public class UserService implements IUserService { 16 | private static final CommonDao db = new CommonDao(); 17 | 18 | @Override 19 | public List> load() { 20 | return db.load(User.class); 21 | } 22 | 23 | @Override 24 | public List> load(String condition) { 25 | return db.load(User.class, condition); 26 | } 27 | 28 | @Override 29 | public List> load(String[] params, String condition) { 30 | return db.load(params, User.class, condition); 31 | } 32 | 33 | @Override 34 | public List> load(String[] params, String condition, int curPage, int limit) { 35 | return db.load(params, User.class, condition, curPage, limit); 36 | } 37 | 38 | @Override 39 | public Map loadOne(String condition) { 40 | return db.loadOne(User.class, condition); 41 | } 42 | 43 | @Override 44 | public Map loadOne(String[] params, String condition) { 45 | return db.loadOne(params, User.class, condition); 46 | } 47 | 48 | @Override 49 | public boolean save(User obj) { 50 | return db.insert(obj); 51 | } 52 | 53 | @Override 54 | public boolean update(User obj) { 55 | return db.update(obj); 56 | } 57 | 58 | @Override 59 | public boolean delete(User obj) { 60 | return db.delete(obj); 61 | } 62 | 63 | @Override 64 | public boolean deleteByCondition(String condition) { 65 | return db.delete(User.class, condition); 66 | } 67 | 68 | @Override 69 | public int count() { 70 | return db.count(User.class); 71 | } 72 | 73 | @Override 74 | public int count(String condition) { 75 | return db.count(User.class, condition); 76 | } 77 | 78 | public UserService() { 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/PermissionInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import com.ming.dao.BaseDao; 8 | import com.opensymphony.xwork2.ActionContext; 9 | import com.opensymphony.xwork2.ActionInvocation; 10 | import com.opensymphony.xwork2.ActionProxy; 11 | import com.opensymphony.xwork2.interceptor.AbstractInterceptor; 12 | 13 | /** 14 | * 利用注解进行登录方法拦截 15 | * @author Ming 16 | * @description 拦截需要登录才能调用的方法 17 | * @date 2015-03-15 18 | */ 19 | public class PermissionInterceptor extends AbstractInterceptor { 20 | private static final long serialVersionUID = 1L; 21 | 22 | @Override 23 | public String intercept(ActionInvocation invocation) throws Exception { 24 | ActionProxy actionProxy = invocation.getProxy(); 25 | String currentMethodName = actionProxy.getMethod(); 26 | String actionName = actionProxy.getActionName(); 27 | Class actionClass = invocation.getAction().getClass(); 28 | Method currentMethod = actionClass.getMethod(currentMethodName); 29 | if (currentMethod.getAnnotation(Permission.class) != null) { 30 | Map session = ActionContext.getContext().getSession(); 31 | if (session.get("userId") == null) { 32 | ConsoleMessage.warn("拦截未登录调用" + actionName); 33 | if (currentMethod.getReturnType().equals(String.class)) { 34 | return "login"; 35 | } else { 36 | WebUtil.writeJson(WebUtil.JSON_LOGIN); 37 | return null; 38 | } 39 | } 40 | Integer roleId = (Integer) session.get("roleId"); 41 | List> data = BaseDao.load("SELECT id FROM Permission WHERE actionName = '" + actionName + "' AND roleId = '" + roleId + "'"); 42 | if (data.size() == 0) { 43 | ConsoleMessage.warn("拦截无权限调用" + actionName); 44 | if (currentMethod.getReturnType().equals(String.class)) { 45 | return "nopower"; 46 | } else { 47 | WebUtil.writeJson(WebUtil.JSON_NO_PERMISSION); 48 | return null; 49 | } 50 | } 51 | } 52 | return invocation.invoke(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/MessageService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.dao.CommonDao; 7 | import com.ming.entity.Message; 8 | 9 | /** 10 | * MessageService 11 | * @author Ming 12 | * @description 13 | * @date 2015-07-10 14 | */ 15 | public class MessageService implements IMessageService { 16 | private static final CommonDao db = new CommonDao(); 17 | 18 | @Override 19 | public List> load() { 20 | return db.load(Message.class); 21 | } 22 | 23 | @Override 24 | public List> load(String condition) { 25 | return db.load(Message.class, condition); 26 | } 27 | 28 | @Override 29 | public List> load(String[] params, String condition) { 30 | return db.load(params, Message.class, condition); 31 | } 32 | 33 | @Override 34 | public List> load(String[] params, String condition, int curPage, int limit) { 35 | return db.load(params, Message.class, condition, curPage, limit); 36 | } 37 | 38 | @Override 39 | public Map loadOne(String condition) { 40 | return db.loadOne(Message.class, condition); 41 | } 42 | 43 | @Override 44 | public Map loadOne(String[] params, String condition) { 45 | return db.loadOne(params, Message.class, condition); 46 | } 47 | 48 | @Override 49 | public boolean save(Message obj) { 50 | return db.insert(obj); 51 | } 52 | 53 | @Override 54 | public boolean update(Message obj) { 55 | return db.update(obj); 56 | } 57 | 58 | @Override 59 | public boolean delete(Message obj) { 60 | return db.delete(obj); 61 | } 62 | 63 | @Override 64 | public boolean deleteByCondition(String condition) { 65 | return db.delete(Message.class, condition); 66 | } 67 | 68 | @Override 69 | public int count() { 70 | return db.count(Message.class); 71 | } 72 | 73 | @Override 74 | public int count(String condition) { 75 | return db.count(Message.class, condition); 76 | } 77 | 78 | public MessageService() { 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/PermissionService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.dao.CommonDao; 7 | import com.ming.entity.Permission; 8 | 9 | /** 10 | * PermissionService 11 | * @author Ming 12 | * @description 13 | * @date 2015-07-10 14 | */ 15 | public class PermissionService implements IPermissionService { 16 | private static final CommonDao db = new CommonDao(); 17 | 18 | @Override 19 | public List> load() { 20 | return db.load(Permission.class); 21 | } 22 | 23 | @Override 24 | public List> load(String condition) { 25 | return db.load(Permission.class, condition); 26 | } 27 | 28 | @Override 29 | public List> load(String[] params, String condition) { 30 | return db.load(params, Permission.class, condition); 31 | } 32 | 33 | @Override 34 | public List> load(String[] params, String condition, int curPage, int limit) { 35 | return db.load(params, Permission.class, condition, curPage, limit); 36 | } 37 | 38 | @Override 39 | public Map loadOne(String condition) { 40 | return db.loadOne(Permission.class, condition); 41 | } 42 | 43 | @Override 44 | public Map loadOne(String[] params, String condition) { 45 | return db.loadOne(params, Permission.class, condition); 46 | } 47 | 48 | @Override 49 | public boolean save(Permission obj) { 50 | return db.insert(obj); 51 | } 52 | 53 | @Override 54 | public boolean update(Permission obj) { 55 | return db.update(obj); 56 | } 57 | 58 | @Override 59 | public boolean delete(Permission obj) { 60 | return db.delete(obj); 61 | } 62 | 63 | @Override 64 | public boolean deleteByCondition(String condition) { 65 | return db.delete(Permission.class, condition); 66 | } 67 | 68 | @Override 69 | public int count() { 70 | return db.count(Permission.class); 71 | } 72 | 73 | @Override 74 | public int count(String condition) { 75 | return db.count(Permission.class, condition); 76 | } 77 | 78 | public PermissionService() { 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/DataUtil.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.text.DateFormat; 4 | import java.text.DecimalFormat; 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | import java.util.TimeZone; 8 | import java.util.UUID; 9 | 10 | /** 11 | * 数据工具类 12 | * @author Ming 13 | * @description 提供辅助数据 14 | * @date 2015-03-10 15 | */ 16 | public class DataUtil { 17 | /** 18 | * 生成32位的UUID 19 | * @return UUID字符串 20 | */ 21 | public static String getUUID() { 22 | UUID uuid = UUID.randomUUID(); 23 | // String uuidString = uuid.toString().replaceAll("-", ""); 24 | String uuidString = uuid.toString(); 25 | return uuidString; 26 | } 27 | 28 | /** 29 | * 生成格式化的日期时间 30 | * @param date 日期时间对象 31 | * @param format 日期时间格式 32 | * @return 日期时间字符串 33 | */ 34 | public static String getDateString(final Date date, final String format) { 35 | TimeZone timeZone = TimeZone.getDefault(); // 获取系统当前市区 36 | DateFormat dateFormat = new SimpleDateFormat(format); 37 | dateFormat.setTimeZone(timeZone); 38 | String dateString = dateFormat.format(date); 39 | return dateString; 40 | } 41 | 42 | /** 43 | * 将double类型并且形如“yyyyMMdd”的数据转成“yyyy/MM/dd”的字符串 44 | * @param data 日期 45 | * @return 格式化后的字符串 46 | */ 47 | public static String dateFormat(final Double data) { 48 | try { 49 | DecimalFormat format = new DecimalFormat("#"); 50 | String dataString = format.format(data); 51 | return dataString.substring(0, 4) + "/" + dataString.substring(4, 6) + "/" + dataString.substring(6); 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | return ""; 55 | } 56 | } 57 | 58 | /** 59 | * 将double类型并且形如“yyyyMMddHHmmss”的数据转成“yyyy/MM/dd HH:mm:ss”的字符串 60 | * @param data 日期 61 | * @return 格式化后的字符串 62 | */ 63 | public static String dateTimeFormat(final Double data) { 64 | try { 65 | DecimalFormat format = new DecimalFormat("#"); 66 | String dataString = format.format(data); 67 | return dataString.substring(0, 4) + "/" + dataString.substring(4, 6) + "/" + dataString.substring(6, 8) + " " + dataString.substring(8, 10) + ":" + dataString.substring(10, 12) + ":" + dataString.substring(12); 68 | } catch (Exception e) { 69 | e.printStackTrace(); 70 | return ""; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/ming/entity/BillForIn.java: -------------------------------------------------------------------------------- 1 | package com.ming.entity; 2 | 3 | import com.ming.util.ID; 4 | 5 | /** 6 | * 7 | * @author Ming 8 | * @description 9 | * @date 2015-03-12 10 | */ 11 | public class BillForIn { 12 | @ID 13 | private String id; 14 | private Double date; 15 | private Double amount; 16 | private String fromId; 17 | private String toId; 18 | private String recordId; 19 | private Double createDate; 20 | private String remark; 21 | 22 | public String getId() { 23 | return id; 24 | } 25 | 26 | public void setId(String id) { 27 | this.id = id; 28 | } 29 | 30 | public Double getDate() { 31 | return date; 32 | } 33 | 34 | public void setDate(Double date) { 35 | this.date = date; 36 | } 37 | 38 | public Double getAmount() { 39 | return amount; 40 | } 41 | 42 | public void setAmount(Double amount) { 43 | this.amount = amount; 44 | } 45 | 46 | public String getFromId() { 47 | return fromId; 48 | } 49 | 50 | public void setFromId(String fromId) { 51 | this.fromId = fromId; 52 | } 53 | 54 | public String getToId() { 55 | return toId; 56 | } 57 | 58 | public void setToId(String toId) { 59 | this.toId = toId; 60 | } 61 | 62 | public String getRecordId() { 63 | return recordId; 64 | } 65 | 66 | public void setRecordId(String recordId) { 67 | this.recordId = recordId; 68 | } 69 | 70 | public Double getCreateDate() { 71 | return createDate; 72 | } 73 | 74 | public void setCreateDate(Double createDate) { 75 | this.createDate = createDate; 76 | } 77 | 78 | public String getRemark() { 79 | return remark; 80 | } 81 | 82 | public void setRemark(String remark) { 83 | this.remark = remark; 84 | } 85 | 86 | public BillForIn() { 87 | } 88 | 89 | public BillForIn(String id) { 90 | this.id = id; 91 | } 92 | 93 | public BillForIn(String id, Double date, Double amount, String fromId, String toId, String recordId, Double createDate, String remark) { 94 | this.id = id; 95 | this.date = date; 96 | this.amount = amount; 97 | this.fromId = fromId; 98 | this.toId = toId; 99 | this.recordId = recordId; 100 | this.createDate = createDate; 101 | this.remark = remark; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/DataSecurity.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | /** 7 | * 数据安全类 8 | * @author Ming 9 | * @description 进行数据MD5或者SHA1加密(来源网上) 10 | * @date 2015-02-25 11 | */ 12 | public class DataSecurity { 13 | public static String stringMD5(String data) { 14 | try { 15 | // 拿到一个MD5转换器 16 | MessageDigest messageDigest = MessageDigest.getInstance("MD5"); 17 | 18 | // 输入的字符串转换成字节数组 19 | byte[] inputByteArray = data.getBytes(); 20 | 21 | // inputByteArray是输入字符串转换得到的字节数组 22 | messageDigest.update(inputByteArray); 23 | 24 | // 转换并返回结果,也是字节数组,包含16个元素 25 | byte[] resultByteArray = messageDigest.digest(); 26 | 27 | // 字符数组转换成字符串返回 28 | return byteArrayToHex(resultByteArray); 29 | } catch (NoSuchAlgorithmException e) { 30 | return null; 31 | } 32 | } 33 | 34 | public static String stringSHA1(String data) { 35 | try { 36 | // 拿到一个SHA1转换器 37 | MessageDigest messageDigest = MessageDigest.getInstance("SHA1"); 38 | 39 | // 输入的字符串转换成字节数组 40 | byte[] inputByteArray = data.getBytes(); 41 | 42 | // inputByteArray是输入字符串转换得到的字节数组 43 | messageDigest.update(inputByteArray); 44 | 45 | // 转换并返回结果,也是字节数组,包含16个元素 46 | byte[] resultByteArray = messageDigest.digest(); 47 | 48 | // 字符数组转换成字符串返回 49 | return byteArrayToHex(resultByteArray); 50 | } catch (NoSuchAlgorithmException e) { 51 | return null; 52 | } 53 | } 54 | 55 | public static String byteArrayToHex(byte[] byteArray) { 56 | // 首先初始化一个字符数组,用来存放每个16进制字符 57 | char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; 58 | 59 | // new一个字符数组,这个就是用来组成结果字符串的(解释一下:一个byte是八位二进制,也就是2位十六进制字符(2的8次方等于16的2次方)) 60 | char[] resultCharArray = new char[byteArray.length * 2]; 61 | 62 | // 遍历字节数组,通过位运算(位运算效率高),转换成字符放到字符数组中去 63 | int index = 0; 64 | for (byte b : byteArray) { 65 | 66 | resultCharArray[index++] = hexDigits[b >>> 4 & 0xf]; 67 | 68 | resultCharArray[index++] = hexDigits[b & 0xf]; 69 | 70 | } 71 | 72 | // 字符数组组合成字符串返回 73 | return new String(resultCharArray); 74 | } 75 | 76 | public static void main(String[] args) { 77 | String testString = "root"; 78 | System.out.println(stringMD5(testString)); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/webapp/view/about.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

财务管理系统

4 |

感谢您的使用!

5 |
6 | 作者:黄则鸣
7 | Email:642203604@qq.com 8 |
9 | 10 |
11 |
12 | 13 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/java/com/ming/entity/BillForOut.java: -------------------------------------------------------------------------------- 1 | package com.ming.entity; 2 | 3 | import com.ming.util.ID; 4 | 5 | /** 6 | * 7 | * @author Ming 8 | * @description 9 | * @date 2015-03-12 10 | */ 11 | public class BillForOut { 12 | public static final Integer STATUS_UNPAID = 0; // 未支付 13 | public static final Integer STATUS_PAID = 1; // 已支付 14 | public static final Integer STATUS_UNCHECK = 2; // 未审核 15 | public static final Integer STATUS_FAILED = 3; // 不通过 16 | 17 | @ID 18 | private String id; 19 | private Double date; 20 | private String event; 21 | private Double amount; 22 | private String payId; 23 | private Integer status; 24 | private String recordId; 25 | private Double createDate; 26 | private String remark; 27 | 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | 36 | public Double getDate() { 37 | return date; 38 | } 39 | 40 | public void setDate(Double date) { 41 | this.date = date; 42 | } 43 | 44 | public String getEvent() { 45 | return event; 46 | } 47 | 48 | public void setEvent(String event) { 49 | this.event = event; 50 | } 51 | 52 | public Double getAmount() { 53 | return amount; 54 | } 55 | 56 | public void setAmount(Double amount) { 57 | this.amount = amount; 58 | } 59 | 60 | public String getPayId() { 61 | return payId; 62 | } 63 | 64 | public void setPayId(String payId) { 65 | this.payId = payId; 66 | } 67 | 68 | public Integer getStatus() { 69 | return status; 70 | } 71 | 72 | public void setStatus(Integer status) { 73 | this.status = status; 74 | } 75 | 76 | public String getRecordId() { 77 | return recordId; 78 | } 79 | 80 | public void setRecordId(String recordId) { 81 | this.recordId = recordId; 82 | } 83 | 84 | public Double getCreateDate() { 85 | return createDate; 86 | } 87 | 88 | public void setCreateDate(Double createDate) { 89 | this.createDate = createDate; 90 | } 91 | 92 | public String getRemark() { 93 | return remark; 94 | } 95 | 96 | public void setRemark(String remark) { 97 | this.remark = remark; 98 | } 99 | 100 | public BillForOut() { 101 | } 102 | 103 | public BillForOut(String id) { 104 | this.id = id; 105 | } 106 | 107 | public BillForOut(String id, Double date, String event, Double amount, String payId, Integer status, String recordId, Double createDate, String remark) { 108 | this.id = id; 109 | this.date = date; 110 | this.event = event; 111 | this.amount = amount; 112 | this.payId = payId; 113 | this.status = status; 114 | this.recordId = recordId; 115 | this.createDate = createDate; 116 | this.remark = remark; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/CommonFilter.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.servlet.Filter; 8 | import javax.servlet.FilterChain; 9 | import javax.servlet.FilterConfig; 10 | import javax.servlet.ServletException; 11 | import javax.servlet.ServletRequest; 12 | import javax.servlet.ServletResponse; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | 16 | import com.ming.dao.BaseDao; 17 | 18 | /** 19 | * 公共过滤器类 20 | * @author Ming 21 | * @description 设置请求和响应的字符集和权限控制 22 | * @date 2015-02-14 23 | */ 24 | public class CommonFilter implements Filter { 25 | @SuppressWarnings("unused") 26 | private FilterConfig config; 27 | private String encoding; 28 | 29 | @Override 30 | public void destroy() { 31 | } 32 | 33 | @Override 34 | public void doFilter(ServletRequest request, ServletResponse response, 35 | FilterChain chain) throws IOException, ServletException { 36 | if (this.encoding != null && !"".equals(this.encoding)) { 37 | request.setCharacterEncoding(this.encoding); 38 | response.setCharacterEncoding(this.encoding); 39 | } 40 | HttpServletRequest httpServletRequest = (HttpServletRequest) request; 41 | String page = httpServletRequest.getServletPath().replaceAll("'", "''"); // 防止SQL注入!! 42 | if (page.matches("(.*)html") || page.matches("(.*)htm") || page.matches("(.*)jsp")) { 43 | List> countPage = BaseDao.load("SELECT COUNT(*) result FROM Page WHERE page = '" + page + "'"); 44 | if (countPage != null && !countPage.get(0).get("result").equals(0L)) { 45 | String userId = (String) httpServletRequest.getSession().getAttribute("userId"); 46 | if (userId == null) { 47 | String path = httpServletRequest.getContextPath(); 48 | ((HttpServletResponse) response).sendRedirect(path + "/"); 49 | return; 50 | } 51 | List> pageList = BaseDao.load("SELECT m.page FROM User u LEFT JOIN Page m ON u.roleId = m.roleId WHERE u.id = '" + userId + "'"); 52 | boolean hasAdmission = false; 53 | for (int i = 0, length = pageList.size(); i < length; i++) { 54 | Map pageMap = pageList.get(i); 55 | if (pageMap.containsValue(page)) { 56 | hasAdmission = true; 57 | break; 58 | } 59 | } 60 | if (!hasAdmission) { 61 | ((HttpServletResponse) response).sendError(404); 62 | return; 63 | } 64 | } 65 | } 66 | chain.doFilter(request, response); 67 | } 68 | 69 | @Override 70 | public void init(FilterConfig filterConfig) throws ServletException { 71 | this.config = filterConfig; 72 | this.encoding = filterConfig.getInitParameter("encoding"); 73 | String jdbcConfigPath = filterConfig.getServletContext().getRealPath("/WEB-INF/classes/jdbc.properties"); 74 | new ConnectionPool(jdbcConfigPath); 75 | ConsoleMessage.info("公共过滤器准备就绪"); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/ming/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.ming.entity; 2 | 3 | import com.ming.util.ID; 4 | 5 | /** 6 | * 7 | * @author Ming 8 | * @description 9 | * @date 2015-03-12 10 | */ 11 | public class User { 12 | public static final Integer ROLEID_SUPER_MANAGER = 0; // 超级管理员 13 | public static final Integer ROLEID_MANAGER = 1; // 管理员 14 | public static final Integer ROLEID_NORMAL_USER = 2; // 普通用户 15 | 16 | public static final Integer ISACTIVE_NO = 0; // 未激活 17 | public static final Integer ISACTIVE_YES = 1; // 已激活 18 | 19 | @ID 20 | private String id; 21 | private String loginName; 22 | private String userName; 23 | private String password; 24 | private String sex; 25 | private Double birthday; 26 | private String email; 27 | private String qq; 28 | private Integer roleId; 29 | private Integer isActive; 30 | private Double createDate; 31 | 32 | public String getId() { 33 | return id; 34 | } 35 | 36 | public void setId(String id) { 37 | this.id = id; 38 | } 39 | 40 | public String getLoginName() { 41 | return loginName; 42 | } 43 | 44 | public void setLoginName(String loginName) { 45 | this.loginName = loginName; 46 | } 47 | 48 | public String getUserName() { 49 | return userName; 50 | } 51 | 52 | public void setUserName(String userName) { 53 | this.userName = userName; 54 | } 55 | 56 | public String getPassword() { 57 | return password; 58 | } 59 | 60 | public void setPassword(String password) { 61 | this.password = password; 62 | } 63 | 64 | public String getSex() { 65 | return sex; 66 | } 67 | 68 | public void setSex(String sex) { 69 | this.sex = sex; 70 | } 71 | 72 | public Double getBirthday() { 73 | return birthday; 74 | } 75 | 76 | public void setBirthday(Double birthday) { 77 | this.birthday = birthday; 78 | } 79 | 80 | public String getEmail() { 81 | return email; 82 | } 83 | 84 | public void setEmail(String email) { 85 | this.email = email; 86 | } 87 | 88 | public String getQq() { 89 | return qq; 90 | } 91 | 92 | public void setQq(String qq) { 93 | this.qq = qq; 94 | } 95 | 96 | public Integer getRoleId() { 97 | return roleId; 98 | } 99 | 100 | public void setRoleId(Integer roleId) { 101 | this.roleId = roleId; 102 | } 103 | 104 | public Integer getIsActive() { 105 | return isActive; 106 | } 107 | 108 | public void setIsActive(Integer isActive) { 109 | this.isActive = isActive; 110 | } 111 | 112 | public Double getCreateDate() { 113 | return createDate; 114 | } 115 | 116 | public void setCreateDate(Double createDate) { 117 | this.createDate = createDate; 118 | } 119 | 120 | public User() { 121 | } 122 | 123 | public User(String id) { 124 | this.id = id; 125 | } 126 | 127 | public User(String id, String loginName, String userName, String password, String sex, Double birthday, String email, String qq, Integer roleId, Integer isActive, Double createDate) { 128 | this.id = id; 129 | this.loginName = loginName; 130 | this.userName = userName; 131 | this.password = password; 132 | this.sex = sex; 133 | this.birthday = birthday; 134 | this.email = email; 135 | this.qq = qq; 136 | this.roleId = roleId; 137 | this.isActive = isActive; 138 | this.createDate = createDate; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 财务管理系统 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |
17 | 18 |
19 |
财务管理系统
20 |
21 |
22 |
23 | 24 |
25 |
26 | 27 |
28 | 29 |
30 |
31 |
32 | 33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 | 42 |
43 | 44 |
45 | 验证码 46 |
47 |
48 |
49 | 50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |

财务管理系统 © 2018

58 |
59 |
60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/main/java/com/ming/dao/BaseDao.java: -------------------------------------------------------------------------------- 1 | package com.ming.dao; 2 | 3 | import java.sql.Connection; 4 | import java.sql.ResultSet; 5 | import java.sql.ResultSetMetaData; 6 | import java.sql.SQLException; 7 | import java.sql.Statement; 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | import com.ming.util.ConnectionPool; 14 | import com.ming.util.ConsoleMessage; 15 | 16 | /** 17 | * 基础数据库连接类 18 | * @author Ming 19 | * @description 连接数据库和提供基础方法 20 | * @date 2015-02-21 21 | */ 22 | public class BaseDao { 23 | /** 24 | * 数据库连接池 25 | */ 26 | final static ConnectionPool connectionPool = new ConnectionPool(); 27 | 28 | /** 29 | * 执行SQL语句进行数据库查询并返回数据 30 | * @param sql SQL语句 31 | * @return 32 | */ 33 | public static List> load(final String sql) { 34 | List> list = new ArrayList>(); 35 | Connection connection = null; 36 | Statement statement = null; 37 | try { 38 | connection = getConnection(); 39 | statement = connection.createStatement(); 40 | ResultSet resultSet = statement.executeQuery(sql); 41 | ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); 42 | int numberOfColumns = resultSetMetaData.getColumnCount(); 43 | 44 | // 获取字段名 45 | String[] keys = new String[numberOfColumns]; 46 | for (int i = 0; i < numberOfColumns; i++) 47 | keys[i] = resultSetMetaData.getColumnLabel(i + 1); 48 | 49 | // 获取对应的值 50 | while (resultSet.next()) { 51 | Map map = new HashMap(); 52 | for (int i = 0; i < numberOfColumns; i++) 53 | map.put(keys[i], resultSet.getObject(i + 1)); 54 | 55 | list.add(map); 56 | } 57 | 58 | ConsoleMessage.info(sql); 59 | } catch (Exception e) { 60 | ConsoleMessage.warn("数据库操作失败"); 61 | e.printStackTrace(); 62 | 63 | // 关闭连接 64 | closeAll(connection, statement); 65 | return null; 66 | } 67 | 68 | // 关闭连接 69 | closeAll(connection, statement); 70 | 71 | return list; 72 | } 73 | 74 | /** 75 | * 执行SQL语句进行数据库操作并返回是否成功 76 | * @param sql 77 | * @return 是否执行成功 78 | */ 79 | public static boolean execute(final String sql) { 80 | boolean result = false; 81 | Connection connection = null; 82 | Statement statement = null; 83 | 84 | try { 85 | connection = getConnection(); 86 | statement = connection.createStatement(); 87 | statement.execute(sql); 88 | ConsoleMessage.info(sql); 89 | result = true; 90 | } catch (SQLException e) { 91 | ConsoleMessage.warn("数据库操作失败"); 92 | e.printStackTrace(); 93 | 94 | // 关闭连接 95 | closeAll(connection, statement); 96 | return false; 97 | } 98 | 99 | // 关闭连接 100 | closeAll(connection, statement); 101 | 102 | return result; 103 | } 104 | 105 | /** 106 | * 获取数据库连接 107 | * @return 数据库连接 108 | */ 109 | private static Connection getConnection() { 110 | Connection connection = null; 111 | try { 112 | // connectionPool.refreshConnections(); 113 | connection = connectionPool.getConnection(); 114 | } catch (SQLException e) { 115 | e.printStackTrace(); 116 | } 117 | return connection; 118 | } 119 | 120 | /** 121 | * 关闭数据库连接及表连接 122 | * @param connection 数据库连接 123 | * @param statement 表连接 124 | */ 125 | private static void closeAll(Connection connection, Statement statement) { 126 | try { 127 | if (connection != null && statement != null) { 128 | statement.close(); 129 | connectionPool.returnConnection(connection); 130 | } 131 | } catch (Exception e) { 132 | e.printStackTrace(); 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/main/webapp/view/apply.html: -------------------------------------------------------------------------------- 1 |
2 | 19 |
20 |
21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
#日期事项金额(元)状态记录人创建日期备注
无数据
52 |
53 | 数据总数: 54 | 总计金额: 55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 |
72 |
73 | 74 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/MailUtil.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.Properties; 6 | 7 | import javax.mail.Authenticator; 8 | import javax.mail.Message.RecipientType; 9 | import javax.mail.MessagingException; 10 | import javax.mail.PasswordAuthentication; 11 | import javax.mail.Session; 12 | import javax.mail.Transport; 13 | import javax.mail.internet.InternetAddress; 14 | import javax.mail.internet.MimeMessage; 15 | 16 | /** 17 | * 18 | * @author Ming 邮箱发送工具
19 | * 参照http://blog.163.com/java_star/blog/static/11771480520136511023957/ 20 | */ 21 | public class MailUtil { 22 | private static boolean isInited = false; 23 | private static Properties properties = new Properties(); 24 | 25 | public static void sendInBackground(String address, String subject, String content) { 26 | new SendTask(address, subject, content).start(); 27 | } 28 | 29 | public static boolean send(String address, String subject, String content) { 30 | return new SendTask(address, subject, content).send(); 31 | } 32 | 33 | public static void sendToAdminInBackground(String subject, String content) { 34 | new SendTask(null, subject, content).start(); 35 | } 36 | 37 | public static boolean sendToAdmin(String subject, String content) { 38 | return new SendTask(null, subject, content).send(); 39 | } 40 | 41 | public static void init() { 42 | try { 43 | // 配置发送邮件的环境属性 44 | InputStream input = MailUtil.class.getResource("/mail.properties").openStream(); 45 | properties.load(input); 46 | isInited = true; 47 | System.out.println(properties); 48 | } catch (IOException e) { 49 | e.printStackTrace(); 50 | } 51 | } 52 | 53 | private static class SendTask extends Thread { 54 | private String address; 55 | private String subject; 56 | private String content; 57 | 58 | @Override 59 | public void run() { 60 | send(); 61 | } 62 | 63 | public boolean send() { 64 | try { 65 | if (!isInited) 66 | init(); 67 | 68 | if (properties.getProperty("status").equals("off")) 69 | return false; 70 | 71 | // 构建授权信息,用于进行SMTP进行身份验证 72 | Authenticator authenticator = new Authenticator() { 73 | @Override 74 | protected PasswordAuthentication getPasswordAuthentication() { 75 | // 用户名、密码 76 | String userName = properties.getProperty("mail.user"); 77 | String password = properties.getProperty("mail.password"); 78 | return new PasswordAuthentication(userName, password); 79 | } 80 | }; 81 | 82 | // 使用环境属性和授权信息,创建邮件会话 83 | Session mailSession = Session.getInstance(properties, authenticator); 84 | // 创建邮件消息 85 | MimeMessage message = new MimeMessage(mailSession); 86 | // 设置发件人 87 | InternetAddress form = new InternetAddress(properties.getProperty("mail.user")); 88 | message.setFrom(form); 89 | 90 | // 设置收件人 91 | InternetAddress to = new InternetAddress(address == null ? properties.getProperty("admin") : address); 92 | message.setRecipient(RecipientType.TO, to); 93 | 94 | // 设置邮件标题 95 | message.setSubject(subject); 96 | 97 | // 设置邮件的内容体 98 | message.setContent(content, "text/html;charset=UTF-8"); 99 | 100 | // 发送邮件 101 | Transport.send(message); 102 | 103 | return true; 104 | } catch (MessagingException e) { 105 | e.printStackTrace(); 106 | return false; 107 | } 108 | } 109 | 110 | public SendTask(String address, String subject, String content) { 111 | this.address = address; 112 | this.subject = subject; 113 | this.content = content; 114 | } 115 | } 116 | 117 | public static void main(String[] args) { 118 | init(); 119 | System.out.println(properties); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/com/ming/action/RoleAction.java: -------------------------------------------------------------------------------- 1 | package com.ming.action; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.google.gson.Gson; 7 | import com.ming.entity.Role; 8 | import com.ming.service.IRoleService; 9 | import com.ming.service.RoleService; 10 | import com.ming.util.Permission; 11 | import com.ming.util.WebUtil; 12 | import com.opensymphony.xwork2.ActionSupport; 13 | 14 | public class RoleAction extends ActionSupport { 15 | private static final long serialVersionUID = 1L; 16 | 17 | static final Gson GSON = new Gson(); 18 | static final IRoleService roleService = new RoleService(); 19 | 20 | /* 开始配置数据接收 */ 21 | private int id; 22 | private String role; 23 | 24 | public int getId() { 25 | return id; 26 | } 27 | 28 | public void setId(int id) { 29 | this.id = id; 30 | } 31 | 32 | public String getRole() { 33 | return role; 34 | } 35 | 36 | public void setRole(String role) { 37 | this.role = role; 38 | } 39 | /* 结束配置数据接收 */ 40 | 41 | /** 42 | * 读取多条数据 43 | */ 44 | @Permission 45 | public void load() { 46 | try { 47 | String[] params = new String[] {"roleId", "roleName"}; 48 | 49 | List> datas = roleService.load(params, "1=1 ORDER BY roleId DESC"); 50 | if (datas != null) { 51 | String json = GSON.toJson(datas); 52 | WebUtil.writeJson(json); 53 | } else { 54 | WebUtil.writeJson(WebUtil.JSON_ERROR); 55 | } 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | WebUtil.writeJson(WebUtil.JSON_ERROR); 59 | } 60 | } 61 | 62 | /** 63 | * 获取数据条数 64 | */ 65 | @Permission 66 | public void count() { 67 | try { 68 | int length = roleService.count(); 69 | if (length != -1) { 70 | String json = "{\"count\":" + length + "}"; 71 | WebUtil.writeJson(json); 72 | } else { 73 | WebUtil.writeJson(WebUtil.JSON_ERROR); 74 | } 75 | } catch (Exception e) { 76 | e.printStackTrace(); 77 | WebUtil.writeJson(WebUtil.JSON_ERROR); 78 | } 79 | } 80 | 81 | /** 82 | * 读取一条数据 83 | */ 84 | @Permission 85 | public void loadOne() { 86 | try { 87 | String[] params = new String[] {"roleId", "roleName"}; 88 | 89 | Map data = roleService.loadOne(params, "roleId = '" + id + "'"); 90 | if (data != null) { 91 | String json = GSON.toJson(data); 92 | WebUtil.writeJson(json); 93 | } else { 94 | WebUtil.writeJson(WebUtil.JSON_ERROR); 95 | } 96 | } catch (Exception e) { 97 | e.printStackTrace(); 98 | WebUtil.writeJson(WebUtil.JSON_ERROR); 99 | } 100 | } 101 | 102 | /** 103 | * 保存一条数据 104 | */ 105 | @Permission 106 | public void save() { 107 | try { 108 | Role roleObject = GSON.fromJson(role, Role.class); 109 | 110 | boolean isSucceed = roleService.save(roleObject); 111 | if (isSucceed) { 112 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 113 | } else { 114 | WebUtil.writeJson(WebUtil.JSON_ERROR); 115 | } 116 | } catch (Exception e) { 117 | e.printStackTrace(); 118 | WebUtil.writeJson(WebUtil.JSON_ERROR); 119 | } 120 | } 121 | 122 | /** 123 | * 修改一条数据 124 | */ 125 | @Permission 126 | public void edit() { 127 | try { 128 | Role roleObject = GSON.fromJson(role, Role.class); 129 | 130 | boolean isSucceed = roleService.update(roleObject); 131 | if (isSucceed) { 132 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 133 | } else { 134 | WebUtil.writeJson(WebUtil.JSON_ERROR); 135 | } 136 | } catch (Exception e) { 137 | e.printStackTrace(); 138 | WebUtil.writeJson(WebUtil.JSON_ERROR); 139 | } 140 | } 141 | 142 | /** 143 | * 删除一条数据 144 | */ 145 | @Permission 146 | public void delete() { 147 | try { 148 | Role roleObject = new Role(id); 149 | 150 | boolean isSucceed = roleService.delete(roleObject); 151 | if (isSucceed) { 152 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 153 | } else { 154 | WebUtil.writeJson(WebUtil.JSON_ERROR); 155 | } 156 | } catch (Exception e) { 157 | e.printStackTrace(); 158 | WebUtil.writeJson(WebUtil.JSON_ERROR); 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/main/webapp/js/view/apply.js: -------------------------------------------------------------------------------- 1 | app.controller("applyController", function($scope) { 2 | $scope.dateFormat = function(data) { 3 | return dateFormat(data); 4 | }; 5 | $scope.statusFormat = function(data) { 6 | switch (data) { 7 | case 0: return "未支付"; break; 8 | case 1: return "已支付"; break; 9 | case 2: return "待审核"; break; 10 | case 3: return "不通过"; break; 11 | default: return ""; 12 | } 13 | }; 14 | $scope.statusClass = function(data) { 15 | switch (data) { 16 | // case 0: return "info"; break; 17 | case 1: return "success"; break; 18 | case 2: return "warning"; break; 19 | case 3: return "danger"; break; 20 | default: return ""; 21 | } 22 | }; 23 | $scope.getCondition = function() { 24 | var condition = { 25 | status: $scope.status 26 | }; 27 | 28 | return condition; 29 | }; 30 | $scope.load = function() { 31 | $.ajax({ 32 | url: "billForOut_loadMine.action", 33 | type: "POST", 34 | dataType: "json", 35 | data: { 36 | curPage: $scope.curPage, 37 | limit: $scope.limit, 38 | condition: JSON.stringify($scope.getCondition()) 39 | }, 40 | beforeSend: function() { 41 | showAlert("正在加载数据", "warning", 0); 42 | }, 43 | complete: function() { 44 | showAlert("数据加载完成", "success", 1000); 45 | }, 46 | success: function(data) { 47 | $scope.billForOuts = data; 48 | $scope.refreshPager(); 49 | $scope.$apply(); 50 | if (data.result) 51 | alert(data.result); 52 | }, 53 | error: function() { 54 | alert("请求错误"); 55 | } 56 | }); 57 | }; 58 | $scope.refreshPager = function() { 59 | switch ($scope.pages) { 60 | case 0: $scope.pager = [null, null, null]; break; 61 | case 1: $scope.pager = [1, null, null]; break; 62 | case 2: $scope.pager = [1, 2, null]; break; 63 | case 3: $scope.pager = [1, 2, 3]; break; 64 | default: 65 | if ($scope.curPage <= 2) 66 | $scope.pager = [1, 2, 3]; 67 | else if ($scope.curPage >= $scope.pages - 1) 68 | $scope.pager = [$scope.pages - 2, $scope.pages - 1, $scope.pages]; 69 | else 70 | $scope.pager = [$scope.curPage - 1, $scope.curPage, $scope.curPage + 1]; 71 | } 72 | }; 73 | $scope.firstPage = function() { 74 | $scope.curPage = 1; 75 | $scope.load(); 76 | }; 77 | $scope.lastPage = function() { 78 | $scope.curPage = $scope.pages; 79 | $scope.load(); 80 | }; 81 | $scope.prevPage = function() { 82 | $scope.curPage--; 83 | $scope.load(); 84 | }; 85 | $scope.nextPage = function() { 86 | $scope.curPage++; 87 | $scope.load(); 88 | }; 89 | $scope.changePage = function(page) { 90 | $scope.curPage = page; 91 | $scope.load(); 92 | }; 93 | $scope.sumUp = function() { 94 | $.ajax({ 95 | url: "billForOut_sumUpMine.action", 96 | type: "POST", 97 | dataType: "json", 98 | data: { 99 | condition: JSON.stringify($scope.getCondition()) 100 | }, 101 | beforeSend: function() {}, 102 | complete: function() {}, 103 | success: function(data) { 104 | if (data.amount > 0) 105 | $scope.totalAmount = data.amount; 106 | else 107 | $scope.totalAmount = 0; 108 | $scope.$apply(); 109 | if (data.result) 110 | alert(data.result); 111 | }, 112 | error: function() { 113 | alert("请求错误"); 114 | } 115 | }); 116 | }; 117 | $scope.init = function() { 118 | $scope.pager = [1, null, null]; 119 | $scope.curPage = 1; 120 | $scope.limit = 10; 121 | $scope.pages = 0; 122 | $.ajax({ 123 | url: "billForOut_countMine.action", 124 | type: "POST", 125 | dataType: "json", 126 | data: { 127 | condition: JSON.stringify($scope.getCondition()) 128 | }, 129 | beforeSend: function() {}, 130 | complete: function() {}, 131 | success: function(data) { 132 | if (data.count > 0) { 133 | $scope.total = data.count; 134 | $scope.pages = Math.ceil(data.count / $scope.limit); 135 | $scope.sumUp(); 136 | $scope.load(); 137 | } else { 138 | $scope.billForOuts = []; 139 | $scope.curPage = 0; 140 | $scope.pages = 0; 141 | $scope.totalAmount = 0; 142 | $scope.$apply(); 143 | } 144 | if (data.result) 145 | alert(data.result); 146 | }, 147 | error: function() { 148 | alert("请求错误"); 149 | } 150 | }); 151 | }; 152 | $scope.init(); 153 | }); 154 | /* By Ming */ 155 | -------------------------------------------------------------------------------- /src/main/webapp/plugins/angularjs/angular-route.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | AngularJS v1.3.14 3 | (c) 2010-2014 Google, Inc. http://angularjs.org 4 | License: MIT 5 | */ 6 | (function(q,d,C){'use strict';function v(r,k,h){return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",link:function(a,f,b,c,y){function z(){l&&(h.cancel(l),l=null);m&&(m.$destroy(),m=null);n&&(l=h.leave(n),l.then(function(){l=null}),n=null)}function x(){var b=r.current&&r.current.locals;if(d.isDefined(b&&b.$template)){var b=a.$new(),c=r.current;n=y(b,function(b){h.enter(b,null,n||f).then(function(){!d.isDefined(t)||t&&!a.$eval(t)||k()});z()});m=c.scope=b;m.$emit("$viewContentLoaded"); 7 | m.$eval(w)}else z()}var m,n,l,t=b.autoscroll,w=b.onload||"";a.$on("$routeChangeSuccess",x);x()}}}function A(d,k,h){return{restrict:"ECA",priority:-400,link:function(a,f){var b=h.current,c=b.locals;f.html(c.$template);var y=d(f.contents());b.controller&&(c.$scope=a,c=k(b.controller,c),b.controllerAs&&(a[b.controllerAs]=c),f.data("$ngControllerController",c),f.children().data("$ngControllerController",c));y(a)}}}q=d.module("ngRoute",["ng"]).provider("$route",function(){function r(a,f){return d.extend(Object.create(a), 8 | f)}function k(a,d){var b=d.caseInsensitiveMatch,c={originalPath:a,regexp:a},h=c.keys=[];a=a.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)([\?\*])?/g,function(a,d,b,c){a="?"===c?c:null;c="*"===c?c:null;h.push({name:b,optional:!!a});d=d||"";return""+(a?"":d)+"(?:"+(a?d:"")+(c&&"(.+?)"||"([^/]+)")+(a||"")+")"+(a||"")}).replace(/([\/$\*])/g,"\\$1");c.regexp=new RegExp("^"+a+"$",b?"i":"");return c}var h={};this.when=function(a,f){var b=d.copy(f);d.isUndefined(b.reloadOnSearch)&&(b.reloadOnSearch=!0); 9 | d.isUndefined(b.caseInsensitiveMatch)&&(b.caseInsensitiveMatch=this.caseInsensitiveMatch);h[a]=d.extend(b,a&&k(a,b));if(a){var c="/"==a[a.length-1]?a.substr(0,a.length-1):a+"/";h[c]=d.extend({redirectTo:a},k(c,b))}return this};this.caseInsensitiveMatch=!1;this.otherwise=function(a){"string"===typeof a&&(a={redirectTo:a});this.when(null,a);return this};this.$get=["$rootScope","$location","$routeParams","$q","$injector","$templateRequest","$sce",function(a,f,b,c,k,q,x){function m(b){var e=s.current; 10 | (v=(p=l())&&e&&p.$$route===e.$$route&&d.equals(p.pathParams,e.pathParams)&&!p.reloadOnSearch&&!w)||!e&&!p||a.$broadcast("$routeChangeStart",p,e).defaultPrevented&&b&&b.preventDefault()}function n(){var u=s.current,e=p;if(v)u.params=e.params,d.copy(u.params,b),a.$broadcast("$routeUpdate",u);else if(e||u)w=!1,(s.current=e)&&e.redirectTo&&(d.isString(e.redirectTo)?f.path(t(e.redirectTo,e.params)).search(e.params).replace():f.url(e.redirectTo(e.pathParams,f.path(),f.search())).replace()),c.when(e).then(function(){if(e){var a= 11 | d.extend({},e.resolve),b,g;d.forEach(a,function(b,e){a[e]=d.isString(b)?k.get(b):k.invoke(b,null,null,e)});d.isDefined(b=e.template)?d.isFunction(b)&&(b=b(e.params)):d.isDefined(g=e.templateUrl)&&(d.isFunction(g)&&(g=g(e.params)),g=x.getTrustedResourceUrl(g),d.isDefined(g)&&(e.loadedTemplateUrl=g,b=q(g)));d.isDefined(b)&&(a.$template=b);return c.all(a)}}).then(function(c){e==s.current&&(e&&(e.locals=c,d.copy(e.params,b)),a.$broadcast("$routeChangeSuccess",e,u))},function(b){e==s.current&&a.$broadcast("$routeChangeError", 12 | e,u,b)})}function l(){var a,b;d.forEach(h,function(c,h){var g;if(g=!b){var k=f.path();g=c.keys;var m={};if(c.regexp)if(k=c.regexp.exec(k)){for(var l=1,n=k.length;l 2 | 21 | 22 |
23 |
24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 53 | 54 | 55 | 56 | 57 | 58 |
#日期事项金额(元)支付人状态创建日期备注操作
50 | 51 | 52 |
无数据
59 |
60 | 数据总数: 61 | 总计金额: 62 | 财务余额: 63 | 距离付清还需: 64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
79 |
80 |
81 |
82 | 83 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/HtmlUtil.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.net.URL; 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * HTML工具类
11 | * 参数资料: http://blog 13 | * .sina.com.cn/s/blog_53b91ff30100kbv2.html 14 | * 15 | * @author Ming 16 | * @date 2015-10-18 17 | */ 18 | public class HtmlUtil { 19 | public static String removeHTMLTags(String str, String tags) { 20 | if (str == null) 21 | return null; 22 | if (tags == null) 23 | return str; 24 | String regx = "(]*>)"; 25 | Matcher matcher; 26 | Pattern pattern = Pattern.compile(regx, Pattern.CASE_INSENSITIVE 27 | + Pattern.MULTILINE);// 不区分大小写 28 | // 此处需要循环匹配,防止恶意构造的字符串 29 | while ((matcher = pattern.matcher(str)).find()) { 30 | str = matcher.replaceAll(""); 31 | } 32 | 33 | return str; 34 | } 35 | 36 | public static String removeEvents(String content) { 37 | 38 | String regx = "(<[^<]*)(on\\w*\\x20*=|javascript:)"; 39 | Pattern pattern = Pattern.compile(regx, Pattern.CASE_INSENSITIVE 40 | + Pattern.MULTILINE);// 不区分大小写 41 | Matcher matcher; 42 | String ts = content; 43 | // 此处需要循环匹配,防止恶意构造的字符串如 onclick=onclick=xxx 44 | while ((matcher = pattern.matcher(ts)).find()) { 45 | ts = matcher.replaceAll("$1"); 46 | } 47 | return ts; 48 | } 49 | 50 | public static String makeSafe(String content) { 51 | return removeEvents(removeHTMLTags( 52 | content, 53 | "html|body|head|title|style|video|canvas|script|iframe|frameset|frame|object|embed|xml|input|button|textarea|select|pre|option|plaintext|form")); 54 | } 55 | 56 | public static String makeSafe(String content, String tags) { 57 | if (tags == null) 58 | return makeSafe(content); 59 | return removeEvents(removeHTMLTags(content, tags)); 60 | } 61 | 62 | /** 63 | * 获取网页内容
64 | * 参考:http://www.cnblogs.com/langlang/archive/2010/12/10/1901744.html 67 | * 68 | * @param url 69 | * 网页URL 70 | * @return 网页内容 71 | */ 72 | public static String getContent(String url) { 73 | try { 74 | StringBuilder stringBuilder = new StringBuilder(); 75 | 76 | BufferedReader in = new BufferedReader(new InputStreamReader( 77 | new URL(url).openStream(), "UTF-8")); 78 | String line; 79 | while ((line = in.readLine()) != null) { 80 | stringBuilder.append(line); 81 | } 82 | 83 | return stringBuilder.toString(); 84 | } catch (Exception e) { 85 | e.printStackTrace(); 86 | return null; 87 | } 88 | } 89 | 90 | /** 91 | * 删除HTML文本中的所有HTML标签
92 | * 参考:http://www. 93 | * cnblogs.com/newsouls/p/3995394.html 94 | * 95 | * @param htmlStr HTML文本 96 | * @return 去除HTML标签的文本 97 | */ 98 | public static String delHTMLTag(String htmlStr) { 99 | String regEx_script = "]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式 100 | String regEx_style = "]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式 101 | String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式 102 | 103 | Pattern p_script = Pattern.compile(regEx_script, 104 | Pattern.CASE_INSENSITIVE); 105 | Matcher m_script = p_script.matcher(htmlStr); 106 | htmlStr = m_script.replaceAll(""); // 过滤script标签 107 | 108 | Pattern p_style = Pattern 109 | .compile(regEx_style, Pattern.CASE_INSENSITIVE); 110 | Matcher m_style = p_style.matcher(htmlStr); 111 | htmlStr = m_style.replaceAll(""); // 过滤style标签 112 | 113 | Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE); 114 | Matcher m_html = p_html.matcher(htmlStr); 115 | htmlStr = m_html.replaceAll(""); // 过滤html标签 116 | 117 | return htmlStr.trim(); // 返回文本字符串 118 | } 119 | 120 | public static String substring(String content, int length) { 121 | if (content == null) 122 | return ""; 123 | content = content.replaceAll("\n", " "); 124 | if (content.length() <= length) { 125 | return content; 126 | } else { 127 | return content.substring(0, length); 128 | } 129 | } 130 | 131 | public static String formatHtmlSpecialChars(String str) { 132 | str = str.replaceAll("&", "&"); 133 | str = str.replaceAll("<", "<"); 134 | str = str.replaceAll(">", ">"); 135 | str = str.replaceAll("\"", """); 136 | return str; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/WebUtil.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | import javax.servlet.http.HttpSession; 8 | 9 | import org.apache.struts2.ServletActionContext; 10 | 11 | import com.opensymphony.xwork2.ActionSupport; 12 | 13 | /** 14 | * WebUtil类 15 | * @author Ming 16 | * @description 基础Struts2的WebUtil,用于向客户端发送字符串 17 | * @date 2015-03-13 18 | */ 19 | public class WebUtil extends ActionSupport { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public static final String JSON_SUCCESS = "{\"result\":\"success\"}"; 23 | public static final String JSON_ERROR = "{\"result\":\"服务器错误\"}"; 24 | public static final String JSON_LOGIN = "{\"result\":\"用户未登录或会话已过期\"}"; 25 | public static final String JSON_NO_PERMISSION = "{\"result\":\"没有足够的权限\"}"; 26 | public static final String JSON_WRONG_VALIDCODE = "{\"result\":\"验证码错误\"}"; 27 | 28 | /** 29 | * 向前台返回数据 30 | * @param string 数据 31 | */ 32 | public static void write(String string) { 33 | try { 34 | HttpServletResponse response = ServletActionContext.getResponse(); 35 | response.setCharacterEncoding("UTF-8"); 36 | PrintWriter out = response.getWriter(); 37 | out.write(string); 38 | out.flush(); 39 | out.close(); 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | } 44 | 45 | /** 46 | * 向前台返回文本 47 | * @param string 数据 48 | */ 49 | public static void writeText(String string) { 50 | try { 51 | HttpServletResponse response = ServletActionContext.getResponse(); 52 | response.setContentType("text/plain; charset=UTF-8"); 53 | PrintWriter out = response.getWriter(); 54 | out.write(string); 55 | out.flush(); 56 | out.close(); 57 | } catch (Exception e) { 58 | e.printStackTrace(); 59 | } 60 | } 61 | 62 | /** 63 | * 向前台返回XML 64 | * @param string 数据 65 | */ 66 | public static void writeXml(String string) { 67 | try { 68 | HttpServletResponse response = ServletActionContext.getResponse(); 69 | response.setContentType("text/xml; charset=UTF-8"); 70 | PrintWriter out = response.getWriter(); 71 | out.write(string); 72 | out.flush(); 73 | out.close(); 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | } 77 | } 78 | 79 | /** 80 | * 向前台返回JSON 81 | * @param string 数据 82 | */ 83 | public static void writeJson(String string) { 84 | try { 85 | HttpServletResponse response = ServletActionContext.getResponse(); 86 | response.setContentType("application/json; charset=UTF-8"); 87 | PrintWriter out = response.getWriter(); 88 | out.write(string); 89 | out.flush(); 90 | out.close(); 91 | } catch (Exception e) { 92 | e.printStackTrace(); 93 | } 94 | } 95 | 96 | /** 97 | * 向前台返回JSONP 98 | * @param string 数据 99 | */ 100 | public static void writeJsonp(String string) { 101 | try { 102 | HttpServletResponse response = ServletActionContext.getResponse(); 103 | response.setContentType("text/javascript; charset=UTF-8"); 104 | PrintWriter out = response.getWriter(); 105 | out.write("handleResponse(" + string + ")"); 106 | out.flush(); 107 | out.close(); 108 | } catch (Exception e) { 109 | e.printStackTrace(); 110 | } 111 | } 112 | 113 | /** 114 | * 控制前台跳转页面 115 | * @param url URL 116 | */ 117 | public static void sendRedirect(String url) { 118 | try { 119 | HttpServletRequest request = ServletActionContext.getRequest(); 120 | HttpServletResponse response = ServletActionContext.getResponse(); 121 | String path = request.getContextPath(); 122 | response.sendRedirect(path + url); 123 | } catch (Exception e) { 124 | e.printStackTrace(); 125 | } 126 | } 127 | 128 | /** 129 | * 获取request对象 130 | * @return 131 | */ 132 | public static HttpServletRequest getRequest() { 133 | try { 134 | HttpServletRequest request = ServletActionContext.getRequest(); 135 | request.setCharacterEncoding("UTF-8"); 136 | return request; 137 | } catch (Exception e) { 138 | e.printStackTrace(); 139 | return null; 140 | } 141 | } 142 | 143 | /** 144 | * 获取response对象 145 | * @return 146 | */ 147 | public static HttpServletResponse getResponse() { 148 | try { 149 | HttpServletResponse response = ServletActionContext.getResponse(); 150 | response.setCharacterEncoding("UTF-8"); 151 | return response; 152 | } catch (Exception e) { 153 | e.printStackTrace(); 154 | return null; 155 | } 156 | } 157 | 158 | /** 159 | * 获取session对象 160 | * @return 161 | */ 162 | public HttpSession getSession() { 163 | try { 164 | HttpSession session = ServletActionContext.getRequest().getSession(); 165 | return session; 166 | } catch (Exception e) { 167 | e.printStackTrace(); 168 | return null; 169 | } 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /src/main/webapp/js/view/pay.js: -------------------------------------------------------------------------------- 1 | app.controller("payController", function($scope) { 2 | $scope.dateFormat = function(data) { 3 | return dateFormat(data); 4 | }; 5 | $scope.statusFormat = function(data) { 6 | switch (data) { 7 | case 0: return "未支付"; break; 8 | case 1: return "已支付"; break; 9 | default: return ""; 10 | } 11 | }; 12 | $scope.getCondition = function() { 13 | var condition = { 14 | payName: $scope.payName, 15 | status: $scope.status 16 | }; 17 | 18 | return condition; 19 | }; 20 | $scope.load = function() { 21 | $.ajax({ 22 | url: "billForOut_loadPay.action", 23 | type: "POST", 24 | dataType: "json", 25 | data: { 26 | curPage: $scope.curPage, 27 | limit: $scope.limit, 28 | condition: JSON.stringify($scope.getCondition()) 29 | }, 30 | beforeSend: function() { 31 | showAlert("正在加载数据", "warning", 0); 32 | }, 33 | complete: function() { 34 | showAlert("数据加载完成", "success", 1000); 35 | }, 36 | success: function(data) { 37 | $scope.billForOuts = data; 38 | $scope.refreshPager(); 39 | $scope.$apply(); 40 | if (data.result) 41 | alert(data.result); 42 | }, 43 | error: function() { 44 | alert("请求错误"); 45 | } 46 | }); 47 | }; 48 | $scope.refreshPager = function() { 49 | switch ($scope.pages) { 50 | case 0: $scope.pager = [null, null, null]; break; 51 | case 1: $scope.pager = [1, null, null]; break; 52 | case 2: $scope.pager = [1, 2, null]; break; 53 | case 3: $scope.pager = [1, 2, 3]; break; 54 | default: 55 | if ($scope.curPage <= 2) 56 | $scope.pager = [1, 2, 3]; 57 | else if ($scope.curPage >= $scope.pages - 1) 58 | $scope.pager = [$scope.pages - 2, $scope.pages - 1, $scope.pages]; 59 | else 60 | $scope.pager = [$scope.curPage - 1, $scope.curPage, $scope.curPage + 1]; 61 | } 62 | }; 63 | $scope.firstPage = function() { 64 | $scope.curPage = 1; 65 | $scope.load(); 66 | }; 67 | $scope.lastPage = function() { 68 | $scope.curPage = $scope.pages; 69 | $scope.load(); 70 | }; 71 | $scope.prevPage = function() { 72 | $scope.curPage--; 73 | $scope.load(); 74 | }; 75 | $scope.nextPage = function() { 76 | $scope.curPage++; 77 | $scope.load(); 78 | }; 79 | $scope.changePage = function(page) { 80 | $scope.curPage = page; 81 | $scope.load(); 82 | }; 83 | $scope.paid = function(id) { 84 | if (confirm("确认已支付?")) { 85 | $.ajax({ 86 | url: "billForOut_paid.action", 87 | type: "POST", 88 | dataType: "json", 89 | data: { 90 | id: id 91 | }, 92 | beforeSend: function() {}, 93 | complete: function() {}, 94 | success: function(data) { 95 | if (data.result === "success") { 96 | alert("记录更新成功"); 97 | $scope.init(); 98 | } else { 99 | alert(data.result); 100 | } 101 | }, 102 | error: function() { 103 | alert("请求错误"); 104 | } 105 | }); 106 | } 107 | }; 108 | $scope.unpaid = function(id) { 109 | if (confirm("确认未支付?")) { 110 | $.ajax({ 111 | url: "billForOut_unpaid.action", 112 | type: "POST", 113 | dataType: "json", 114 | data: { 115 | id: id 116 | }, 117 | beforeSend: function() {}, 118 | complete: function() {}, 119 | success: function(data) { 120 | if (data.result === "success") { 121 | alert("记录更新成功"); 122 | $scope.init(); 123 | } else { 124 | alert(data.result); 125 | } 126 | }, 127 | error: function() { 128 | alert("请求错误"); 129 | } 130 | }); 131 | } 132 | }; 133 | $scope.sumUp = function() { 134 | $.ajax({ 135 | url: "billForOut_sumUpPay.action", 136 | type: "POST", 137 | dataType: "json", 138 | data: { 139 | condition: JSON.stringify($scope.getCondition()) 140 | }, 141 | beforeSend: function() {}, 142 | complete: function() {}, 143 | success: function(data) { 144 | if (data.amount > 0) 145 | $scope.totalAmount = data.amount; 146 | else 147 | $scope.totalAmount = 0; 148 | $scope.$apply(); 149 | if (data.result) 150 | alert(data.result); 151 | }, 152 | error: function() { 153 | alert("请求错误"); 154 | } 155 | }); 156 | }; 157 | $scope.sumUpMoney = function() { 158 | $.ajax({ 159 | url: "billForIn_sumUpMoney.action", 160 | type: "POST", 161 | dataType: "json", 162 | data: {}, 163 | beforeSend: function() {}, 164 | complete: function() {}, 165 | success: function(data) { 166 | $scope.totalMoney = data.amount; 167 | $scope.$apply(); 168 | if (data.result) 169 | alert(data.result); 170 | }, 171 | error: function() { 172 | alert("请求错误"); 173 | } 174 | }); 175 | }; 176 | $scope.sumUpNeed = function() { 177 | $.ajax({ 178 | url: "billForOut_sumUpNeed.action", 179 | type: "POST", 180 | dataType: "json", 181 | data: {}, 182 | beforeSend: function() {}, 183 | complete: function() {}, 184 | success: function(data) { 185 | $scope.needMoney = data.amount; 186 | $scope.$apply(); 187 | if (data.result) 188 | alert(data.result); 189 | }, 190 | error: function() { 191 | alert("请求错误"); 192 | } 193 | }); 194 | }; 195 | $scope.init = function() { 196 | $scope.pager = [1, null, null]; 197 | $scope.curPage = 1; 198 | $scope.limit = 10; 199 | $scope.pages = 0; 200 | $.ajax({ 201 | url: "billForOut_countPay.action", 202 | type: "POST", 203 | dataType: "json", 204 | data: { 205 | condition: JSON.stringify($scope.getCondition()) 206 | }, 207 | beforeSend: function() {}, 208 | complete: function() {}, 209 | success: function(data) { 210 | if (data.count > 0) { 211 | $scope.total = data.count; 212 | $scope.pages = Math.ceil(data.count / $scope.limit); 213 | $scope.sumUp(); 214 | $scope.sumUpMoney(); 215 | $scope.sumUpNeed(); 216 | $scope.load(); 217 | } else { 218 | $scope.billForOuts = []; 219 | $scope.curPage = 0; 220 | $scope.pages = 0; 221 | $scope.totalAmount = 0; 222 | $scope.needMoney = 0; 223 | $scope.$apply(); 224 | } 225 | if (data.result) 226 | alert(data.result); 227 | }, 228 | error: function() { 229 | alert("请求错误"); 230 | } 231 | }); 232 | }; 233 | $scope.init(); 234 | }); 235 | /* By Ming */ 236 | -------------------------------------------------------------------------------- /src/main/java/com/ming/service/BillForInService.java: -------------------------------------------------------------------------------- 1 | package com.ming.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.ming.dao.BaseDao; 7 | import com.ming.dao.CommonDao; 8 | import com.ming.entity.BillForIn; 9 | import com.ming.entity.BillForOut; 10 | 11 | /** 12 | * BillForInService 13 | * @author Ming 14 | * @description 15 | * @date 2015-03-24 16 | */ 17 | public class BillForInService implements IBillForInService { 18 | private static final CommonDao db = new CommonDao(); 19 | 20 | @Override 21 | public List> load() { 22 | return db.load(BillForIn.class); 23 | } 24 | 25 | @Override 26 | public List> load(String condition) { 27 | return db.load(BillForIn.class, condition); 28 | } 29 | 30 | @Override 31 | public List> load(String[] params, String condition) { 32 | return db.load(params, BillForIn.class, condition); 33 | } 34 | 35 | @Override 36 | public List> load(String[] params, String condition, int curPage, int limit) { 37 | return db.load(params, BillForIn.class, condition, curPage, limit); 38 | } 39 | 40 | @Override 41 | public Map loadOne(String condition) { 42 | return db.loadOne(BillForIn.class, condition); 43 | } 44 | 45 | @Override 46 | public Map loadOne(String[] params, String condition) { 47 | return db.loadOne(params, BillForIn.class, condition); 48 | } 49 | 50 | @Override 51 | public boolean save(BillForIn obj) { 52 | return db.insert(obj); 53 | } 54 | 55 | @Override 56 | public boolean update(BillForIn obj) { 57 | return db.update(obj); 58 | } 59 | 60 | @Override 61 | public boolean delete(BillForIn obj) { 62 | return db.delete(obj); 63 | } 64 | 65 | @Override 66 | public boolean deleteByCondition(String condition) { 67 | return db.delete(BillForIn.class, condition); 68 | } 69 | 70 | @Override 71 | public int count() { 72 | return db.count(BillForIn.class); 73 | } 74 | 75 | @Override 76 | public int count(String condition) { 77 | return db.count(BillForIn.class, condition); 78 | } 79 | 80 | public BillForInService() { 81 | } 82 | 83 | public List> loadSpecial(String condition, int curPage, int limit) { 84 | String sql = "SELECT * FROM (SELECT a.id, a.date, a.amount, b.userName fromName, " 85 | + "c.userName toName, d.userName recordName, a.createDate, a.remark FROM " 86 | + "BillForIn a LEFT JOIN User b ON a.fromId = b.id LEFT JOIN User c ON a.toId " 87 | + "= c.id LEFT JOIN User d ON a.recordId = d.id) result"; 88 | if (null != condition && !"".equals(condition)) 89 | sql += " WHERE " + condition; 90 | sql += " ORDER BY date DESC LIMIT " + (curPage - 1) * limit + ", " + curPage * limit; 91 | List> data = BaseDao.load(sql); 92 | return data; 93 | } 94 | 95 | public Map loadOneSpecial(String condition) { 96 | String sql = "SELECT * FROM (SELECT a.id, a.date, a.amount, b.userName fromName, " 97 | + "c.userName toName, d.userName recordName, a.createDate, a.remark FROM " 98 | + "BillForIn a LEFT JOIN User b ON a.fromId = b.id LEFT JOIN User c ON a.toId " 99 | + "= c.id LEFT JOIN User d ON a.recordId = d.id) result"; 100 | if (null != condition && !"".equals(condition)) 101 | sql += " WHERE " + condition; 102 | List> data = BaseDao.load(sql); 103 | if (data != null && data.size() == 1) 104 | return data.get(0); 105 | else 106 | return null; 107 | } 108 | 109 | public int countSpecial(String condition) { 110 | String sql = "SELECT COUNT(*) FROM (SELECT a.id, a.date, a.amount, b.userName fromName, " 111 | + "c.userName toName, d.userName recordName, a.createDate, a.remark FROM " 112 | + "BillForIn a LEFT JOIN User b ON a.fromId = b.id LEFT JOIN User c ON a.toId = " 113 | + "c.id LEFT JOIN User d ON a.recordId = d.id) result"; 114 | if (null != condition && !"".equals(condition)) 115 | sql += " WHERE " + condition; 116 | List> data = BaseDao.load(sql); 117 | int length = -1; 118 | if (data.size() == 1) { 119 | Map map = data.get(0); 120 | if (map != null && map.size() == 1) { 121 | String count = null; 122 | try { 123 | for (Map.Entry value : map.entrySet()) 124 | count = value.getValue().toString(); 125 | length = Integer.parseInt(count); 126 | } catch (Exception e) { 127 | length = -1; 128 | } 129 | } 130 | } 131 | return length; 132 | } 133 | 134 | public double sumUp(String condition) { 135 | String sql = "SELECT SUM(amount) FROM (SELECT a.id, a.date, a.amount, b.userName fromName, " 136 | + "c.userName toName, d.userName recordName, a.createDate, a.remark FROM " 137 | + "BillForIn a LEFT JOIN User b ON a.fromId = b.id LEFT JOIN User c ON a.toId = " 138 | + "c.id LEFT JOIN User d ON a.recordId = d.id) result"; 139 | if (null != condition && !"".equals(condition)) 140 | sql += " WHERE " + condition; 141 | List> data = BaseDao.load(sql); 142 | double sum = 0; 143 | if (data.size() == 1) { 144 | Map map = data.get(0); 145 | if (map != null && map.size() == 1) { 146 | String amount = null; 147 | try { 148 | for (Map.Entry value : map.entrySet()) 149 | amount = value.getValue().toString(); 150 | sum = Double.parseDouble(amount); 151 | } catch (Exception e) { 152 | sum = 0; 153 | } 154 | } 155 | } 156 | return sum; 157 | } 158 | 159 | public double sumUpMoney() { 160 | String sql = "SELECT (bin.amount - bout.amount) amount FROM (SELECT SUM(amount) amount FROM " 161 | + "BillForIn) bin, (SELECT IFNULL(SUM(amount), 0) amount FROM BillForOut WHERE status = " 162 | + BillForOut.STATUS_PAID + ") bout"; 163 | List> data = BaseDao.load(sql); 164 | double sum = 0; 165 | if (data.size() == 1) { 166 | Map map = data.get(0); 167 | if (map != null && map.size() == 1) { 168 | String amount = null; 169 | try { 170 | for (Map.Entry value : map.entrySet()) 171 | amount = value.getValue().toString(); 172 | sum = Double.parseDouble(amount); 173 | } catch (Exception e) { 174 | sum = 0; 175 | } 176 | } 177 | } 178 | return sum; 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /src/main/webapp/js/view/review.js: -------------------------------------------------------------------------------- 1 | app.controller("reviewController", function($scope) { 2 | $scope.dateFormat = function(data) { 3 | return dateFormat(data); 4 | }; 5 | $scope.getCondition = function() { 6 | var condition = { 7 | payName: $scope.payName 8 | }; 9 | 10 | return condition; 11 | }; 12 | $scope.load = function() { 13 | $.ajax({ 14 | url: "billForOut_loadReview.action", 15 | type: "POST", 16 | dataType: "json", 17 | data: { 18 | curPage: $scope.curPage, 19 | limit: $scope.limit, 20 | condition: JSON.stringify($scope.getCondition()) 21 | }, 22 | beforeSend: function() { 23 | showAlert("正在加载数据", "warning", 0); 24 | }, 25 | complete: function() { 26 | showAlert("数据加载完成", "success", 1000); 27 | }, 28 | success: function(data) { 29 | $scope.billForOuts = data; 30 | $scope.refreshPager(); 31 | $scope.$apply(); 32 | if (data.result) 33 | alert(data.result); 34 | }, 35 | error: function() { 36 | alert("请求错误"); 37 | } 38 | }); 39 | }; 40 | $scope.refreshPager = function() { 41 | switch ($scope.pages) { 42 | case 0: $scope.pager = [null, null, null]; break; 43 | case 1: $scope.pager = [1, null, null]; break; 44 | case 2: $scope.pager = [1, 2, null]; break; 45 | case 3: $scope.pager = [1, 2, 3]; break; 46 | default: 47 | if ($scope.curPage <= 2) 48 | $scope.pager = [1, 2, 3]; 49 | else if ($scope.curPage >= $scope.pages - 1) 50 | $scope.pager = [$scope.pages - 2, $scope.pages - 1, $scope.pages]; 51 | else 52 | $scope.pager = [$scope.curPage - 1, $scope.curPage, $scope.curPage + 1]; 53 | } 54 | }; 55 | $scope.firstPage = function() { 56 | $scope.curPage = 1; 57 | $scope.load(); 58 | }; 59 | $scope.lastPage = function() { 60 | $scope.curPage = $scope.pages; 61 | $scope.load(); 62 | }; 63 | $scope.prevPage = function() { 64 | $scope.curPage--; 65 | $scope.load(); 66 | }; 67 | $scope.nextPage = function() { 68 | $scope.curPage++; 69 | $scope.load(); 70 | }; 71 | $scope.changePage = function(page) { 72 | $scope.curPage = page; 73 | $scope.load(); 74 | }; 75 | $scope.reset = function() { 76 | $scope.billForOut = { 77 | date: new Date(), 78 | amount: null 79 | }; 80 | }; 81 | $scope.add = function() { 82 | $scope.modalTitle = "新增支出"; 83 | $scope.mode = "save"; 84 | $scope.reset(); 85 | }; 86 | $scope.review = function(id) { 87 | $scope.reset(); 88 | $.ajax({ 89 | url: "billForOut_loadOneReview.action", 90 | type: "POST", 91 | dataType: "json", 92 | data: { 93 | id: id 94 | }, 95 | beforeSend: function() {}, 96 | complete: function() {}, 97 | success: function(data) { 98 | $scope.billForOut = data; 99 | $scope.billForOut.date = doubleToDate(data.date); 100 | $scope.billForOut.status = null; 101 | $scope.$apply(); 102 | if (data.result) 103 | alert(data.result); 104 | }, 105 | error: function() { 106 | alert("请求错误"); 107 | } 108 | }); 109 | }; 110 | $scope.ok = function() { 111 | var billForOut = { 112 | id: $scope.billForOut.id, 113 | date: dateToDouble($scope.billForOut.date), 114 | amount: $.trim($scope.billForOut.amount), 115 | event: $.trim($scope.billForOut.event), 116 | status: $scope.billForOut.status, 117 | remark: $scope.billForOut.remark 118 | }; 119 | $.ajax({ 120 | url: "billForOut_reviewOk.action", 121 | type: "POST", 122 | dataType: "json", 123 | data: { 124 | billForOut: JSON.stringify(billForOut) 125 | }, 126 | beforeSend: function() {}, 127 | complete: function() {}, 128 | success: function(data) { 129 | if (data.result === "success") { 130 | alert("记录更新成功"); 131 | $scope.init(); 132 | $("#billForOut-modal").modal("hide"); 133 | } else { 134 | alert(data.result); 135 | } 136 | }, 137 | error: function() { 138 | alert("请求错误"); 139 | } 140 | }); 141 | }; 142 | $scope.no = function() { 143 | var billForOut = { 144 | id: $scope.billForOut.id, 145 | date: dateToDouble($scope.billForOut.date), 146 | amount: $.trim($scope.billForOut.amount), 147 | event: $.trim($scope.billForOut.event), 148 | remark: $scope.billForOut.remark 149 | }; 150 | if (confirm("确认审核不通过?")) { 151 | $.ajax({ 152 | url: "billForOut_reviewNo.action", 153 | type: "POST", 154 | dataType: "json", 155 | data: { 156 | billForOut: JSON.stringify(billForOut) 157 | }, 158 | beforeSend: function() {}, 159 | complete: function() {}, 160 | success: function(data) { 161 | if (data.result === "success") { 162 | alert("记录更新成功"); 163 | $scope.init(); 164 | $("#billForOut-modal").modal("hide"); 165 | } else { 166 | alert(data.result); 167 | } 168 | }, 169 | error: function() { 170 | alert("请求错误"); 171 | } 172 | }); 173 | } 174 | }; 175 | $scope.sumUp = function() { 176 | $.ajax({ 177 | url: "billForOut_sumUpReview.action", 178 | type: "POST", 179 | dataType: "json", 180 | data: { 181 | condition: JSON.stringify($scope.getCondition()) 182 | }, 183 | beforeSend: function() {}, 184 | complete: function() {}, 185 | success: function(data) { 186 | if (data.amount > 0) 187 | $scope.totalAmount = data.amount; 188 | else 189 | $scope.totalAmount = 0; 190 | $scope.$apply(); 191 | if (data.result) 192 | alert(data.result); 193 | }, 194 | error: function() { 195 | alert("请求错误"); 196 | } 197 | }); 198 | }; 199 | $scope.init = function() { 200 | $scope.pager = [1, null, null]; 201 | $scope.curPage = 1; 202 | $scope.limit = 10; 203 | $scope.pages = 0; 204 | $.ajax({ 205 | url: "billForOut_countReview.action", 206 | type: "POST", 207 | dataType: "json", 208 | data: { 209 | condition: JSON.stringify($scope.getCondition()) 210 | }, 211 | beforeSend: function() {}, 212 | complete: function() {}, 213 | success: function(data) { 214 | if (data.count > 0) { 215 | $scope.total = data.count; 216 | $scope.pages = Math.ceil(data.count / $scope.limit); 217 | $scope.sumUp(); 218 | $scope.load(); 219 | } else { 220 | $scope.billForOuts = []; 221 | $scope.curPage = 0; 222 | $scope.pages = 0; 223 | $scope.totalAmount = 0; 224 | $scope.$apply(); 225 | } 226 | if (data.result) 227 | alert(data.result); 228 | }, 229 | error: function() { 230 | alert("请求错误"); 231 | } 232 | }); 233 | }; 234 | $scope.init(); 235 | }); 236 | /* By Ming */ 237 | -------------------------------------------------------------------------------- /src/main/webapp/plugins/security/sha1.js: -------------------------------------------------------------------------------- 1 | /* 2 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined 3 | * in FIPS PUB 180-1 4 | * Version 2.1a Copyright Paul Johnston 2000 - 2002. 5 | * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet 6 | * Distributed under the BSD License 7 | * See http://pajhome.org.uk/crypt/md5 for details. 8 | */ 9 | 10 | /* 11 | * Configurable variables. You may need to tweak these to be compatible with 12 | * the server-side, but the defaults work in most cases. 13 | */ 14 | var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ 15 | var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ 16 | var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ 17 | 18 | /* 19 | * These are the functions you'll usually want to call 20 | * They take string arguments and return either hex or base-64 encoded strings 21 | */ 22 | function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));} 23 | function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));} 24 | function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));} 25 | function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));} 26 | function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));} 27 | function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));} 28 | 29 | /* 30 | * Perform a simple self-test to see if the VM is working 31 | */ 32 | function sha1_vm_test() 33 | { 34 | return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d"; 35 | } 36 | 37 | /* 38 | * Calculate the SHA-1 of an array of big-endian words, and a bit length 39 | */ 40 | function core_sha1(x, len) 41 | { 42 | /* append padding */ 43 | x[len >> 5] |= 0x80 << (24 - len % 32); 44 | x[((len + 64 >> 9) << 4) + 15] = len; 45 | 46 | var w = Array(80); 47 | var a = 1732584193; 48 | var b = -271733879; 49 | var c = -1732584194; 50 | var d = 271733878; 51 | var e = -1009589776; 52 | 53 | for(var i = 0; i < x.length; i += 16) 54 | { 55 | var olda = a; 56 | var oldb = b; 57 | var oldc = c; 58 | var oldd = d; 59 | var olde = e; 60 | 61 | for(var j = 0; j < 80; j++) 62 | { 63 | if(j < 16) w[j] = x[i + j]; 64 | else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1); 65 | var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), 66 | safe_add(safe_add(e, w[j]), sha1_kt(j))); 67 | e = d; 68 | d = c; 69 | c = rol(b, 30); 70 | b = a; 71 | a = t; 72 | } 73 | 74 | a = safe_add(a, olda); 75 | b = safe_add(b, oldb); 76 | c = safe_add(c, oldc); 77 | d = safe_add(d, oldd); 78 | e = safe_add(e, olde); 79 | } 80 | return Array(a, b, c, d, e); 81 | 82 | } 83 | 84 | /* 85 | * Perform the appropriate triplet combination function for the current 86 | * iteration 87 | */ 88 | function sha1_ft(t, b, c, d) 89 | { 90 | if(t < 20) return (b & c) | ((~b) & d); 91 | if(t < 40) return b ^ c ^ d; 92 | if(t < 60) return (b & c) | (b & d) | (c & d); 93 | return b ^ c ^ d; 94 | } 95 | 96 | /* 97 | * Determine the appropriate additive constant for the current iteration 98 | */ 99 | function sha1_kt(t) 100 | { 101 | return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : 102 | (t < 60) ? -1894007588 : -899497514; 103 | } 104 | 105 | /* 106 | * Calculate the HMAC-SHA1 of a key and some data 107 | */ 108 | function core_hmac_sha1(key, data) 109 | { 110 | var bkey = str2binb(key); 111 | if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz); 112 | 113 | var ipad = Array(16), opad = Array(16); 114 | for(var i = 0; i < 16; i++) 115 | { 116 | ipad[i] = bkey[i] ^ 0x36363636; 117 | opad[i] = bkey[i] ^ 0x5C5C5C5C; 118 | } 119 | 120 | var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz); 121 | return core_sha1(opad.concat(hash), 512 + 160); 122 | } 123 | 124 | /* 125 | * Add integers, wrapping at 2^32. This uses 16-bit operations internally 126 | * to work around bugs in some JS interpreters. 127 | */ 128 | function safe_add(x, y) 129 | { 130 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); 131 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); 132 | return (msw << 16) | (lsw & 0xFFFF); 133 | } 134 | 135 | /* 136 | * Bitwise rotate a 32-bit number to the left. 137 | */ 138 | function rol(num, cnt) 139 | { 140 | return (num << cnt) | (num >>> (32 - cnt)); 141 | } 142 | 143 | /* 144 | * Convert an 8-bit or 16-bit string to an array of big-endian words 145 | * In 8-bit function, characters >255 have their hi-byte silently ignored. 146 | */ 147 | function str2binb(str) 148 | { 149 | var bin = Array(); 150 | var mask = (1 << chrsz) - 1; 151 | for(var i = 0; i < str.length * chrsz; i += chrsz) 152 | bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32); 153 | return bin; 154 | } 155 | 156 | /* 157 | * Convert an array of big-endian words to a string 158 | */ 159 | function binb2str(bin) 160 | { 161 | var str = ""; 162 | var mask = (1 << chrsz) - 1; 163 | for(var i = 0; i < bin.length * 32; i += chrsz) 164 | str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask); 165 | return str; 166 | } 167 | 168 | /* 169 | * Convert an array of big-endian words to a hex string. 170 | */ 171 | function binb2hex(binarray) 172 | { 173 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; 174 | var str = ""; 175 | for(var i = 0; i < binarray.length * 4; i++) 176 | { 177 | str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + 178 | hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); 179 | } 180 | return str; 181 | } 182 | 183 | /* 184 | * Convert an array of big-endian words to a base-64 string 185 | */ 186 | function binb2b64(binarray) 187 | { 188 | var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 189 | var str = ""; 190 | for(var i = 0; i < binarray.length * 4; i += 3) 191 | { 192 | var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16) 193 | | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 ) 194 | | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF); 195 | for(var j = 0; j < 4; j++) 196 | { 197 | if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; 198 | else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); 199 | } 200 | } 201 | return str; 202 | } 203 | -------------------------------------------------------------------------------- /src/main/java/com/ming/action/MenuAction.java: -------------------------------------------------------------------------------- 1 | package com.ming.action; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.google.gson.Gson; 7 | import com.ming.entity.Menu; 8 | import com.ming.service.IMenuService; 9 | import com.ming.service.MenuService; 10 | import com.ming.util.Condition; 11 | import com.ming.util.DataUtil; 12 | import com.ming.util.Permission; 13 | import com.ming.util.WebUtil; 14 | import com.opensymphony.xwork2.ActionContext; 15 | import com.opensymphony.xwork2.ActionSupport; 16 | 17 | /** 18 | * MenuAction 19 | * @author Ming 20 | * @description 21 | * @date 2015-07-02 22 | */ 23 | public class MenuAction extends ActionSupport { 24 | private static final long serialVersionUID = 1L; 25 | 26 | private static final Gson GSON = new Gson(); 27 | private static final IMenuService menuService = new MenuService(); 28 | 29 | /* 开始配置数据接收 */ 30 | private String id; 31 | private String menu; 32 | private int curPage; 33 | private int limit; 34 | private String condition; 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | 40 | public void setId(String id) { 41 | this.id = id; 42 | } 43 | 44 | public String getMenu() { 45 | return menu; 46 | } 47 | 48 | public void setMenu(String menu) { 49 | this.menu = menu; 50 | } 51 | 52 | public int getCurPage() { 53 | return curPage; 54 | } 55 | 56 | public void setCurPage(int curPage) { 57 | this.curPage = curPage; 58 | } 59 | 60 | public int getLimit() { 61 | return limit; 62 | } 63 | 64 | public void setLimit(int limit) { 65 | this.limit = limit; 66 | } 67 | 68 | public String getCondition() { 69 | return condition; 70 | } 71 | 72 | public void setCondition(String condition) { 73 | this.condition = condition; 74 | } 75 | /* 结束配置数据接收 */ 76 | 77 | /** 78 | * 读取多条数据 79 | */ 80 | @Permission 81 | public void load() { 82 | try { 83 | String[] params = new String[] {"menuId", "name", "url", "href", "no", "roleId"}; 84 | 85 | List> datas = menuService.load(params, conditionString(), curPage, limit); 86 | if (datas != null) { 87 | String json = GSON.toJson(datas); 88 | WebUtil.writeJson(json); 89 | } else { 90 | WebUtil.writeJson(WebUtil.JSON_ERROR); 91 | } 92 | } catch (Exception e) { 93 | e.printStackTrace(); 94 | WebUtil.writeJson(WebUtil.JSON_ERROR); 95 | } 96 | } 97 | 98 | /** 99 | * 获取数据条数 100 | */ 101 | @Permission 102 | public void count() { 103 | try { 104 | int length = menuService.count(conditionString()); 105 | if (length != -1) { 106 | String json = "{\"count\":" + length + "}"; 107 | WebUtil.writeJson(json); 108 | } else { 109 | WebUtil.writeJson(WebUtil.JSON_ERROR); 110 | } 111 | } catch (Exception e) { 112 | e.printStackTrace(); 113 | WebUtil.writeJson(WebUtil.JSON_ERROR); 114 | } 115 | } 116 | 117 | /** 118 | * 读取一条数据 119 | */ 120 | @Permission 121 | public void loadOne() { 122 | try { 123 | String[] params = new String[] {"menuId", "name", "url", "href", "no", "roleId"}; 124 | 125 | Map data = menuService.loadOne(params, "menuId = '" + id + "'"); 126 | if (data != null) { 127 | String json = GSON.toJson(data); 128 | WebUtil.writeJson(json); 129 | } else { 130 | WebUtil.writeJson(WebUtil.JSON_ERROR); 131 | } 132 | } catch (Exception e) { 133 | e.printStackTrace(); 134 | WebUtil.writeJson(WebUtil.JSON_ERROR); 135 | } 136 | } 137 | 138 | /** 139 | * 保存一条数据 140 | */ 141 | @Permission 142 | public void save() { 143 | try { 144 | Menu menuObject = GSON.fromJson(menu, Menu.class); 145 | menuObject.setMenuId(DataUtil.getUUID()); 146 | 147 | boolean isSucceed = menuService.save(menuObject); 148 | if (isSucceed) { 149 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 150 | } else { 151 | WebUtil.writeJson(WebUtil.JSON_ERROR); 152 | } 153 | } catch (Exception e) { 154 | e.printStackTrace(); 155 | WebUtil.writeJson(WebUtil.JSON_ERROR); 156 | } 157 | } 158 | 159 | /** 160 | * 修改一条数据 161 | */ 162 | @Permission 163 | public void edit() { 164 | try { 165 | Menu menuObject = GSON.fromJson(menu, Menu.class); 166 | 167 | boolean isSucceed = menuService.update(menuObject); 168 | if (isSucceed) { 169 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 170 | } else { 171 | WebUtil.writeJson(WebUtil.JSON_ERROR); 172 | } 173 | } catch (Exception e) { 174 | e.printStackTrace(); 175 | WebUtil.writeJson(WebUtil.JSON_ERROR); 176 | } 177 | } 178 | 179 | /** 180 | * 删除一条数据 181 | */ 182 | @Permission 183 | public void delete() { 184 | try { 185 | Menu menuObject = new Menu(id); 186 | 187 | boolean isSucceed = menuService.delete(menuObject); 188 | if (isSucceed) { 189 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 190 | } else { 191 | WebUtil.writeJson(WebUtil.JSON_ERROR); 192 | } 193 | } catch (Exception e) { 194 | e.printStackTrace(); 195 | WebUtil.writeJson(WebUtil.JSON_ERROR); 196 | } 197 | } 198 | 199 | /** 200 | * 组合条件 201 | * @return 条件SQL语句 202 | */ 203 | private String conditionString() { 204 | try { 205 | if (condition != null) { 206 | Condition conditionObject = GSON.fromJson(condition, Condition.class); 207 | 208 | String conditionString = ""; 209 | if (conditionObject.getName() != null) 210 | conditionString += "name LIKE '%" + conditionObject.getName() + "%' AND "; 211 | if (conditionObject.getUrl() != null) 212 | conditionString += "url LIKE '%" + conditionObject.getUrl() + "%' AND "; 213 | 214 | if (conditionString.length() > 5) 215 | conditionString = conditionString.substring(0, conditionString.length() - 5); 216 | 217 | return conditionString; 218 | } else { 219 | return null; 220 | } 221 | } catch (Exception e) { 222 | e.printStackTrace(); 223 | return null; 224 | } 225 | } 226 | 227 | /** 228 | * 获取个人菜单信息 229 | */ 230 | @Permission 231 | public void loadMine() { 232 | try { 233 | Map session = ActionContext.getContext().getSession(); 234 | Integer roleId = (Integer) session.get("roleId"); 235 | 236 | String[] params = new String[] {"name", "href"}; 237 | 238 | List> datas = menuService.load(params, "roleId = '" + roleId + "' ORDER BY no"); 239 | if (datas != null) { 240 | String json = GSON.toJson(datas); 241 | WebUtil.writeJson(json); 242 | } else { 243 | WebUtil.writeJson(WebUtil.JSON_ERROR); 244 | } 245 | } catch (Exception e) { 246 | e.printStackTrace(); 247 | WebUtil.writeJson(WebUtil.JSON_ERROR); 248 | } 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /src/main/webapp/js/view/user.js: -------------------------------------------------------------------------------- 1 | app.controller("userController", function($scope) { 2 | $scope.dateFormat = function(data) { 3 | return dateFormat(data); 4 | }; 5 | $scope.roleFormat = function(data) { 6 | if ($scope.roles && $scope.roles.length > 0) { 7 | for (var i = 0, length = $scope.roles.length; i < length; i++) { 8 | var role = $scope.roles[i]; 9 | if (role.roleId == data) 10 | return role.roleName; 11 | } 12 | } 13 | return ""; 14 | }; 15 | $scope.loadRoles = function() { 16 | $.ajax({ 17 | url: "role_load.action", 18 | type: "POST", 19 | dataType: "json", 20 | data: {}, 21 | beforeSend: function() {}, 22 | complete: function() {}, 23 | success: function(data) { 24 | $scope.roles = data; 25 | $scope.$apply(); 26 | if (data.result) 27 | alert(data.result); 28 | }, 29 | error: function() { 30 | alert("请求错误"); 31 | } 32 | }); 33 | }; 34 | $scope.getCondition = function() { 35 | var condition = { 36 | userName: $scope.userName 37 | }; 38 | 39 | return condition; 40 | }; 41 | $scope.load = function() { 42 | $.ajax({ 43 | url: "user_load.action", 44 | type: "POST", 45 | dataType: "json", 46 | data: { 47 | curPage: $scope.curPage, 48 | limit: $scope.limit, 49 | condition: JSON.stringify($scope.getCondition()) 50 | }, 51 | beforeSend: function() { 52 | showAlert("正在加载数据", "warning", 0); 53 | }, 54 | complete: function() { 55 | showAlert("数据加载完成", "success", 1000); 56 | }, 57 | success: function(data) { 58 | $scope.users = data; 59 | $scope.refreshPager(); 60 | $scope.$apply(); 61 | if (data.result) 62 | alert(data.result); 63 | }, 64 | error: function() { 65 | alert("请求错误"); 66 | } 67 | }); 68 | }; 69 | $scope.refreshPager = function() { 70 | switch ($scope.pages) { 71 | case 0: $scope.pager = [null, null, null]; break; 72 | case 1: $scope.pager = [1, null, null]; break; 73 | case 2: $scope.pager = [1, 2, null]; break; 74 | case 3: $scope.pager = [1, 2, 3]; break; 75 | default: 76 | if ($scope.curPage <= 2) 77 | $scope.pager = [1, 2, 3]; 78 | else if ($scope.curPage >= $scope.pages - 1) 79 | $scope.pager = [$scope.pages - 2, $scope.pages - 1, $scope.pages]; 80 | else 81 | $scope.pager = [$scope.curPage - 1, $scope.curPage, $scope.curPage + 1]; 82 | } 83 | }; 84 | $scope.firstPage = function() { 85 | $scope.curPage = 1; 86 | $scope.load(); 87 | }; 88 | $scope.lastPage = function() { 89 | $scope.curPage = $scope.pages; 90 | $scope.load(); 91 | }; 92 | $scope.prevPage = function() { 93 | $scope.curPage--; 94 | $scope.load(); 95 | }; 96 | $scope.nextPage = function() { 97 | $scope.curPage++; 98 | $scope.load(); 99 | }; 100 | $scope.changePage = function(page) { 101 | $scope.curPage = page; 102 | $scope.load(); 103 | }; 104 | $scope.reset = function() { 105 | $scope.user = { 106 | sex: 0, 107 | birthday: new Date(), 108 | email: "", 109 | roleId: $scope.roles[0].roleId, 110 | isActive: 0 111 | }; 112 | }; 113 | $scope.add = function() { 114 | $scope.modalTitle = "新增用户"; 115 | $scope.mode = "save"; 116 | $scope.reset(); 117 | }; 118 | $scope.edit = function(id) { 119 | $scope.modalTitle = "编辑用户"; 120 | $scope.mode = "edit"; 121 | $scope.reset(); 122 | $.ajax({ 123 | url: "user_loadOne.action", 124 | type: "POST", 125 | dataType: "json", 126 | data: { 127 | id: id 128 | }, 129 | beforeSend: function() {}, 130 | complete: function() {}, 131 | success: function(data) { 132 | $scope.user = data; 133 | $scope.user.birthday = doubleToDate(data.birthday); 134 | $scope.$apply(); 135 | if (data.result) 136 | alert(data.result); 137 | }, 138 | error: function() { 139 | alert("请求错误"); 140 | } 141 | }); 142 | }; 143 | $scope.delete = function(id) { 144 | if (confirm("确认删除?")) { 145 | $.ajax({ 146 | url: "user_delete.action", 147 | type: "POST", 148 | dataType: "json", 149 | data: { 150 | id: id 151 | }, 152 | beforeSend: function() {}, 153 | complete: function() {}, 154 | success: function(data) { 155 | if (data.result === "success") { 156 | alert("数据删除成功"); 157 | $scope.init(); 158 | } else { 159 | alert(data.result); 160 | } 161 | }, 162 | error: function() { 163 | alert("请求错误"); 164 | } 165 | }); 166 | } 167 | }; 168 | $scope.ok = function() { 169 | var user = { 170 | userName: $.trim($scope.user.userName), 171 | sex: $scope.user.sex, 172 | birthday: dateToDouble($scope.user.birthday), 173 | email: $.trim($scope.user.email), 174 | qq: $.trim($scope.user.qq), 175 | roleId: $scope.user.roleId, 176 | isActive: $scope.user.isActive 177 | }; 178 | if ($scope.mode === "edit") { 179 | user.id = $scope.user.id 180 | if ($scope.user.password && $scope.user.password.length > 0) { 181 | user.password = hex_md5($scope.user.password); 182 | } 183 | } else { 184 | user.loginName = hex_md5($.trim($scope.user.loginName)), 185 | user.password = hex_md5($scope.user.password) 186 | } 187 | $.ajax({ 188 | url: "user_" + $scope.mode + ".action", 189 | type: "POST", 190 | dataType: "json", 191 | data: { 192 | user: JSON.stringify(user) 193 | }, 194 | beforeSend: function() {}, 195 | complete: function() {}, 196 | success: function(data) { 197 | if (data.result === "success") { 198 | alert("数据保存成功"); 199 | $scope.init(); 200 | $("#user-modal").modal("hide"); 201 | } else { 202 | alert(data.result); 203 | } 204 | }, 205 | error: function() { 206 | alert("请求错误"); 207 | } 208 | }); 209 | }; 210 | $scope.init = function() { 211 | $scope.pager = [1, null, null]; 212 | $scope.curPage = 1; 213 | $scope.limit = 10; 214 | $scope.pages = 0; 215 | $scope.loadRoles(); 216 | $.ajax({ 217 | url: "user_count.action", 218 | type: "POST", 219 | dataType: "json", 220 | data: { 221 | condition: JSON.stringify($scope.getCondition()) 222 | }, 223 | beforeSend: function() {}, 224 | complete: function() {}, 225 | success: function(data) { 226 | if (data.count > 0) { 227 | $scope.total = data.count; 228 | $scope.pages = Math.ceil(data.count / $scope.limit); 229 | $scope.load(); 230 | } else { 231 | $scope.users = []; 232 | $scope.curPage = 0; 233 | $scope.pages = 0; 234 | $scope.$apply(); 235 | } 236 | if (data.result) 237 | alert(data.result); 238 | }, 239 | error: function() { 240 | alert("请求错误"); 241 | } 242 | }); 243 | }; 244 | $scope.init(); 245 | }); 246 | /* By Ming */ 247 | -------------------------------------------------------------------------------- /src/main/java/com/ming/action/BillForInAction.java: -------------------------------------------------------------------------------- 1 | package com.ming.action; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import com.google.gson.Gson; 8 | import com.ming.entity.BillForIn; 9 | import com.ming.entity.BillForOut; 10 | import com.ming.service.BillForInService; 11 | import com.ming.service.BillForOutService; 12 | import com.ming.service.IBillForInService; 13 | import com.ming.service.IBillForOutService; 14 | import com.ming.util.Condition; 15 | import com.ming.util.DataUtil; 16 | import com.ming.util.Permission; 17 | import com.ming.util.WebUtil; 18 | import com.opensymphony.xwork2.ActionSupport; 19 | 20 | /** 21 | * BillForInAction 22 | * @author Ming 23 | * @description 24 | * @date 2015-07-10 25 | */ 26 | public class BillForInAction extends ActionSupport { 27 | private static final long serialVersionUID = 1L; 28 | 29 | private static final Gson GSON = new Gson(); 30 | private static final IBillForInService billForInService = new BillForInService(); 31 | private static final IBillForOutService billForOutService = new BillForOutService(); 32 | 33 | /* 开始配置数据接收 */ 34 | private String id; 35 | private String billForIn; 36 | private int curPage; 37 | private int limit; 38 | private String condition; 39 | 40 | public String getId() { 41 | return id; 42 | } 43 | 44 | public void setId(String id) { 45 | this.id = id; 46 | } 47 | 48 | public String getBillForIn() { 49 | return billForIn; 50 | } 51 | 52 | public void setBillForIn(String billForIn) { 53 | this.billForIn = billForIn; 54 | } 55 | 56 | public int getCurPage() { 57 | return curPage; 58 | } 59 | 60 | public void setCurPage(int curPage) { 61 | this.curPage = curPage; 62 | } 63 | 64 | public int getLimit() { 65 | return limit; 66 | } 67 | 68 | public void setLimit(int limit) { 69 | this.limit = limit; 70 | } 71 | 72 | public String getCondition() { 73 | return condition; 74 | } 75 | 76 | public void setCondition(String condition) { 77 | this.condition = condition; 78 | } 79 | /* 结束配置数据接收 */ 80 | 81 | /** 82 | * 读取多条数据 83 | */ 84 | @Permission 85 | public void load() { 86 | try { 87 | List> datas = billForInService.loadSpecial(conditionString(), curPage, limit); 88 | if (datas != null) { 89 | String json = GSON.toJson(datas); 90 | WebUtil.writeJson(json); 91 | } else { 92 | WebUtil.writeJson(WebUtil.JSON_ERROR); 93 | } 94 | } catch (Exception e) { 95 | e.printStackTrace(); 96 | WebUtil.writeJson(WebUtil.JSON_ERROR); 97 | } 98 | } 99 | 100 | /** 101 | * 获取数据条数 102 | */ 103 | @Permission 104 | public void count() { 105 | try { 106 | int length = billForInService.countSpecial(conditionString()); 107 | if (length != -1) { 108 | String json = "{\"count\":" + length + "}"; 109 | WebUtil.writeJson(json); 110 | } else { 111 | WebUtil.writeJson(WebUtil.JSON_ERROR); 112 | } 113 | } catch (Exception e) { 114 | e.printStackTrace(); 115 | WebUtil.writeJson(WebUtil.JSON_ERROR); 116 | } 117 | } 118 | 119 | /** 120 | * 读取一条数据 121 | */ 122 | @Permission 123 | public void loadOne() { 124 | try { 125 | String[] params = new String[] {"id", "date", "amount", "fromId", "toId", "recordId", "remark"}; 126 | 127 | Map data = billForInService.loadOne(params, "id = '" + id + "'"); 128 | if (data != null) { 129 | String json = GSON.toJson(data); 130 | WebUtil.writeJson(json); 131 | } else { 132 | WebUtil.writeJson(WebUtil.JSON_ERROR); 133 | } 134 | } catch (Exception e) { 135 | e.printStackTrace(); 136 | WebUtil.writeJson(WebUtil.JSON_ERROR); 137 | } 138 | } 139 | 140 | /** 141 | * 保存一条数据 142 | */ 143 | @Permission 144 | public void save() { 145 | try { 146 | BillForIn billForInObject = GSON.fromJson(billForIn, BillForIn.class); 147 | billForInObject.setId(DataUtil.getUUID()); 148 | billForInObject.setCreateDate(Double.parseDouble(DataUtil.getDateString(new Date(), "yyyyMMdd"))); 149 | 150 | boolean isSucceed = billForInService.save(billForInObject); 151 | if (isSucceed) { 152 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 153 | } else { 154 | WebUtil.writeJson(WebUtil.JSON_ERROR); 155 | } 156 | } catch (Exception e) { 157 | e.printStackTrace(); 158 | WebUtil.writeJson(WebUtil.JSON_ERROR); 159 | } 160 | } 161 | 162 | /** 163 | * 修改一条数据 164 | */ 165 | @Permission 166 | public void edit() { 167 | try { 168 | BillForIn billForInObject = GSON.fromJson(billForIn, BillForIn.class); 169 | 170 | boolean isSucceed = billForInService.update(billForInObject); 171 | if (isSucceed) { 172 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 173 | } else { 174 | WebUtil.writeJson(WebUtil.JSON_ERROR); 175 | } 176 | } catch (Exception e) { 177 | e.printStackTrace(); 178 | WebUtil.writeJson(WebUtil.JSON_ERROR); 179 | } 180 | } 181 | 182 | /** 183 | * 删除一条数据 184 | */ 185 | @Permission 186 | public void delete() { 187 | try { 188 | BillForIn billForInObject = new BillForIn(id); 189 | 190 | boolean isSucceed = billForInService.delete(billForInObject); 191 | if (isSucceed) { 192 | WebUtil.writeJson(WebUtil.JSON_SUCCESS); 193 | } else { 194 | WebUtil.writeJson(WebUtil.JSON_ERROR); 195 | } 196 | } catch (Exception e) { 197 | e.printStackTrace(); 198 | WebUtil.writeJson(WebUtil.JSON_ERROR); 199 | } 200 | } 201 | 202 | /** 203 | * 组合条件 204 | * @return 条件SQL语句 205 | */ 206 | private String conditionString() { 207 | try { 208 | if (condition != null) { 209 | Condition conditionObject = GSON.fromJson(condition, Condition.class); 210 | 211 | String conditionString = ""; 212 | if (conditionObject.getToName() != null) 213 | conditionString += "toName LIKE '%" + conditionObject.getToName() + "%' AND "; 214 | 215 | if (conditionString.length() > 5) 216 | conditionString = conditionString.substring(0, conditionString.length() - 5); 217 | 218 | return conditionString; 219 | } else { 220 | return null; 221 | } 222 | } catch (Exception e) { 223 | e.printStackTrace(); 224 | return null; 225 | } 226 | } 227 | 228 | /** 229 | * 入账金额统计 230 | */ 231 | @Permission 232 | public void sumUp() { 233 | try { 234 | double sum = billForInService.sumUp(conditionString()); 235 | String json = "{\"amount\":" + sum + "}"; 236 | WebUtil.writeJson(json); 237 | } catch (Exception e) { 238 | e.printStackTrace(); 239 | WebUtil.writeJson(WebUtil.JSON_ERROR); 240 | } 241 | } 242 | 243 | /** 244 | * 报账金额统计 245 | */ 246 | @Permission 247 | public void sumUpMoney() { 248 | try { 249 | double sum = billForInService.sumUpMoney(); 250 | String json = "{\"amount\":" + sum + "}"; 251 | WebUtil.writeJson(json); 252 | } catch (Exception e) { 253 | e.printStackTrace(); 254 | WebUtil.writeJson(WebUtil.JSON_ERROR); 255 | } 256 | } 257 | 258 | /** 259 | * 查看所有还需金额 260 | */ 261 | @Permission 262 | public void sumUpNeed() { 263 | try { 264 | double leftMoney = billForInService.sumUpMoney(); 265 | double unpaidMoney = billForOutService.sumUp("status = " + BillForOut.STATUS_UNPAID); 266 | if (unpaidMoney > leftMoney) 267 | WebUtil.writeJson("{\"amount\":" + (unpaidMoney - leftMoney) + "}"); 268 | else 269 | WebUtil.writeJson("{\"amount\":null}"); 270 | } catch (Exception e) { 271 | e.printStackTrace(); 272 | WebUtil.writeJson(WebUtil.JSON_ERROR); 273 | } 274 | } 275 | } 276 | -------------------------------------------------------------------------------- /src/main/webapp/view/review.html: -------------------------------------------------------------------------------- 1 |
2 | 13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 47 |
#日期事项金额(元)支付人创建日期备注操作
40 | 41 |
无数据
48 |
49 | 数据总数: 50 | 总计金额: 51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
66 |
67 |
68 |
69 | 70 | 125 | 126 | -------------------------------------------------------------------------------- /src/main/webapp/js/view/billforin.js: -------------------------------------------------------------------------------- 1 | app.controller("billForInController", function($scope) { 2 | $scope.dateFormat = function(data) { 3 | return dateFormat(data); 4 | }; 5 | $scope.currentUserId = function() { 6 | $.ajax({ 7 | url: "user_currentId.action", 8 | type: "POST", 9 | dataType: "json", 10 | data: {}, 11 | beforeSend: function() {}, 12 | complete: function() {}, 13 | success: function(data) { 14 | if (data.id) { 15 | $scope.currentId = data.id; 16 | $scope.$apply(); 17 | } 18 | }, 19 | error: function() { 20 | alert("请求错误"); 21 | } 22 | }); 23 | }; 24 | $scope.loadUsers = function() { 25 | $.ajax({ 26 | url: "user_loadAll.action", 27 | type: "POST", 28 | dataType: "json", 29 | data: {}, 30 | beforeSend: function() {}, 31 | complete: function() {}, 32 | success: function(data) { 33 | $scope.users = data; 34 | $scope.$apply(); 35 | if (data.result) 36 | alert(data.result); 37 | }, 38 | error: function() { 39 | alert("请求错误"); 40 | } 41 | }); 42 | }; 43 | $scope.getCondition = function() { 44 | var condition = { 45 | toName: $scope.toName 46 | }; 47 | 48 | return condition; 49 | }; 50 | $scope.load = function() { 51 | $.ajax({ 52 | url: "billForIn_load.action", 53 | type: "POST", 54 | dataType: "json", 55 | data: { 56 | curPage: $scope.curPage, 57 | limit: $scope.limit, 58 | condition: JSON.stringify($scope.getCondition()) 59 | }, 60 | beforeSend: function() { 61 | showAlert("正在加载数据", "warning", 0); 62 | }, 63 | complete: function() { 64 | showAlert("数据加载完成", "success", 1000); 65 | }, 66 | success: function(data) { 67 | $scope.billForIns = data; 68 | $scope.refreshPager(); 69 | $scope.$apply(); 70 | if (data.result) 71 | alert(data.result); 72 | }, 73 | error: function() { 74 | alert("请求错误"); 75 | } 76 | }); 77 | }; 78 | $scope.refreshPager = function() { 79 | switch ($scope.pages) { 80 | case 0: $scope.pager = [null, null, null]; break; 81 | case 1: $scope.pager = [1, null, null]; break; 82 | case 2: $scope.pager = [1, 2, null]; break; 83 | case 3: $scope.pager = [1, 2, 3]; break; 84 | default: 85 | if ($scope.curPage <= 2) 86 | $scope.pager = [1, 2, 3]; 87 | else if ($scope.curPage >= $scope.pages - 1) 88 | $scope.pager = [$scope.pages - 2, $scope.pages - 1, $scope.pages]; 89 | else 90 | $scope.pager = [$scope.curPage - 1, $scope.curPage, $scope.curPage + 1]; 91 | } 92 | }; 93 | $scope.firstPage = function() { 94 | $scope.curPage = 1; 95 | $scope.load(); 96 | }; 97 | $scope.lastPage = function() { 98 | $scope.curPage = $scope.pages; 99 | $scope.load(); 100 | }; 101 | $scope.prevPage = function() { 102 | $scope.curPage--; 103 | $scope.load(); 104 | }; 105 | $scope.nextPage = function() { 106 | $scope.curPage++; 107 | $scope.load(); 108 | }; 109 | $scope.changePage = function(page) { 110 | $scope.curPage = page; 111 | $scope.load(); 112 | }; 113 | $scope.reset = function() { 114 | $scope.billForIn = { 115 | date: new Date(), 116 | amount: null, 117 | recordId: $scope.currentId || null 118 | }; 119 | }; 120 | $scope.add = function() { 121 | $scope.modalTitle = "新增入账"; 122 | $scope.mode = "save"; 123 | $scope.reset(); 124 | }; 125 | $scope.edit = function(id) { 126 | $scope.modalTitle = "编辑入账"; 127 | $scope.mode = "edit"; 128 | $scope.reset(); 129 | $.ajax({ 130 | url: "billForIn_loadOne.action", 131 | type: "POST", 132 | dataType: "json", 133 | data: { 134 | id: id 135 | }, 136 | beforeSend: function() {}, 137 | complete: function() {}, 138 | success: function(data) { 139 | $scope.billForIn = data; 140 | $scope.billForIn.date = doubleToDate(data.date); 141 | $scope.$apply(); 142 | if (data.result) 143 | alert(data.result); 144 | }, 145 | error: function() { 146 | alert("请求错误"); 147 | } 148 | }); 149 | }; 150 | $scope.delete = function(id) { 151 | if (confirm("确认删除?")) { 152 | $.ajax({ 153 | url: "billForIn_delete.action", 154 | type: "POST", 155 | dataType: "json", 156 | data: { 157 | id: id 158 | }, 159 | beforeSend: function() {}, 160 | complete: function() {}, 161 | success: function(data) { 162 | if (data.result === "success") { 163 | alert("数据删除成功"); 164 | $scope.init(); 165 | } else { 166 | alert(data.result); 167 | } 168 | }, 169 | error: function() { 170 | alert("请求错误"); 171 | } 172 | }); 173 | } 174 | }; 175 | $scope.ok = function() { 176 | var billForIn = { 177 | date: dateToDouble($scope.billForIn.date), 178 | amount: $.trim($scope.billForIn.amount), 179 | fromId: $scope.billForIn.fromId, 180 | toId: $scope.billForIn.toId, 181 | recordId: $scope.billForIn.recordId, 182 | remark: $scope.billForIn.remark 183 | }; 184 | if ($scope.mode === "edit") { 185 | billForIn.id = $scope.billForIn.id 186 | } 187 | $.ajax({ 188 | url: "billForIn_" + $scope.mode + ".action", 189 | type: "POST", 190 | dataType: "json", 191 | data: { 192 | billForIn: JSON.stringify(billForIn) 193 | }, 194 | beforeSend: function() {}, 195 | complete: function() {}, 196 | success: function(data) { 197 | if (data.result === "success") { 198 | alert("数据保存成功"); 199 | $scope.init(); 200 | $("#billForIn-modal").modal("hide"); 201 | } else { 202 | alert(data.result); 203 | } 204 | }, 205 | error: function() { 206 | alert("请求错误"); 207 | } 208 | }); 209 | }; 210 | $scope.sumUp = function() { 211 | $.ajax({ 212 | url: "billForIn_sumUp.action", 213 | type: "POST", 214 | dataType: "json", 215 | data: { 216 | condition: JSON.stringify($scope.getCondition()) 217 | }, 218 | beforeSend: function() {}, 219 | complete: function() {}, 220 | success: function(data) { 221 | if (data.amount > 0) 222 | $scope.totalAmount = data.amount; 223 | else 224 | $scope.totalAmount = 0; 225 | $scope.$apply(); 226 | if (data.result) 227 | alert(data.result); 228 | }, 229 | error: function() { 230 | alert("请求错误"); 231 | } 232 | }); 233 | }; 234 | $scope.sumUpMoney = function() { 235 | $.ajax({ 236 | url: "billForIn_sumUpMoney.action", 237 | type: "POST", 238 | dataType: "json", 239 | data: {}, 240 | beforeSend: function() {}, 241 | complete: function() {}, 242 | success: function(data) { 243 | $scope.totalMoney = data.amount; 244 | $scope.$apply(); 245 | if (data.result) 246 | alert(data.result); 247 | }, 248 | error: function() { 249 | alert("请求错误"); 250 | } 251 | }); 252 | }; 253 | $scope.sumUpNeed = function() { 254 | $.ajax({ 255 | url: "billForIn_sumUpNeed.action", 256 | type: "POST", 257 | dataType: "json", 258 | data: {}, 259 | beforeSend: function() {}, 260 | complete: function() {}, 261 | success: function(data) { 262 | $scope.needMoney = data.amount; 263 | $scope.$apply(); 264 | if (data.result) 265 | alert(data.result); 266 | }, 267 | error: function() { 268 | alert("请求错误"); 269 | } 270 | }); 271 | }; 272 | $scope.init = function() { 273 | $scope.pager = [1, null, null]; 274 | $scope.curPage = 1; 275 | $scope.limit = 10; 276 | $scope.pages = 0; 277 | $scope.loadUsers(); 278 | $scope.currentUserId(); 279 | $.ajax({ 280 | url: "billForIn_count.action", 281 | type: "POST", 282 | dataType: "json", 283 | data: { 284 | condition: JSON.stringify($scope.getCondition()) 285 | }, 286 | beforeSend: function() {}, 287 | complete: function() {}, 288 | success: function(data) { 289 | if (data.count > 0) { 290 | $scope.total = data.count; 291 | $scope.pages = Math.ceil(data.count / $scope.limit); 292 | $scope.sumUp(); 293 | $scope.sumUpMoney(); 294 | $scope.sumUpNeed(); 295 | $scope.load(); 296 | } else { 297 | $scope.billForIns = []; 298 | $scope.curPage = 0; 299 | $scope.pages = 0; 300 | $scope.totalAmount = 0; 301 | $scope.totalMoney = 0; 302 | $scope.needMoney = 0; 303 | $scope.$apply(); 304 | } 305 | if (data.result) 306 | alert(data.result); 307 | }, 308 | error: function() { 309 | alert("请求错误"); 310 | } 311 | }); 312 | }; 313 | $scope.init(); 314 | }); 315 | /* By Ming */ 316 | -------------------------------------------------------------------------------- /src/main/webapp/view/billforin.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 |
7 | 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 50 | 51 | 52 | 53 | 54 | 55 |
#日期金额(元)经手人接收人记录人创建日期备注操作
47 | 48 | 49 |
无数据
56 |
57 | 数据总数: 58 | 总计金额: 59 | 财务余额: 60 | 距离全部付清还需: 61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
76 |
77 |
78 |
79 | 80 | 134 | 135 | -------------------------------------------------------------------------------- /src/main/java/com/ming/util/SqlUtil.java: -------------------------------------------------------------------------------- 1 | package com.ming.util; 2 | 3 | import java.lang.reflect.Field; 4 | import java.lang.reflect.Method; 5 | import java.lang.reflect.Modifier; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * SQL语句生成类 11 | * @author Ming 12 | * @description 用于生成建表、插入、更新、删除、查询实体类的SQL语句 13 | * @date 2015-03-10 14 | */ 15 | public class SqlUtil { 16 | /** 17 | * 生成新增的SQL语句 18 | * @param obj 实体对象 19 | * @return SQL语句 20 | */ 21 | public static String insert(final Object obj) { 22 | try { 23 | StringBuilder result = new StringBuilder(); 24 | Class cls = obj.getClass(); 25 | Field[] fields = cls.getDeclaredFields(); 26 | if (fields.length == 0) 27 | throw new Exception("No data to insert"); 28 | result.append("INSERT INTO " + cls.getSimpleName() + "("); 29 | StringBuilder values = new StringBuilder(); 30 | for (Field field : fields) { 31 | if (!Modifier.isStatic(field.getModifiers())) { // 忽略静态成员 32 | String fieldName = field.getName(); 33 | result.append(fieldName + ", "); // 加上字段名可以去除数据库字段顺序带来的影响,增加容错性 34 | Method getter = cls.getMethod(getterName(fieldName)); 35 | Object getterResult = getter.invoke(obj); 36 | if (getterResult != null) 37 | values.append("'" + getterResult.toString() + "', "); 38 | else 39 | values.append("'', "); 40 | } 41 | } 42 | values.setLength(values.length() - 2); 43 | result.setLength(result.length() - 2); 44 | result.append(") VALUES (" + values.toString() + ")"); 45 | return result.toString(); 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | return null; 49 | } 50 | } 51 | 52 | /** 53 | * 生成更新的SQL语句 54 | * @param obj 实体对象 55 | * @return SQL语句 56 | */ 57 | public static String update(final Object obj) { 58 | try { 59 | StringBuilder result = new StringBuilder(); 60 | Map ids = new HashMap(); 61 | boolean hasValue = false; 62 | Class cls = obj.getClass(); 63 | Field[] fields = cls.getDeclaredFields(); 64 | result.append("UPDATE " + cls.getSimpleName() + " SET "); 65 | for (Field field : fields) { 66 | if (!Modifier.isStatic(field.getModifiers())) { // 忽略静态成员 67 | String fieldName = field.getName(); 68 | Object value = cls.getMethod(getterName(fieldName)).invoke(obj); 69 | if (field.getAnnotation(ID.class) == null) { 70 | if (value != null) { 71 | result.append(fieldName + " = '" + value + "', "); 72 | hasValue = true; 73 | } 74 | } else 75 | ids.put(fieldName, value); 76 | } 77 | } 78 | if (!hasValue) 79 | throw new Exception("No data to update"); 80 | result.setLength(result.length() - 2); 81 | result.append(" WHERE "); 82 | for (Map.Entry map : ids.entrySet()) 83 | result.append(map.getKey() + " = '" + map.getValue() + "' AND "); 84 | result.setLength(result.length() - 5); 85 | return result.toString(); 86 | } catch (Exception e) { 87 | e.printStackTrace(); 88 | return null; 89 | } 90 | } 91 | 92 | /** 93 | * 生成删除的SQL语句 94 | * @param obj 实体对象 95 | * @return SQL语句 96 | */ 97 | public static String delete(final Object obj) { 98 | try { 99 | StringBuilder result = new StringBuilder(); 100 | boolean hasID = false; 101 | Class cls = obj.getClass(); 102 | Field[] fields = cls.getDeclaredFields(); 103 | result.append("DELETE FROM " + cls.getSimpleName() + " WHERE "); 104 | for (Field field : fields) { 105 | if (field.getAnnotation(ID.class) != null) { 106 | String fieldName = field.getName(); 107 | Object value = cls.getMethod(getterName(fieldName)).invoke(obj); 108 | if (value != null) { 109 | result.append(field.getName() + " = '" + value + "' AND "); 110 | hasID = true; 111 | } 112 | } 113 | } 114 | if (!hasID) 115 | throw new Exception("No data to delete"); 116 | result.setLength(result.length() - 5); 117 | return result.toString(); 118 | } catch (Exception e) { 119 | e.printStackTrace(); 120 | return null; 121 | } 122 | } 123 | 124 | /** 125 | * 生成删除的SQL语句 126 | * @param cls 实体类对象 127 | * @param condition 条件 128 | * @return SQL语句 129 | */ 130 | public static String delete(final Class cls, final String condition) { 131 | try { 132 | StringBuilder result = new StringBuilder(); 133 | result.append("DELETE FROM " + cls.getSimpleName() + " WHERE "); 134 | if (!(condition == null || "".equals(condition))) 135 | result.append(condition); 136 | else 137 | throw new Exception("No data to delete"); 138 | return result.toString(); 139 | } catch (Exception e) { 140 | e.printStackTrace(); 141 | return null; 142 | } 143 | } 144 | 145 | /** 146 | * 生成查询的SQL语句 147 | * @param cls 实体类对象 148 | * @return SQL语句 149 | */ 150 | public static String load(final Class cls) { 151 | return load(cls, null); 152 | } 153 | 154 | /** 155 | * 生成查询的SQL语句 156 | * @param cls 实体类对象 157 | * @param condition 条件 158 | * @return SQL语句 159 | */ 160 | public static String load(final Class cls, final String condition) { 161 | try { 162 | Field[] fields = cls.getDeclaredFields(); 163 | if (fields.length == 0) 164 | throw new Exception("No data to load"); 165 | StringBuilder result = new StringBuilder(); 166 | result.append("SELECT "); 167 | 168 | /*for (Field field : fields) 169 | result.append(field.getName() + ", "); 170 | result.setLength(result.length() - 2);*/ 171 | 172 | // 之前用*代替上面被注释掉的代码,查询所有字段,效果相同,但代码运行效率高些,无需循环 173 | result.append("*"); 174 | 175 | result.append(" FROM " + cls.getSimpleName()); 176 | if (!(condition == null || "".equals(condition))) 177 | result.append(" WHERE " + condition); 178 | return result.toString(); 179 | } catch (Exception e) { 180 | e.printStackTrace(); 181 | return null; 182 | } 183 | } 184 | 185 | /** 186 | * 生成查询特定字段的SQL语句 187 | * @param params 参数数组 188 | * @param cls 实体类对象 189 | * @return SQL语句 190 | */ 191 | public static String load(final String[] params, final Class cls) { 192 | return load(params, cls, null); 193 | } 194 | 195 | /** 196 | * 生成查询特定字段的SQL语句 197 | * @param params 参数数组 198 | * @param cls 实体类对象 199 | * @param condition 条件 200 | * @return SQL语句 201 | */ 202 | public static String load(final String[] params, final Class cls, final String condition) { 203 | try { 204 | if (params == null || params.length == 0) 205 | // throw new Exception("No data to load"); 206 | return load(cls, condition); // 若没有指定字段则查询所有字段 207 | StringBuilder result = new StringBuilder(); 208 | result.append("SELECT "); 209 | 210 | for (String param : params) 211 | result.append(param + ", "); 212 | 213 | result.setLength(result.length() - 2); 214 | result.append(" FROM " + cls.getSimpleName()); 215 | if (!(condition == null || "".equals(condition))) 216 | result.append(" WHERE " + condition); 217 | return result.toString(); 218 | } catch (Exception e) { 219 | e.printStackTrace(); 220 | return null; 221 | } 222 | } 223 | 224 | /** 225 | * 生成查询数目的SQL语句 226 | * @param cls 实体类对象 227 | * @return SQL条件 228 | */ 229 | public static String count(final Class cls) { 230 | return count(cls, null); 231 | } 232 | 233 | /** 234 | * 生成查询数目的SQL语句 235 | * @param cls 实体类对象 236 | * @param condition 条件 237 | * @return SQL语句 238 | */ 239 | public static String count(final Class cls, final String condition) { 240 | try { 241 | Field[] fields = cls.getDeclaredFields(); 242 | if (fields.length == 0) 243 | throw new Exception("No data to load"); 244 | StringBuilder result = new StringBuilder(); 245 | result.append("SELECT COUNT(*) FROM " + cls.getSimpleName()); 246 | if (!(condition == null || "".equals(condition))) 247 | result.append(" WHERE " + condition); 248 | return result.toString(); 249 | } catch (Exception e) { 250 | e.printStackTrace(); 251 | return null; 252 | } 253 | } 254 | 255 | /** 256 | * 获取getter方法名 257 | * @param fieldName 成员名 258 | * @return 方法名 259 | */ 260 | public static String getterName(final String fieldName) { 261 | StringBuilder result = new StringBuilder("get" + fieldName); 262 | result.setCharAt(3, Character.toUpperCase(fieldName.charAt(0))); 263 | return result.toString(); 264 | } 265 | 266 | /** 267 | * 获取setter方法名 268 | * @param fieldName 成员名 269 | * @return 方法名 270 | */ 271 | public static String setterName(final String fieldName) { 272 | StringBuilder result = new StringBuilder("set" + fieldName); 273 | result.setCharAt(3, Character.toUpperCase(fieldName.charAt(0))); 274 | return result.toString(); 275 | } 276 | } 277 | -------------------------------------------------------------------------------- /src/main/webapp/js/view/billforout.js: -------------------------------------------------------------------------------- 1 | app.controller("billForOutController", function($scope) { 2 | $scope.dateFormat = function(data) { 3 | return dateFormat(data); 4 | }; 5 | $scope.statusFormat = function(data) { 6 | switch (data) { 7 | case 0: return "未支付"; break; 8 | case 1: return "已支付"; break; 9 | case 2: return "待审核"; break; 10 | case 3: return "不通过"; break; 11 | default: return ""; 12 | } 13 | }; 14 | $scope.currentUserId = function() { 15 | $.ajax({ 16 | url: "user_currentId.action", 17 | type: "POST", 18 | dataType: "json", 19 | data: {}, 20 | beforeSend: function() {}, 21 | complete: function() {}, 22 | success: function(data) { 23 | if (data.id) { 24 | $scope.currentId = data.id; 25 | $scope.$apply(); 26 | } 27 | }, 28 | error: function() { 29 | alert("请求错误"); 30 | } 31 | }); 32 | }; 33 | $scope.loadUsers = function() { 34 | $.ajax({ 35 | url: "user_loadAll.action", 36 | type: "POST", 37 | dataType: "json", 38 | data: {}, 39 | beforeSend: function() {}, 40 | complete: function() {}, 41 | success: function(data) { 42 | $scope.users = data; 43 | $scope.$apply(); 44 | if (data.result) 45 | alert(data.result); 46 | }, 47 | error: function() { 48 | alert("请求错误"); 49 | } 50 | }); 51 | }; 52 | $scope.getCondition = function() { 53 | var condition = { 54 | payName: $scope.payName, 55 | status: $scope.status 56 | }; 57 | 58 | return condition; 59 | }; 60 | $scope.load = function() { 61 | $.ajax({ 62 | url: "billForOut_load.action", 63 | type: "POST", 64 | dataType: "json", 65 | data: { 66 | curPage: $scope.curPage, 67 | limit: $scope.limit, 68 | condition: JSON.stringify($scope.getCondition()) 69 | }, 70 | beforeSend: function() { 71 | showAlert("正在加载数据", "warning", 0); 72 | }, 73 | complete: function() { 74 | showAlert("数据加载完成", "success", 1000); 75 | }, 76 | success: function(data) { 77 | $scope.billForOuts = data; 78 | $scope.refreshPager(); 79 | $scope.$apply(); 80 | if (data.result) 81 | alert(data.result); 82 | }, 83 | error: function() { 84 | alert("请求错误"); 85 | } 86 | }); 87 | }; 88 | $scope.refreshPager = function() { 89 | switch ($scope.pages) { 90 | case 0: $scope.pager = [null, null, null]; break; 91 | case 1: $scope.pager = [1, null, null]; break; 92 | case 2: $scope.pager = [1, 2, null]; break; 93 | case 3: $scope.pager = [1, 2, 3]; break; 94 | default: 95 | if ($scope.curPage <= 2) 96 | $scope.pager = [1, 2, 3]; 97 | else if ($scope.curPage >= $scope.pages - 1) 98 | $scope.pager = [$scope.pages - 2, $scope.pages - 1, $scope.pages]; 99 | else 100 | $scope.pager = [$scope.curPage - 1, $scope.curPage, $scope.curPage + 1]; 101 | } 102 | }; 103 | $scope.firstPage = function() { 104 | $scope.curPage = 1; 105 | $scope.load(); 106 | }; 107 | $scope.lastPage = function() { 108 | $scope.curPage = $scope.pages; 109 | $scope.load(); 110 | }; 111 | $scope.prevPage = function() { 112 | $scope.curPage--; 113 | $scope.load(); 114 | }; 115 | $scope.nextPage = function() { 116 | $scope.curPage++; 117 | $scope.load(); 118 | }; 119 | $scope.changePage = function(page) { 120 | $scope.curPage = page; 121 | $scope.load(); 122 | }; 123 | $scope.reset = function() { 124 | $scope.billForOut = { 125 | date: new Date(), 126 | amount: null, 127 | recordId: $scope.currentId || null, 128 | status: 0 129 | }; 130 | }; 131 | $scope.add = function() { 132 | $scope.modalTitle = "新增支出"; 133 | $scope.mode = "save"; 134 | $scope.reset(); 135 | }; 136 | $scope.edit = function(id) { 137 | $scope.modalTitle = "编辑支出"; 138 | $scope.mode = "edit"; 139 | $scope.reset(); 140 | $.ajax({ 141 | url: "billForOut_loadOne.action", 142 | type: "POST", 143 | dataType: "json", 144 | data: { 145 | id: id 146 | }, 147 | beforeSend: function() {}, 148 | complete: function() {}, 149 | success: function(data) { 150 | $scope.billForOut = data; 151 | $scope.billForOut.date = doubleToDate(data.date); 152 | $scope.$apply(); 153 | if (data.result) 154 | alert(data.result); 155 | }, 156 | error: function() { 157 | alert("请求错误"); 158 | } 159 | }); 160 | }; 161 | $scope.delete = function(id) { 162 | if (confirm("确认删除?")) { 163 | $.ajax({ 164 | url: "billForOut_delete.action", 165 | type: "POST", 166 | dataType: "json", 167 | data: { 168 | id: id 169 | }, 170 | beforeSend: function() {}, 171 | complete: function() {}, 172 | success: function(data) { 173 | if (data.result === "success") { 174 | alert("数据删除成功"); 175 | $scope.init(); 176 | } else { 177 | alert(data.result); 178 | } 179 | }, 180 | error: function() { 181 | alert("请求错误"); 182 | } 183 | }); 184 | } 185 | }; 186 | $scope.ok = function() { 187 | var billForOut = { 188 | date: dateToDouble($scope.billForOut.date), 189 | amount: $.trim($scope.billForOut.amount), 190 | event: $.trim($scope.billForOut.event), 191 | payId: $scope.billForOut.payId, 192 | status: $scope.billForOut.status, 193 | recordId: $scope.billForOut.recordId, 194 | remark: $scope.billForOut.remark 195 | }; 196 | if ($scope.mode === "edit") { 197 | billForOut.id = $scope.billForOut.id 198 | } 199 | $.ajax({ 200 | url: "billForOut_" + $scope.mode + ".action", 201 | type: "POST", 202 | dataType: "json", 203 | data: { 204 | billForOut: JSON.stringify(billForOut) 205 | }, 206 | beforeSend: function() {}, 207 | complete: function() {}, 208 | success: function(data) { 209 | if (data.result === "success") { 210 | alert("数据保存成功"); 211 | $scope.init(); 212 | $("#billForOut-modal").modal("hide"); 213 | } else { 214 | alert(data.result); 215 | } 216 | }, 217 | error: function() { 218 | alert("请求错误"); 219 | } 220 | }); 221 | }; 222 | $scope.sumUp = function() { 223 | $.ajax({ 224 | url: "billForOut_sumUp.action", 225 | type: "POST", 226 | dataType: "json", 227 | data: { 228 | condition: JSON.stringify($scope.getCondition()) 229 | }, 230 | beforeSend: function() {}, 231 | complete: function() {}, 232 | success: function(data) { 233 | if (data.amount > 0) 234 | $scope.totalAmount = data.amount; 235 | else 236 | $scope.totalAmount = 0; 237 | $scope.$apply(); 238 | if (data.result) 239 | alert(data.result); 240 | }, 241 | error: function() { 242 | alert("请求错误"); 243 | } 244 | }); 245 | }; 246 | $scope.sumUpMoney = function() { 247 | $.ajax({ 248 | url: "billForIn_sumUpMoney.action", 249 | type: "POST", 250 | dataType: "json", 251 | data: {}, 252 | beforeSend: function() {}, 253 | complete: function() {}, 254 | success: function(data) { 255 | $scope.totalMoney = data.amount; 256 | $scope.$apply(); 257 | if (data.result) 258 | alert(data.result); 259 | }, 260 | error: function() { 261 | alert("请求错误"); 262 | } 263 | }); 264 | }; 265 | $scope.sumUpNeed = function() { 266 | $.ajax({ 267 | url: "billForIn_sumUpNeed.action", 268 | type: "POST", 269 | dataType: "json", 270 | data: {}, 271 | beforeSend: function() {}, 272 | complete: function() {}, 273 | success: function(data) { 274 | $scope.needMoney = data.amount; 275 | $scope.$apply(); 276 | if (data.result) 277 | alert(data.result); 278 | }, 279 | error: function() { 280 | alert("请求错误"); 281 | } 282 | }); 283 | }; 284 | $scope.init = function() { 285 | $scope.pager = [1, null, null]; 286 | $scope.curPage = 1; 287 | $scope.limit = 10; 288 | $scope.pages = 0; 289 | $scope.loadUsers(); 290 | $scope.currentUserId(); 291 | $.ajax({ 292 | url: "billForOut_count.action", 293 | type: "POST", 294 | dataType: "json", 295 | data: { 296 | condition: JSON.stringify($scope.getCondition()) 297 | }, 298 | beforeSend: function() {}, 299 | complete: function() {}, 300 | success: function(data) { 301 | if (data.count > 0) { 302 | $scope.total = data.count; 303 | $scope.pages = Math.ceil(data.count / $scope.limit); 304 | $scope.sumUp(); 305 | $scope.sumUpMoney(); 306 | $scope.sumUpNeed(); 307 | $scope.load(); 308 | } else { 309 | $scope.billForOuts = []; 310 | $scope.curPage = 0; 311 | $scope.pages = 0; 312 | $scope.totalAmount = 0; 313 | $scope.totalMoney = 0; 314 | $scope.needMoney = 0; 315 | $scope.$apply(); 316 | } 317 | if (data.result) 318 | alert(data.result); 319 | }, 320 | error: function() { 321 | alert("请求错误"); 322 | } 323 | }); 324 | }; 325 | $scope.init(); 326 | }); 327 | /* By Ming */ 328 | -------------------------------------------------------------------------------- /src/main/webapp/js/main.js: -------------------------------------------------------------------------------- 1 | function windowResize() { 2 | var minHeight = document.documentElement.clientHeight - 165 + "px"; 3 | $("#main").css("minHeight", minHeight); 4 | } 5 | function doubleToDate(data) { 6 | data = String(data); 7 | return new Date(data.substr(0, 4) + "/" + data.substr(4, 2) + "/" + data.substring(6)); 8 | } 9 | function dateToDouble(data) { 10 | data = new Date(data); 11 | var year = data.getFullYear(); 12 | var month = data.getMonth() + 1; 13 | var day = data.getDate(); 14 | return year + (month > 9 ? "" : "0") + month + (day > 9 ? "" : "0") + day; 15 | } 16 | function dateFormat(data) { 17 | data = String(data); 18 | return data.substr(0, 4) + "/" + data.substr(4, 2) + "/" + data.substring(6); 19 | } 20 | function dateTimeFormat(data) { 21 | data = String(data); 22 | return data.substr(0, 4) + "/" + data.substr(4, 2) + "/" + data.substr(6, 2) + " " + data.substr(8, 2) + ":" + data.substr(10, 2) + ":" + data.substring(12); 23 | } 24 | function showAlert(message, type, time) { 25 | // $("#message-alert").html(message).attr("class", "alert alert-" + type).fadeIn(); 26 | // if (time > 0) 27 | // setTimeout("hideAlert()", time); 28 | } 29 | function hideAlert() { 30 | // $("#message-alert").fadeOut(); 31 | } 32 | 33 | var mainScope; 34 | var messageNumber; 35 | var app = angular.module("app", ["ngRoute"]); 36 | app.config(["$routeProvider", function($routeProvider) { 37 | $routeProvider 38 | .when("/", 39 | { 40 | templateUrl: "view/welcome.html", 41 | controller: "welcomeController" 42 | }) 43 | .when("/user", 44 | { 45 | templateUrl: "view/user.html", 46 | controller: "userController" 47 | }) 48 | .when("/billforin", 49 | { 50 | templateUrl: "view/billforin.html", 51 | controller: "billForInController" 52 | }) 53 | .when("/billforout", 54 | { 55 | templateUrl: "view/billforout.html", 56 | controller: "billForOutController" 57 | }) 58 | .when("/apply", 59 | { 60 | templateUrl: "view/apply.html", 61 | controller: "applyController" 62 | }) 63 | .when("/review", 64 | { 65 | templateUrl: "view/review.html", 66 | controller: "reviewController" 67 | }) 68 | .when("/pay", 69 | { 70 | templateUrl: "view/pay.html", 71 | controller: "payController" 72 | }) 73 | .when("/about", 74 | { 75 | templateUrl: "view/about.html", 76 | controller: "aboutController" 77 | }); 78 | }]); 79 | app.controller("mainController", function($scope, $location) { 80 | $scope.dateTimeFormat = function(data) { 81 | return dateTimeFormat(data); 82 | }; 83 | $scope.alertType = function(type) { 84 | switch (type) { 85 | case "0": return "alert-success"; break; 86 | case "1": return "alert-info"; break; 87 | case "2": return "alert-warning"; break; 88 | case "3": return "alert-danger"; break; 89 | default: return ""; 90 | } 91 | }; 92 | $scope.$watch(function() {return $location.path();}, function() { 93 | $scope.currentPage = $location.path(); 94 | }); 95 | $scope.loadMenus = function() { 96 | $.ajax({ 97 | url: "menu_loadMine.action", 98 | type: "POST", 99 | dataType: "json", 100 | data: {}, 101 | beforeSend: function() {}, 102 | complete: function() {}, 103 | success: function(data) { 104 | $scope.menus = data; 105 | $scope.$apply(); 106 | if (data.result) 107 | alert(data.result); 108 | }, 109 | error: function() { 110 | alert("请求错误"); 111 | } 112 | }); 113 | }; 114 | $scope.loadRoles = function() { 115 | $.ajax({ 116 | url: "role_load.action", 117 | type: "POST", 118 | dataType: "json", 119 | data: {}, 120 | beforeSend: function() {}, 121 | complete: function() {}, 122 | success: function(data) { 123 | $scope.roles = data; 124 | $scope.$apply(); 125 | if (data.result) 126 | alert(data.result); 127 | }, 128 | error: function() { 129 | alert("请求错误"); 130 | } 131 | }); 132 | }; 133 | $scope.logout = function() { 134 | if (confirm("确认注销?")) { 135 | $.ajax({ 136 | url: "user_logout.action", 137 | type: "POST", 138 | dataType: "json", 139 | data: {}, 140 | beforeSend: function() {}, 141 | complete: function() { 142 | window.location.href = "index.html"; 143 | }, 144 | success: function(data) { 145 | }, 146 | error: function() {} 147 | }); 148 | } 149 | }; 150 | $scope.resetBillForOut = function() { 151 | $scope.apply = { 152 | date: new Date() 153 | }; 154 | }; 155 | $scope.applyBillForOut = function() { 156 | var billForOut = { 157 | date: dateToDouble($scope.apply.date), 158 | event: $.trim($scope.apply.event), 159 | amount: $.trim($scope.apply.amount), 160 | remark: $.trim($scope.apply.remark) 161 | }; 162 | $.ajax({ 163 | url: "billForOut_apply.action", 164 | type: "POST", 165 | dataType: "json", 166 | data: { 167 | billForOut: JSON.stringify(billForOut), 168 | validCode: $scope.apply.validCode 169 | }, 170 | beforeSend: function() {}, 171 | complete: function() {}, 172 | success: function(data) { 173 | if (data.result === "success") { 174 | alert("报账提交成功,请耐心等待审核"); 175 | $("#apply-modal").modal("hide"); 176 | } else { 177 | alert(data.result); 178 | } 179 | }, 180 | error: function() { 181 | alert("请求错误"); 182 | } 183 | }); 184 | }; 185 | $scope.countMessages = function() { 186 | $.ajax({ 187 | url: "message_countMine.action", 188 | type: "POST", 189 | dataType: "json", 190 | data: {}, 191 | beforeSend: function() {}, 192 | complete: function() {}, 193 | success: function(data) { 194 | if (data.count > 0) { 195 | $scope.messageNumber = data.count; 196 | messageNumber = data.count; 197 | } else { 198 | $scope.messageNumber = null; 199 | messageNumber = null; 200 | } 201 | $scope.$apply(); 202 | if (data.result) 203 | alert(data.result); 204 | }, 205 | error: function() { 206 | alert("请求错误"); 207 | } 208 | }); 209 | }; 210 | $scope.loadMessages = function() { 211 | $.ajax({ 212 | url: "message_loadMine.action", 213 | type: "POST", 214 | dataType: "json", 215 | data: {}, 216 | beforeSend: function() {}, 217 | complete: function() {}, 218 | success: function(data) { 219 | $scope.countMessages(); 220 | $scope.messages = data; 221 | $scope.$apply(); 222 | if (data.result) 223 | alert(data.result); 224 | }, 225 | error: function() { 226 | alert("请求错误"); 227 | } 228 | }); 229 | }; 230 | $scope.deleteMessage = function(id) { 231 | $.ajax({ 232 | url: "message_deleteMine.action", 233 | type: "POST", 234 | dataType: "json", 235 | data: { 236 | id: id 237 | }, 238 | beforeSend: function() {}, 239 | complete: function() {}, 240 | success: function(data) { 241 | if (data.result === "success") { 242 | $scope.loadMessages(); 243 | } else { 244 | alert(data.result); 245 | } 246 | }, 247 | error: function() { 248 | alert("请求错误"); 249 | } 250 | }); 251 | }; 252 | $scope.changeValidCode = function() { 253 | $scope.timestamp = new Date().getTime(); 254 | }; 255 | $scope.loadSelf = function() { 256 | $scope.changePassword = false; 257 | $scope.timestamp = new Date().getTime(); 258 | $scope.loadRoles(); 259 | $.ajax({ 260 | url: "user_loadMine.action", 261 | type: "POST", 262 | dataType: "json", 263 | data: {}, 264 | beforeSend: function() {}, 265 | complete: function() {}, 266 | success: function(data) { 267 | $scope.self = data; 268 | $scope.self.birthday = doubleToDate(data.birthday); 269 | $scope.$apply(); 270 | if (data.result) 271 | alert(data.result); 272 | }, 273 | error: function() { 274 | alert("请求错误"); 275 | } 276 | }); 277 | }; 278 | $scope.toggleChangePassword = function() { 279 | $scope.changePassword = !$scope.changePassword; 280 | setTimeout("$('#self-modal').modal('handleUpdate')", 0); 281 | }; 282 | $scope.saveSelf = function() { 283 | var data = {}; 284 | var user = { 285 | birthday: dateToDouble($scope.self.birthday), 286 | email: $.trim($scope.self.email), 287 | qq: $.trim($scope.self.qq) 288 | }; 289 | if ($scope.changePassword) { 290 | user.password = hex_md5($scope.self.newPassword); 291 | data.password = hex_md5($scope.self.oldPassword); 292 | } 293 | data.user = JSON.stringify(user); 294 | data.validCode = $scope.self.validCode; 295 | $.ajax({ 296 | url: "user_editMine.action", 297 | type: "POST", 298 | dataType: "json", 299 | data: data, 300 | beforeSend: function() {}, 301 | complete: function() {}, 302 | success: function(data) { 303 | if (data.result === "success") { 304 | alert("修改成功"); 305 | $("#self-modal").modal("hide"); 306 | } else { 307 | alert(data.result); 308 | } 309 | }, 310 | error: function() { 311 | alert("请求错误"); 312 | } 313 | }); 314 | }; 315 | $scope.init = function() { 316 | mainScope = $scope; 317 | $scope.loadMenus(); 318 | $scope.countMessages(); 319 | setInterval("mainScope.countMessages()", 30000); // 轮询 320 | }; 321 | $scope.init(); 322 | }); 323 | 324 | $(document).ready(function() { 325 | $("[data-toggle='tooltip']").tooltip(); 326 | $(window).resize(function() { 327 | windowResize(); 328 | }); 329 | windowResize(); 330 | }); 331 | /* By Ming */ 332 | --------------------------------------------------------------------------------