Skip to content

Commit

Permalink
72crm_java_20190719
Browse files Browse the repository at this point in the history
  • Loading branch information
GspiriTer committed Aug 19, 2019
1 parent feff2b9 commit f6370c5
Show file tree
Hide file tree
Showing 356 changed files with 15,105 additions and 1,317 deletions.
3 changes: 2 additions & 1 deletion 72crm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ fi

# 生成 class path 值

APP_BASE_PATH="./"
APP_BASE_PATH=$(cd `dirname $0`; pwd)

CP=${APP_BASE_PATH}/config:${APP_BASE_PATH}/lib/*

function start()
Expand Down
265 changes: 96 additions & 169 deletions docs/crm9.sql

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.kakarote</groupId>
<artifactId>crm9</artifactId>
<packaging>jar</packaging>
<version>1.2.1</version>
<version>1.3.0</version>
<name>crm9-master</name>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.jfinal.plugin.redis.RedisPlugin;
import com.jfinal.render.RenderManager;
import com.jfinal.template.Engine;
import com.kakarote.crm9.erp.work.service.WorkService;

import java.io.File;

Expand Down Expand Up @@ -164,6 +165,8 @@ public void onStart() {
adminFieldService.createView(7);
adminFieldService.createView(8);
adminFieldService.createView(10);
WorkService workService= Aop.get(WorkService.class);
workService.initialization();
}

@Override
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/com/kakarote/crm9/common/constant/BaseConstant.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kakarote.crm9.common.constant;

import com.jfinal.plugin.activerecord.Db;
import com.kakarote.crm9.utils.BaseUtil;

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

public static final String NAME = "72CRM";

public static final String VERSION = "1.0.0";
public static final String VERSION = "1.3.0";

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

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

/**
* 项目管理员角色ID
*/
public static Integer WORK_ADMIN_ROLE_ID;
/**
* 每个项目管理员角色ID
*/
public static Integer SMALL_WORK_ADMIN_ROLE_ID;

