Skip to content

Commit f6370c5

Browse files
committed
72crm_java_20190719
1 parent feff2b9 commit f6370c5

File tree

356 files changed

+15105
-1317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+15105
-1317
lines changed

72crm.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ fi
2222

2323
# 生成 class path 值
2424

25-
APP_BASE_PATH="./"
25+
APP_BASE_PATH=$(cd `dirname $0`; pwd)
26+
2627
CP=${APP_BASE_PATH}/config:${APP_BASE_PATH}/lib/*
2728

2829
function start()

docs/crm9.sql

Lines changed: 96 additions & 169 deletions
Large diffs are not rendered by default.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.kakarote</groupId>
55
<artifactId>crm9</artifactId>
66
<packaging>jar</packaging>
7-
<version>1.2.1</version>
7+
<version>1.3.0</version>
88
<name>crm9-master</name>
99

1010
<properties>

src/main/java/com/kakarote/crm9/common/config/JfinalConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.jfinal.plugin.redis.RedisPlugin;
3535
import com.jfinal.render.RenderManager;
3636
import com.jfinal.template.Engine;
37+
import com.kakarote.crm9.erp.work.service.WorkService;
3738

3839
import java.io.File;
3940

@@ -164,6 +165,8 @@ public void onStart() {
164165
adminFieldService.createView(7);
165166
adminFieldService.createView(8);
166167
adminFieldService.createView(10);
168+
WorkService workService= Aop.get(WorkService.class);
169+
workService.initialization();
167170
}
168171

169172
@Override

src/main/java/com/kakarote/crm9/common/constant/BaseConstant.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.kakarote.crm9.common.constant;
22

3+
import com.jfinal.plugin.activerecord.Db;
34
import com.kakarote.crm9.utils.BaseUtil;
45

56
import java.io.Serializable;
@@ -11,7 +12,7 @@ public class BaseConstant implements Serializable {
1112

1213
public static final String NAME = "72CRM";
1314

14-
public static final String VERSION = "1.0.0";
15+
public static final String VERSION = "1.3.0";
1516

1617
private static final long serialVersionUID = 1L;
1718
/**
@@ -24,7 +25,7 @@ public class BaseConstant implements Serializable {
2425
/**
2526
* 角色类型列表
2627
*/
27-
public static final Integer[] ROLE_TYPES = {1, 2, 3, 4, 5, 0};
28+
public static final Integer[] ROLE_TYPES = {1, 2, 3, 4, 0};
2829

2930
/**
3031
* 超级管理员的roleId
@@ -45,4 +46,18 @@ public class BaseConstant implements Serializable {
4546
*/
4647
public static final String USER_LOGIN_ERROR_KEY = "LOGIN_ERROR_USER_";
4748

49+
/**
50+
* 项目管理员角色ID
51+
*/
52+
public static Integer WORK_ADMIN_ROLE_ID;
53+
/**
54+
* 每个项目管理员角色ID
55+
*/
56+
public static Integer SMALL_WORK_ADMIN_ROLE_ID;
57+
58+
/**
59+
* 每个项目编辑角色ID
60+
*/
61+
public static Integer SMALL_WORK_EDIT_ROLE_ID;
62+
4863
}

src/main/java/com/kakarote/crm9/erp/_MappingKit.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public static void mapping(ActiveRecordPlugin arp) {
1919
arp.addMapping("72crm_admin_field_sort", "field_id", AdminFieldSort.class);
2020
arp.addMapping("72crm_admin_field_style", "id", AdminFieldStyle.class);
2121
arp.addMapping("72crm_admin_fieldv", "id", AdminFieldv.class);
22-
2322
arp.addMapping("72crm_admin_file", "file_id", AdminFile.class);
2423
arp.addMapping("72crm_admin_menu", "menu_id", AdminMenu.class);
2524
arp.addMapping("72crm_admin_record", "record_id", AdminRecord.class);
@@ -64,10 +63,10 @@ public static void mapping(ActiveRecordPlugin arp) {
6463
arp.addMapping("72crm_task_comment", "comment_id", TaskComment.class);
6564
arp.addMapping("72crm_task_relation", "r_id", TaskRelation.class);
6665
arp.addMapping("72crm_work", "work_id", Work.class);
67-
arp.addMapping("72crm_work_relation", "r_id", WorkRelation.class);
6866
arp.addMapping("72crm_work_task_class", "class_id", WorkTaskClass.class);
69-
arp.addMapping("72crm_work_task_lable", "lable_id", WorkTaskLable.class);
67+
arp.addMapping("72crm_work_task_label", "label_id", WorkTaskLabel.class);
7068
arp.addMapping("72crm_work_task_log", "log_id", WorkTaskLog.class);
69+
arp.addMapping("72crm_work_user", "id", WorkUser.class);
7170
arp.addMapping("72crm_crm_business_change", "change_id", CrmBusinessChange.class);
7271
}
7372
}

