16 changed files with 614 additions and 76 deletions
@ -0,0 +1,69 @@ |
|||
package com.dreamchaser.depository_manage.entity; |
|||
|
|||
import lombok.Data; |
|||
import lombok.extern.log4j.Log4j2; |
|||
import org.apache.commons.codec.digest.DigestUtils; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 加密算法 |
|||
* <p> |
|||
* 1、分解步骤 |
|||
* one = md5(CodeString)+md5(AppKey) |
|||
* two = md5(one)+AppKey |
|||
* therr = md5(two) |
|||
* 2、合并 |
|||
* md5(md5(md5(CodeString)+md5(AppKey))+AppKey) |
|||
*/ |
|||
@Log4j2 |
|||
@Data |
|||
public class EncryptionAlgorithm { |
|||
private static String CONSTANT_CONFIG_AppKey = "heng_xin_gao_ke_AppKey"; //应用程序密钥
|
|||
|
|||
private String code; |
|||
private String appkey; |
|||
|
|||
|
|||
public EncryptionAlgorithm(String code) { |
|||
this.code = code; |
|||
this.appkey = CONSTANT_CONFIG_AppKey; |
|||
} |
|||
|
|||
public String Algorithm() { |
|||
String keyMd5 = DigestUtils.md5Hex(this.appkey); |
|||
String codeMd51 = DigestUtils.md5Hex(this.code); |
|||
String one = codeMd51 + keyMd5; |
|||
String oneMd5 = DigestUtils.md5Hex(one); |
|||
String two = oneMd5 + this.appkey; |
|||
return DigestUtils.md5Hex(two); |
|||
} |
|||
|
|||
/** |
|||
* 用于获取当前用户的key与token |
|||
* @param userByPort 待获取用户 |
|||
* @return |
|||
*/ |
|||
public Map<String, String> getUserKeyAndUserToken(UserByPort userByPort) { |
|||
Map<String, String> result = new HashMap<>(); |
|||
if(userByPort == null){ |
|||
return null; |
|||
} |
|||
EncryptionAlgorithm md5EncryptionForNumber = new EncryptionAlgorithm(userByPort.getNumber()); |
|||
String userKey = md5EncryptionForNumber.Algorithm(); |
|||
|
|||
EncryptionAlgorithm md5Encryption = new EncryptionAlgorithm(CONSTANT_CONFIG_AppKey); |
|||
String sha1Str = userKey + userByPort.getNumber() + userByPort.getPassword() + md5Encryption.Algorithm(); |
|||
String userToken = DigestUtils.sha1Hex(sha1Str); |
|||
|
|||
|
|||
result.put("userKey", userKey); |
|||
result.put("userToken", userToken); |
|||
return result; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
@ -1,65 +0,0 @@ |
|||
package com.dreamchaser.depository_manage.entity; |
|||
|
|||
import lombok.Data; |
|||
import lombok.extern.log4j.Log4j2; |
|||
import org.apache.commons.codec.digest.DigestUtils; |
|||
|
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 加密算法 |
|||
*/ |
|||
@Log4j2 |
|||
@Data |
|||
public class Md5Encryption { |
|||
private static String CONSTANT_CONFIG_AppKey = "heng_xin_gao_ke_AppKey"; //应用程序密钥
|
|||
|
|||
private String code; |
|||
private String appkey; |
|||
|
|||
public String Md5EncryptionAlgorithm(){ |
|||
if(this.appkey == ""){ |
|||
Md5EncryptionInit(this.code); |
|||
} |
|||
String keyMd5 = DigestUtils.md5Hex(this.appkey); |
|||
String codeMd1 = DigestUtils.md5Hex(this.code); |
|||
String yiCeng = codeMd1 + keyMd5; |
|||
String yiCengMd5 = DigestUtils.md5Hex(yiCeng); |
|||
String erCeng = yiCengMd5 + this.appkey; |
|||
String md5Val = DigestUtils.md5Hex(erCeng); |
|||
return md5Val; |
|||
} |
|||
|
|||
public String Md5EncryptionAlgorithmFj(){ |
|||
if(this.appkey == ""){ |
|||
Md5EncryptionInit(this.code); |
|||
} |
|||
log.info("Code ===> "+this.code); |
|||
log.info("AppKey ===> "+this.appkey); |
|||
|
|||
String keyMd5 = DigestUtils.md5Hex(this.appkey); |
|||
log.info("Step1:--AppKey-加密->"+keyMd5); |
|||
String codeMd1 = DigestUtils.md5Hex(this.code); |
|||
log.info("Step2:--CodeString-加密->"+codeMd1); |
|||
String yiCeng = codeMd1 + keyMd5; |
|||
log.info("Step3:--CodeString+AppKey-->"+yiCeng); |
|||
String yiCengMd5 = DigestUtils.md5Hex(yiCeng); |
|||
log.info("Step4:--one-加密->"+yiCengMd5); |
|||
String erCeng = yiCengMd5 + this.appkey; |
|||
log.info("Step5:--one + AppKey->"+erCeng); |
|||
String erCengMd5 = DigestUtils.md5Hex(erCeng); |
|||
log.info("Step6:--therr--加密-->\n",erCengMd5); |
|||
return erCengMd5; |
|||
} |
|||
|
|||
/** |
|||
* 初始化程序 |
|||
* @param code |
|||
*/ |
|||
public void Md5EncryptionInit(String code){ |
|||
this.code = code; |
|||
this.appkey = CONSTANT_CONFIG_AppKey; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,16 @@ |
|||
package com.dreamchaser.depository_manage.hrNew_mapper; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.Post; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
@Mapper |
|||
public interface PostMapper { |
|||
/** |
|||
* 根据岗位id获取岗位信息 |
|||
* @param postId |
|||
* @return |
|||
*/ |
|||
Post findPostById(Long postId); |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.dreamchaser.depository_manage.hrNew_mapper.PostMapper"> |
|||
<resultMap id="postMap" type="com.dreamchaser.depository_manage.entity.Post"> |
|||
<id property="id" column="id" jdbcType="BIGINT"/> |
|||
<result property="number" column="number" jdbcType="VARCHAR"/> |
|||
<result property="name" column="name" jdbcType="VARCHAR"/> |
|||
<result property="duties" column="duties" jdbcType="BIGINT"/> |
|||
<result property="time" column="time" jdbcType="BIGINT"/> |
|||
<result property="state" column="state" jdbcType="INTEGER"/> |
|||
<result property="superior" column="superior" jdbcType="BIGINT"/> |
|||
<result property="personincharge" column="perincha" jdbcType="INTEGER"/> |
|||
<result property="department" column="department" jdbcType="BIGINT"/> |
|||
<result property="adminorg" column="adm_org" jdbcType="BIGINT"/> |
|||
<result property="dutiesname" column="duties_name" jdbcType="VARCHAR"/> |
|||
<result property="dutiesnumber" column="duties_number" jdbcType="VARCHAR"/> |
|||
<result property="aoname" column="aoname" jdbcType="VARCHAR"/> |
|||
<result property="aonumber" column="aonumber" jdbcType="VARCHAR"/> |
|||
<result property="aonumber" column="aonumber" jdbcType="VARCHAR"/> |
|||
<result property="jobname" column="job_name" jdbcType="VARCHAR"/> |
|||
<result property="superiorname" column="superiorname" jdbcType="VARCHAR"/> |
|||
<result property="superiornumber" column="superiornumber" jdbcType="VARCHAR"/> |
|||
<result property="departmentname" column="departmentname" jdbcType="VARCHAR"/> |
|||
</resultMap> |
|||
|
|||
<sql id="allColumnView"> |
|||
id,number,name,duties,time,state,superior,perincha,department,adm_org,duties_name,duties_number,job_name |
|||
</sql> |
|||
|
|||
<select id="findPostById" parameterType="long" resultMap="postMap"> |
|||
select |
|||
<include refid="allColumnView"/> |
|||
from post_duties_job |
|||
where id = #{postId} |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
|||
@ -0,0 +1,39 @@ |
|||
package com.dreamchaser.depository_manage.service; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.Administration; |
|||
import com.dreamchaser.depository_manage.entity.UserByPort; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface AdministrativeService { |
|||
|
|||
/** |
|||
* 根据id获取行政组织 |
|||
* @param id 待获取行政组织id |
|||
* @return |
|||
*/ |
|||
Administration findAdministrationById(Long id); |
|||
|
|||
/** |
|||
* 获取所有行政组织 |
|||
* @return |
|||
*/ |
|||
List<Administration> findAdministrationsAll(); |
|||
|
|||
/** |
|||
* 获取当前用户所处部门 |
|||
* |
|||
* @param userByPort 待获取用户 |
|||
* @return |
|||
*/ |
|||
public Administration getDepartmentByUser(UserByPort userByPort); |
|||
|
|||
|
|||
/** |
|||
* 获取当前用户所处的部门id(高科)_ |
|||
* @param departmentId 待获取部门id |
|||
* @return |
|||
*/ |
|||
public Administration getDepartmentForHXGK(Long departmentId); |
|||
|
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
package com.dreamchaser.depository_manage.service.impl; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.Administration; |
|||
import com.dreamchaser.depository_manage.entity.UserByPort; |
|||
import com.dreamchaser.depository_manage.hrNew_mapper.AdministrativeMapper; |
|||
import com.dreamchaser.depository_manage.service.AdministrativeService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
@Service |
|||
public class AdministrativeServiceImpl implements AdministrativeService { |
|||
|
|||
@Autowired |
|||
private AdministrativeMapper administrativeMapper; |
|||
|
|||
/** |
|||
* 根据id获取行政组织 |
|||
* @param id 待获取行政组织id |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Administration findAdministrationById(Long id) { |
|||
return administrativeMapper.findAdministrationById(id); |
|||
} |
|||
|
|||
/** |
|||
* 获取所有行政组织 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<Administration> findAdministrationsAll() { |
|||
return administrativeMapper.findAdministrationsAll(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取当前用户所处部门 |
|||
* |
|||
* @param userByPort 待获取用户 |
|||
* @return |
|||
*/ |
|||
public Administration getDepartmentByUser(UserByPort userByPort) { |
|||
Long maindeparment = userByPort.getMaindeparment(); |
|||
if (Long.compare(309, maindeparment) == 0) { |
|||
// 如果是顶级
|
|||
return getDepartmentForHXGK(userByPort.getAdminorg()); |
|||
} |
|||
return administrativeMapper.findAdministrationById(maindeparment); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 获取当前用户所处的部门id(高科)_ |
|||
* @param departmentId 待获取部门id |
|||
* @return |
|||
*/ |
|||
public Administration getDepartmentForHXGK(Long departmentId) { |
|||
List<Administration> administrationsAll = administrativeMapper.findAdministrationsAll(); |
|||
return getDepartmentForRecursion(departmentId, administrationsAll); |
|||
} |
|||
|
|||
/** |
|||
* 用于递归获取高科部门级行政组织 |
|||
* @param departmentId 当前行政组织id |
|||
* @param administrationList 行政组织列表 |
|||
* @return |
|||
*/ |
|||
public Administration getDepartmentForRecursion(Long departmentId,List<Administration> administrationList){ |
|||
for (Administration administration : administrationList) { |
|||
Long administrationId = administration.getId(); |
|||
if(Long.compare(administrationId,departmentId) == 0){ |
|||
Long superior = administration.getSuperior(); |
|||
if(Long.compare(superior,309) == 0){ |
|||
return administration; |
|||
}else{ |
|||
return getDepartmentForRecursion(superior,administrationList); |
|||
} |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue