master
chen 4 years ago
parent 3419d84fd3
commit f7154b8312
  1. 47
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/CopySendController.java
  2. 18
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java
  3. 49
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/ImgUtil.java
  4. 32
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/RoleController.java
  5. 8
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java
  6. 20
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/EmployeeVO.java
  7. 19
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/UserRoleVO.java
  8. 10
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/RoleService.java
  9. 24
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java
  10. 17
      dq-financial-hrms/src/main/resources/mapper/hrms/RoleDao.xml

@ -0,0 +1,47 @@
package com.daqing.financial.guarantee.controller;
import cn.hutool.core.util.IdUtil;
import com.daqing.financial.guarantee.util.ImgUtil;
import com.daqing.financial.guarantee.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
/**
* @Author chen
* @DATE 2021/1/15 9:43
* @Version 1.0
* 抄送控制器
*/
@Api(tags = {"抄送API"})
@RestController
@RequestMapping("/copy-send")
public class CopySendController {
@ApiOperation("base转换图片")
@GetMapping("/conversionImg")
public R conversionImg(String imgData){
//获取随机值
String snowflakeId = IdUtil.getSnowflake(6, 4).nextIdStr();
//文件扩展名
String ext = ".png";
//新文件名:雪花算法.文件扩展名
String newName = snowflakeId + ext;
//指定存放目录
String directory = "D:/img/";
//图片完整路径
String imgPath = directory+newName;
try {
ImgUtil.generateImage(imgData,imgPath);
} catch (IOException e) {
e.printStackTrace();
}
return R.ok();
}
}

@ -337,9 +337,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }
@ -363,9 +365,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }
@ -389,9 +393,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }
@ -416,9 +422,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }
@ -441,9 +449,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }
@ -466,9 +476,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }
@ -492,9 +504,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }
@ -518,9 +532,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }
@ -544,9 +560,11 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
statusPO.setStatus(status); statusPO.setStatus(status);
//相同业务中,如果已经是待处理则数据不覆盖 //相同业务中,如果已经是待处理则数据不覆盖
StatusPO po = (StatusPO) hashMap.get(businessId); StatusPO po = (StatusPO) hashMap.get(businessId);
if (po!=null){
if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { if (!po.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) {
hashMap.put(businessId, statusPO); hashMap.put(businessId, statusPO);
} }
}
}); });
} }
} }

@ -0,0 +1,49 @@
package com.daqing.financial.guarantee.util;
import sun.misc.BASE64Decoder;
import java.io.*;
/**
* @Author chen
* @DATE 2021/1/15 9:45
* @Version 1.0
*/
public class ImgUtil {
/**
* base64字符串转化成图片
* @param imgData 图片编码
* @param imgFilePath 存放到本地路径
*/
public static boolean generateImage(String imgData, String imgFilePath) throws IOException { // 对字节数组字符串进行Base64解码并生成图片
// 图像数据为空
if (imgData == null) {
return false;
}
BASE64Decoder decoder = new BASE64Decoder();
OutputStream out = null;
try {
out = new FileOutputStream(imgFilePath);
// Base64解码
byte[] b = decoder.decodeBuffer(imgData);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {// 调整异常数据
b[i] += 256;
}
}
out.write(b);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
out.flush();
}
if (out != null) {
out.close();
}
}
return true;
}
}

@ -1,9 +1,14 @@
package com.daqing.financial.hrms.controller; package com.daqing.financial.hrms.controller;
import com.baomidou.mybatisplus.extension.api.R;
import com.daqing.financial.hrms.entity.vo.EmployeeVO;
import com.daqing.financial.hrms.entity.vo.UserRoleVO;
import com.daqing.financial.hrms.service.RoleService; import com.daqing.financial.hrms.service.RoleService;
import com.daqing.framework.domain.hrms.RoleEntity; import com.daqing.framework.domain.hrms.RoleEntity;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -88,4 +93,31 @@ public class RoleController {
return ResponseResult.SUCCESS(); return ResponseResult.SUCCESS();
} }
@ApiOperation(value = "根据角色查询员工")
@GetMapping("getEmployeesByRoleId")
public ResponseResult getEmployeesByRoleId(
@ApiParam(name = "roleId", value = "角色id", required = true)
@RequestParam("roleId") String roleId){
List<EmployeeVO> employees = roleService.getEmployeesByRoleId(roleId);
return ResponseResult.SUCCESS(employees);
}
@ApiOperation(value = "保存用户角色")
@PostMapping("saveUserRole")
public ResponseResult saveUserRole(@RequestBody UserRoleVO userRoleVO){
boolean save = roleService.saveUserRole(userRoleVO);
return ResponseResult.SUCCESS(save);
}
@ApiOperation(value = "删除用户角色")
@PostMapping("removeUserRole")
public ResponseResult removeUserRole(
@ApiParam(name = "roleId", value = "角色id", required = true)
@RequestParam("roleId") String roleId,
@ApiParam(name = "userId", value = "用户id", required = true)
@RequestParam("userId") String userId){
boolean remove = roleService.removeUserRole(roleId,userId);
return ResponseResult.SUCCESS(remove);
}
} }