src/main/java/com/kakarote/crm9/erp/admin/controller/AdminFieldController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
import com.alibaba.fastjson.JSON;
44
import com.alibaba.fastjson.JSONObject;
5-
import com.jfinal.aop.Before;
5+
import com.jfinal.aop.Clear;
66
import com.jfinal.aop.Inject;
77
import com.jfinal.core.Controller;
88
import com.jfinal.core.paragetter.Para;
9-
import com.jfinal.ext.interceptor.POST;
109
import com.jfinal.plugin.activerecord.Record;
1110
import com.kakarote.crm9.common.annotation.NotNullValidate;
1211
import com.kakarote.crm9.erp.admin.entity.AdminFieldSort;
@@ -167,6 +166,7 @@ public void setFelidStyle(@Para("") AdminFieldStyle adminFleldStyle){
167166
* @author zhangzhiwei
168167
* 验证字段数据
169168
*/
169+
@Clear
170170
@NotNullValidate(value = "val",message = "字段校验参数错误")
171171
@NotNullValidate(value = "types",message = "字段校验参数错误")
172172
@NotNullValidate(value = "name",message = "字段校验参数错误")

src/main/java/com/kakarote/crm9/erp/admin/controller/AdminLoginController.java

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
* @author z
3434
*/
3535
@Clear
36-
public class AdminLoginController extends Controller {
36+
public class AdminLoginController extends Controller{
3737

3838
@Inject
3939
private AdminRoleService adminRoleService;
4040

4141
public static Prop prop = PropKit.use("config/crm9-config.txt");
4242

43-
public void index() {
43+
public void index(){
4444
redirect("/index.html");
4545
}
4646

@@ -50,96 +50,99 @@ public void index() {
5050
* @author zhangzhiwei
5151
* 用户登录
5252
*/
53-
public void login(@Para("username") String username, @Para("password") String password) {
54-
String key = BaseConstant.USER_LOGIN_ERROR_KEY+username;
53+
public void login(@Para("username") String username, @Para("password") String password){
54+
String key = BaseConstant.USER_LOGIN_ERROR_KEY + username;
5555
Cache redis = Redis.use();
56-
long beforeTime = System.currentTimeMillis() - 60*5*1000;
56+
long beforeTime = System.currentTimeMillis() - 60 * 5 * 1000;
5757
if(redis.exists(key)){
58-
Set zrevrange = redis.zrange(key, 0,0);
59-
Long time = (Long) zrevrange.iterator().next()+60*5*1000;
60-
if (redis.zcount(key, beforeTime, System.currentTimeMillis()) >= 5) {
61-
long expire = (time-System.currentTimeMillis())/1000;
62-
renderJson(R.error("密码错误次数过多,请等"+expire+"秒后在重试!"));
58+
if(redis.zcount(key, beforeTime, System.currentTimeMillis()) >= 5){
59+
Set zrevrange = redis.zrevrange(key, 4, 5);
60+
Long time = (Long) zrevrange.iterator().next() + 60 * 5 * 1000;
61+
long expire = (time - System.currentTimeMillis()) / 1000;
62+
renderJson(R.error("密码错误次数过多,请等" + expire + "秒后在重试!"));
6363
return;
6464
}
6565
}
66-
redis.zadd(key,System.currentTimeMillis(),System.currentTimeMillis());
67-
if (StrUtil.isEmpty(username) || StrUtil.isEmpty(password)) {
66+
redis.zadd(key, System.currentTimeMillis(), System.currentTimeMillis());
67+
if(StrUtil.isEmpty(username) || StrUtil.isEmpty(password)){
6868
renderJson(R.error("请输入用户名和密码!"));
6969
return;
7070
}
7171
AdminUser user = AdminUser.dao.findFirst(Db.getSql("admin.user.queryByUserName"), username.trim());
72-
if (user == null) {
72+
if(user == null){
7373
renderJson(R.error("用户名或密码错误!"));
74-
} else {
75-
if (user.getStatus() == 0) {
76-
renderJson(R.error("账户被禁用!"));
77-
}
78-
if (BaseUtil.verify(username + password, user.getSalt(), user.getPassword())) {
79-
if (user.getStatus() == 2) {
80-
user.setStatus(1);
81-
}
82-
String token = IdUtil.simpleUUID();
83-
user.setLastLoginIp(BaseUtil.getLoginAddress(getRequest()));
84-
user.setLastLoginTime(new Date());
85-
user.update();
86-
user.setRoles(adminRoleService.queryRoleIdsByUserId(user.getUserId()));
87-
Redis.use().setex(token, 360000, user);
88-
user.remove("password", "salt");
89-
setCookie("Admin-Token", token, 360000);
90-
renderJson(R.ok().put("Admin-Token", token).put("user", user).put("auth", adminRoleService.auth(user.getUserId())));
91-
} else {
92-
Log.getLog(getClass()).warn("用户登录失败");
93-
renderJson(R.error("用户名或密码错误!"));
74+
return;
75+
}
76+
if(user.getStatus() == 0){
77+
renderJson(R.error("账户被禁用!"));
78+
return;
79+
}
80+
if(BaseUtil.verify(username + password, user.getSalt(), user.getPassword())){
81+
if(user.getStatus() == 2){
82+
user.setStatus(1);
9483
}
84+
redis.del(key);
85+
String token = IdUtil.simpleUUID();
86+
user.setLastLoginIp(BaseUtil.getLoginAddress(getRequest()));
87+
user.setLastLoginTime(new Date());
88+
user.update();
89+
user.setRoles(adminRoleService.queryRoleIdsByUserId(user.getUserId()));
90+
Redis.use().setex(token, 360000, user);
91+
user.remove("password", "salt");
92+
setCookie("Admin-Token", token, 360000);
93+
renderJson(R.ok().put("Admin-Token", token).put("user", user).put("auth", adminRoleService.auth(user.getUserId())));
94+
}else{
95+
Log.getLog(getClass()).warn("用户登录失败");
96+
renderJson(R.error("用户名或密码错误!"));
9597
}
98+
9699
}
97100

98101
/**
99102
* @author zhangzhiwei
100103
* 退出登录
101104
*/
102-
public void logout() {
105+
public void logout(){
103106
String token = BaseUtil.getToken(getRequest());
104-
if (!StrUtil.isEmpty(token)) {
107+
if(! StrUtil.isEmpty(token)){
105108
Redis.use().del(token);
106109
removeCookie("Admin-Token");
107110
}
108111
renderJson(R.ok());
109112
}
110113

111-
public void version() {
114+
public void version(){
112115
renderJson(R.ok().put("name", BaseConstant.NAME).put("version", BaseConstant.VERSION));
113116
}
114117

115-
public void ping() {
118+
public void ping(){
116119
List<String> arrays = new ArrayList<>();
117120
Connection connection = null;
118-
try {
121+
try{
119122
connection = Db.use().getConfig().getConnection();
120-
if (connection != null) {
123+
if(connection != null){
121124
arrays.add("数据库连接成功");
122125
}
123-
} catch (Exception e) {
126+
}catch(Exception e){
124127
arrays.add("数据库连接异常");
125-
} finally {
126-
if (connection != null) {
127-
try {
128+
}finally{
129+
if(connection != null){
130+
try{
128131
connection.close();
129-
} catch (SQLException e) {
132+
}catch(SQLException e){
130133
e.printStackTrace();
131134
}
132135
}
133136

134137
}
135-
try {
138+
try{
136139
String ping = Redis.use().ping();
137-
if ("PONG".equals(ping)) {
140+
if("PONG".equals(ping)){
138141
arrays.add("Redis配置成功");
139-
} else {
142+
}else{
140143
arrays.add("Redis配置失败");
141144
}
142-
} catch (Exception e) {
145+
}catch(Exception e){
143146
arrays.add("Redis配置失败");
144147
}
145148
renderJson(R.ok().put("data", arrays));
@@ -152,14 +155,14 @@ public void ping() {
152155
public void dingLogin(String code){
153156
String appkey = prop.get("appkey");
154157
String appSecert = prop.get("appSecret");
155-
String tokenJson = HttpUtil.get("https://oapi.dingtalk.com/gettoken?appkey="+appkey+"&appsecret="+appSecert);
158+
String tokenJson = HttpUtil.get("https://oapi.dingtalk.com/gettoken?appkey=" + appkey + "&appsecret=" + appSecert);
156159
String accessToken = JSONObject.parseObject(tokenJson).getString("access_token");
157-
String userJson = HttpUtil.get("https://oapi.dingtalk.com/user/getuserinfo?access_token="+accessToken+"&code="+code);
160+
String userJson = HttpUtil.get("https://oapi.dingtalk.com/user/getuserinfo?access_token=" + accessToken + "&code=" + code);
158161
String userId = JSONObject.parseObject(userJson).getString("userid");
159-
String userInfo = HttpUtil.get("https://oapi.dingtalk.com/user/get?access_token="+accessToken+"&userid="+userId);
162+
String userInfo = HttpUtil.get("https://oapi.dingtalk.com/user/get?access_token=" + accessToken + "&userid=" + userId);
160163
String mobile = JSONObject.parseObject(userInfo).getString("mobile");
161-
Integer isUser = Db.queryInt("select count(*) from 72crm_admin_user where mobile = ?",mobile);
162-
if (isUser > 0){
164+
Integer isUser = Db.queryInt("select count(*) from 72crm_admin_user where mobile = ?", mobile);
165+
if(isUser > 0){
163166
AdminUser user = AdminUser.dao.findFirst(Db.getSql("admin.user.queryByUserName"), mobile.trim());
164167
String token = IdUtil.simpleUUID();
165168
user.setLastLoginIp(BaseUtil.getLoginAddress(getRequest()));
@@ -170,7 +173,7 @@ public void dingLogin(String code){
170173
user.remove("password", "salt");
171174
setCookie("Admin-Token", token, 360000);
172175
renderJson(R.ok().put("Admin-Token", token).put("user", user).put("auth", adminRoleService.auth(user.getUserId())));
173-
}else {
176+
}else{
174177
renderJson(R.error("账户不存在"));
175178
}
176179
}

src/main/java/com/kakarote/crm9/erp/admin/controller/AdminMenuController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.kakarote.crm9.erp.admin.controller;
22

3+
import com.jfinal.plugin.activerecord.Db;
4+
import com.kakarote.crm9.common.constant.BaseConstant;
5+
import com.kakarote.crm9.erp.admin.entity.AdminMenu;
36
import com.kakarote.crm9.erp.admin.service.AdminMenuService;
47
import com.kakarote.crm9.utils.R;
58
import com.jfinal.aop.Inject;
@@ -26,4 +29,15 @@ public void getRoleMenu(@Para("roleId") Integer roleId){
2629
public void getAllMenuList(){
2730
renderJson(R.ok().put("data",adminMenuService.getAllMenuList(0,20)));
2831
}
32+
33+
/**
34+
* @author hmb
35+
* 展示全部菜单
36+
*/
37+
public void getWorkMenuList(){
38+
Integer workMenuId = Db.queryInt("select menu_id from `72crm_admin_menu` where parent_id = 0 and realm = 'work'");
39+
AdminMenu root = new AdminMenu().findById(workMenuId);
40+
root.put("childMenu",adminMenuService.getWorkMenuList(root.getMenuId(),20));
41+
renderJson(R.ok().put("data",root));
42+
}
2943
}

src/main/java/com/kakarote/crm9/erp/admin/controller/AdminRoleController.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.kakarote.crm9.erp.admin.controller;
22

33
import com.alibaba.fastjson.JSON;
4+
import com.alibaba.fastjson.JSONObject;
45
import com.kakarote.crm9.common.annotation.NotNullValidate;
56
import com.kakarote.crm9.erp.admin.entity.AdminRole;
67
import com.kakarote.crm9.erp.admin.entity.AdminUserRole;
@@ -94,6 +95,15 @@ public void delete(@Para("roleId")Integer roleId){
9495
renderJson(adminRoleService.delete(roleId) ? R.ok() : R.error());
9596
}
9697

98+
/**
99+
* @author wyq
100+
* @param roleId 角色项目管理角色id
101+
* 删除
102+
*/
103+
public void deleteWorkRole(@Para("roleId")Integer roleId){
104+
renderJson(adminRoleService.deleteWorkRole(roleId) ? R.ok() : R.error());
105+
}
106+
97107
/**
98108
* @author wyq
99109
* 关联员工
@@ -109,4 +119,22 @@ public void relatedUser(@Para("")AdminUserRole adminUserRole){
109119
public void unbindingUser(@Para("") AdminUserRole adminUserRole){
110120
renderJson(adminRoleService.unbindingUser(adminUserRole));
111121
}
122+
123+
/**
124+
* 项目管理角色列表
125+
* @author wyq
126+
*/
127+
public void queryProjectRoleList(){
128+
renderJson(adminRoleService.queryProjectRoleList());
129+
}
130+
131+
132+
/**
133+
* 设置项目管理角色
134+
* @author wyq
135+
*/
136+
public void setWorkRole(){
137+
JSONObject jsonObject = JSON.parseObject(getRawData());
138+
renderJson(adminRoleService.setWorkRole(jsonObject));
139+
}
112140
}

0 commit comments

Comments
 (0)