/**
* 每个项目编辑角色ID
*/
public static Integer SMALL_WORK_EDIT_ROLE_ID;

}
5 changes: 2 additions & 3 deletions src/main/java/com/kakarote/crm9/erp/_MappingKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static void mapping(ActiveRecordPlugin arp) {
arp.addMapping("72crm_admin_field_sort", "field_id", AdminFieldSort.class);
arp.addMapping("72crm_admin_field_style", "id", AdminFieldStyle.class);
arp.addMapping("72crm_admin_fieldv", "id", AdminFieldv.class);

arp.addMapping("72crm_admin_file", "file_id", AdminFile.class);
arp.addMapping("72crm_admin_menu", "menu_id", AdminMenu.class);
arp.addMapping("72crm_admin_record", "record_id", AdminRecord.class);
Expand Down Expand Up @@ -64,10 +63,10 @@ public static void mapping(ActiveRecordPlugin arp) {
arp.addMapping("72crm_task_comment", "comment_id", TaskComment.class);
arp.addMapping("72crm_task_relation", "r_id", TaskRelation.class);
arp.addMapping("72crm_work", "work_id", Work.class);
arp.addMapping("72crm_work_relation", "r_id", WorkRelation.class);
arp.addMapping("72crm_work_task_class", "class_id", WorkTaskClass.class);
arp.addMapping("72crm_work_task_lable", "lable_id", WorkTaskLable.class);
arp.addMapping("72crm_work_task_label", "label_id", WorkTaskLabel.class);
arp.addMapping("72crm_work_task_log", "log_id", WorkTaskLog.class);
arp.addMapping("72crm_work_user", "id", WorkUser.class);
arp.addMapping("72crm_crm_business_change", "change_id", CrmBusinessChange.class);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.core.paragetter.Para;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.plugin.activerecord.Record;
import com.kakarote.crm9.common.annotation.NotNullValidate;
import com.kakarote.crm9.erp.admin.entity.AdminFieldSort;
Expand Down Expand Up @@ -167,6 +166,7 @@ public void setFelidStyle(@Para("") AdminFieldStyle adminFleldStyle){
* @author zhangzhiwei
* 验证字段数据
*/
@Clear
@NotNullValidate(value = "val",message = "字段校验参数错误")
@NotNullValidate(value = "types",message = "字段校验参数错误")
@NotNullValidate(value = "name",message = "字段校验参数错误")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
* @author z
*/
@Clear
public class AdminLoginController extends Controller {
public class AdminLoginController extends Controller{

@Inject
private AdminRoleService adminRoleService;

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

public void index() {
public void index(){
redirect("/index.html");
}

Expand All @@ -50,96 +50,99 @@ public void index() {
* @author zhangzhiwei
* 用户登录
*/
public void login(@Para("username") String username, @Para("password") String password) {
String key = BaseConstant.USER_LOGIN_ERROR_KEY+username;
public void login(@Para("username") String username, @Para("password") String password){
String key = BaseConstant.USER_LOGIN_ERROR_KEY + username;
Cache redis = Redis.use();
long beforeTime = System.currentTimeMillis() - 60*5*1000;
long beforeTime = System.currentTimeMillis() - 60 * 5 * 1000;
if(redis.exists(key)){
Set zrevrange = redis.zrange(key, 0,0);
Long time = (Long) zrevrange.iterator().next()+60*5*1000;
if (redis.zcount(key, beforeTime, System.currentTimeMillis()) >= 5) {
long expire = (time-System.currentTimeMillis())/1000;
renderJson(R.error("密码错误次数过多,请等"+expire+"秒后在重试!"));
if(redis.zcount(key, beforeTime, System.currentTimeMillis()) >= 5){
Set zrevrange = redis.zrevrange(key, 4, 5);
Long time = (Long) zrevrange.iterator().next() + 60 * 5 * 1000;
long expire = (time - System.currentTimeMillis()) / 1000;
renderJson(R.error("密码错误次数过多,请等" + expire + "秒后在重试!"));
return;
}
}
redis.zadd(key,System.currentTimeMillis(),System.currentTimeMillis());
if (StrUtil.isEmpty(username) || StrUtil.isEmpty(password)) {
redis.zadd(key, System.currentTimeMillis(), System.currentTimeMillis());
if(StrUtil.isEmpty(username) || StrUtil.isEmpty(password)){
renderJson(R.error("请输入用户名和密码!"));
return;
}
AdminUser user = AdminUser.dao.findFirst(Db.getSql("admin.user.queryByUserName"), username.trim());
if (user == null) {
if(user == null){
renderJson(R.error("用户名或密码错误!"));
} else {
if (user.getStatus() == 0) {
renderJson(R.error("账户被禁用!"));
}
if (BaseUtil.verify(username + password, user.getSalt(), user.getPassword())) {
if (user.getStatus() == 2) {
user.setStatus(1);
}
String token = IdUtil.simpleUUID();
user.setLastLoginIp(BaseUtil.getLoginAddress(getRequest()));
user.setLastLoginTime(new Date());
user.update();
user.setRoles(adminRoleService.queryRoleIdsByUserId(user.getUserId()));
Redis.use().setex(token, 360000, user);
user.remove("password", "salt");
setCookie("Admin-Token", token, 360000);
renderJson(R.ok().put("Admin-Token", token).put("user", user).put("auth", adminRoleService.auth(user.getUserId())));
} else {
Log.getLog(getClass()).warn("用户登录失败");
renderJson(R.error("用户名或密码错误!"));
return;
}
if(user.getStatus() == 0){
renderJson(R.error("账户被禁用!"));
return;
}
if(BaseUtil.verify(username + password, user.getSalt(), user.getPassword())){
if(user.getStatus() == 2){
user.setStatus(1);
}
redis.del(key);
String token = IdUtil.simpleUUID();
user.setLastLoginIp(BaseUtil.getLoginAddress(getRequest()));
user.setLastLoginTime(new Date());
user.update();
user.setRoles(adminRoleService.queryRoleIdsByUserId(user.getUserId()));
Redis.use().setex(token, 360000, user);
user.remove("password", "salt");
setCookie("Admin-Token", token, 360000);
renderJson(R.ok().put("Admin-Token", token).put("user", user).put("auth", adminRoleService.auth(user.getUserId())));
}else{
Log.getLog(getClass()).warn("用户登录失败");
renderJson(R.error("用户名或密码错误!"));
}

}

/**
* @author zhangzhiwei
* 退出登录
*/
public void logout() {
public void logout(){
String token = BaseUtil.getToken(getRequest());
if (!StrUtil.isEmpty(token)) {
if(! StrUtil.isEmpty(token)){
Redis.use().del(token);
removeCookie("Admin-Token");
}
renderJson(R.ok());
}

public void version() {
public void version(){
renderJson(R.ok().put("name", BaseConstant.NAME).put("version", BaseConstant.VERSION));
}

public void ping() {
public void ping(){
List<String> arrays = new ArrayList<>();
Connection connection = null;
try {
try{
connection = Db.use().getConfig().getConnection();
if (connection != null) {
if(connection != null){
arrays.add("数据库连接成功");
}
} catch (Exception e) {
}catch(Exception e){
arrays.add("数据库连接异常");
} finally {
if (connection != null) {
try {
}finally{
if(connection != null){
try{
connection.close();
} catch (SQLException e) {
}catch(SQLException e){
e.printStackTrace();
}
}

}
try {
try{
String ping = Redis.use().ping();
if ("PONG".equals(ping)) {
if("PONG".equals(ping)){
arrays.add("Redis配置成功");
} else {
}else{
arrays.add("Redis配置失败");
}
} catch (Exception e) {
}catch(Exception e){
arrays.add("Redis配置失败");
}
renderJson(R.ok().put("data", arrays));
Expand All @@ -152,14 +155,14 @@ public void ping() {
public void dingLogin(String code){
String appkey = prop.get("appkey");
String appSecert = prop.get("appSecret");
String tokenJson = HttpUtil.get("https://oapi.dingtalk.com/gettoken?appkey="+appkey+"&appsecret="+appSecert);
String tokenJson = HttpUtil.get("https://oapi.dingtalk.com/gettoken?appkey=" + appkey + "&appsecret=" + appSecert);
String accessToken = JSONObject.parseObject(tokenJson).getString("access_token");
String userJson = HttpUtil.get("https://oapi.dingtalk.com/user/getuserinfo?access_token="+accessToken+"&code="+code);
String userJson = HttpUtil.get("https://oapi.dingtalk.com/user/getuserinfo?access_token=" + accessToken + "&code=" + code);
String userId = JSONObject.parseObject(userJson).getString("userid");
String userInfo = HttpUtil.get("https://oapi.dingtalk.com/user/get?access_token="+accessToken+"&userid="+userId);
String userInfo = HttpUtil.get("https://oapi.dingtalk.com/user/get?access_token=" + accessToken + "&userid=" + userId);
String mobile = JSONObject.parseObject(userInfo).getString("mobile");
Integer isUser = Db.queryInt("select count(*) from 72crm_admin_user where mobile = ?",mobile);
if (isUser > 0){
Integer isUser = Db.queryInt("select count(*) from 72crm_admin_user where mobile = ?", mobile);
if(isUser > 0){
AdminUser user = AdminUser.dao.findFirst(Db.getSql("admin.user.queryByUserName"), mobile.trim());
String token = IdUtil.simpleUUID();
user.setLastLoginIp(BaseUtil.getLoginAddress(getRequest()));
Expand All @@ -170,7 +173,7 @@ public void dingLogin(String code){
user.remove("password", "salt");
setCookie("Admin-Token", token, 360000);
renderJson(R.ok().put("Admin-Token", token).put("user", user).put("auth", adminRoleService.auth(user.getUserId())));
}else {
}else{
renderJson(R.error("账户不存在"));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.kakarote.crm9.erp.admin.controller;

import com.jfinal.plugin.activerecord.Db;
import com.kakarote.crm9.common.constant.BaseConstant;
import com.kakarote.crm9.erp.admin.entity.AdminMenu;
import com.kakarote.crm9.erp.admin.service.AdminMenuService;
import com.kakarote.crm9.utils.R;
import com.jfinal.aop.Inject;
Expand All @@ -26,4 +29,15 @@ public void getRoleMenu(@Para("roleId") Integer roleId){
public void getAllMenuList(){
renderJson(R.ok().put("data",adminMenuService.getAllMenuList(0,20)));
}

/**
* @author hmb
* 展示全部菜单
*/
public void getWorkMenuList(){
Integer workMenuId = Db.queryInt("select menu_id from `72crm_admin_menu` where parent_id = 0 and realm = 'work'");
AdminMenu root = new AdminMenu().findById(workMenuId);
root.put("childMenu",adminMenuService.getWorkMenuList(root.getMenuId(),20));
renderJson(R.ok().put("data",root));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kakarote.crm9.erp.admin.controller;

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

/**
* @author wyq
* @param roleId 角色项目管理角色id
* 删除
*/
public void deleteWorkRole(@Para("roleId")Integer roleId){
renderJson(adminRoleService.deleteWorkRole(roleId) ? R.ok() : R.error());
}

/**
* @author wyq
* 关联员工
Expand All @@ -109,4 +119,22 @@ public void relatedUser(@Para("")AdminUserRole adminUserRole){
public void unbindingUser(@Para("") AdminUserRole adminUserRole){
renderJson(adminRoleService.unbindingUser(adminUserRole));
}

/**
* 项目管理角色列表
* @author wyq
*/
public void queryProjectRoleList(){
renderJson(adminRoleService.queryProjectRoleList());
}


/**
* 设置项目管理角色
* @author wyq
*/
public void setWorkRole(){
JSONObject jsonObject = JSON.parseObject(getRawData());
renderJson(adminRoleService.setWorkRole(jsonObject));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Map<String, Integer> saveExamineRecord(Integer type, Long userId, Integer
//如果是负责人主管审批 获取主管ID
Record r = Db.findFirst(Db.getSql("admin.examineLog.queryUserByUserId"), ownerUserId);
if (r == null || r.getLong("user_id") == null){
examineLog.setExamineUser(Long.valueOf(BaseConstant.SUPER_ADMIN_USER_ID));
examineLog.setExamineUser(BaseConstant.SUPER_ADMIN_USER_ID);
}else {
examineLog.setExamineUser(r.getLong("user_id"));}
examineLog.setRecordId(examineRecord.getRecordId());
Expand Down
Loading

0 comments on commit f6370c5

Please sign in to comment.