@ -1,9 +1,11 @@
package com.daqing.financial.hrms.dao; package com.daqing.financial.hrms.dao;
import com.daqing.financial.hrms.entity.vo.EmployeeVO;
import com.daqing.framework.domain.hrms.RoleEntity; import com.daqing.framework.domain.hrms.RoleEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daqing.framework.domain.hrms.ext.RoleVO; import com.daqing.framework.domain.hrms.ext.RoleVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -18,4 +20,10 @@ import java.util.List;
public interface RoleDao extends BaseMapper<RoleEntity> { public interface RoleDao extends BaseMapper<RoleEntity> {
List<RoleVO> listRoleIdAndName(); List<RoleVO> listRoleIdAndName();
List<EmployeeVO> selectEmployeesByRoleId(String roleId);
void saveUserRole(@Param("roleId") String roleId,@Param("userId") String userId);
int removeUserRole(@Param("roleId") String roleId,@Param("userId") String userId);
} }

@ -0,0 +1,20 @@
package com.daqing.financial.hrms.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author chen
* @DATE 2021/1/14 15:50
* @Version 1.0
*/
@Data
public class EmployeeVO {
@ApiModelProperty("员工名称")
private String name;
@ApiModelProperty("用户id")
private String userId;
}

@ -0,0 +1,19 @@
package com.daqing.financial.hrms.entity.vo;
import lombok.Data;
import java.util.List;
/**
* @Author chen
* @DATE 2021/1/14 16:31
* @Version 1.0
*/
@Data
public class UserRoleVO {
private String roleId;
private List<String> userIds;
}

@ -1,9 +1,12 @@
package com.daqing.financial.hrms.service; package com.daqing.financial.hrms.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.financial.hrms.entity.vo.EmployeeVO;
import com.daqing.financial.hrms.entity.vo.UserRoleVO;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.domain.hrms.RoleEntity; import com.daqing.framework.domain.hrms.RoleEntity;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -16,5 +19,12 @@ import java.util.Map;
public interface RoleService extends IService<RoleEntity> { public interface RoleService extends IService<RoleEntity> {
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params);
List<EmployeeVO> getEmployeesByRoleId(String roleId);
boolean saveUserRole(UserRoleVO userRoleVO);
boolean removeUserRole(String roleId, String userId);
} }

@ -1,6 +1,10 @@
package com.daqing.financial.hrms.service.impl; package com.daqing.financial.hrms.service.impl;
import com.daqing.financial.hrms.entity.vo.EmployeeVO;
import com.daqing.financial.hrms.entity.vo.UserRoleVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -26,4 +30,24 @@ public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements
return new PageUtils(page); return new PageUtils(page);
} }
@Override
public List<EmployeeVO> getEmployeesByRoleId(String roleId) {
return baseMapper.selectEmployeesByRoleId(roleId);
}
@Override
public boolean saveUserRole(UserRoleVO userRoleVO) {
String roleId = userRoleVO.getRoleId();
List<String> userIds = userRoleVO.getUserIds();
userIds.forEach(userId -> {
baseMapper.saveUserRole(roleId,userId);
});
return true;
}
@Override
public boolean removeUserRole(String roleId, String userId) {
int remove = baseMapper.removeUserRole(roleId,userId);
return remove>0;
}
} }

@ -12,8 +12,25 @@
<result property="motifyTime" column="motify_time"/> <result property="motifyTime" column="motify_time"/>
</resultMap> </resultMap>
<insert id="saveUserRole">
insert into hrms_employee_role (user_id,role_id) values (#{userId},#{roleId})
</insert>
<delete id="removeUserRole">
DELETE FROM hrms_employee_role WHERE user_id = #{userId} and role_id = #{roleId}
</delete>
<select id="listRoleIdAndName" resultType="com.daqing.framework.domain.hrms.ext.RoleVO"> <select id="listRoleIdAndName" resultType="com.daqing.framework.domain.hrms.ext.RoleVO">
SELECT id,name FROM hrms_role WHERE del_or_not = 0 SELECT id,name FROM hrms_role WHERE del_or_not = 0
</select> </select>
<select id="selectEmployeesByRoleId" resultType="com.daqing.financial.hrms.entity.vo.EmployeeVO">
SELECT he.name,he.user_id
FROM
hrms_employee_role her
LEFT JOIN hrms_employee he ON her.user_id = he.user_id
WHERE
role_id = #{roleId}
</select>
</mapper> </mapper>
Loading…
Cancel
Save