From f7154b831209f0dd22637006689a30aa8dab747b Mon Sep 17 00:00:00 2001 From: chen <1251790704@qq.com> Date: Fri, 15 Jan 2021 14:08:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=84=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CopySendController.java | 47 ++++++++++++++++ .../service/impl/DgEfficiencyServiceImpl.java | 54 ++++++++++++------- .../financial/guarantee/util/ImgUtil.java | 49 +++++++++++++++++ .../hrms/controller/RoleController.java | 32 +++++++++++ .../daqing/financial/hrms/dao/RoleDao.java | 8 +++ .../financial/hrms/entity/vo/EmployeeVO.java | 20 +++++++ .../financial/hrms/entity/vo/UserRoleVO.java | 19 +++++++ .../financial/hrms/service/RoleService.java | 10 ++++ .../hrms/service/impl/RoleServiceImpl.java | 24 +++++++++ .../main/resources/mapper/hrms/RoleDao.xml | 17 ++++++ 10 files changed, 262 insertions(+), 18 deletions(-) create mode 100644 dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/CopySendController.java create mode 100644 dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/ImgUtil.java create mode 100644 dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/EmployeeVO.java create mode 100644 dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/UserRoleVO.java diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/CopySendController.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/CopySendController.java new file mode 100644 index 00000000..0a6ee6a1 --- /dev/null +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/CopySendController.java @@ -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(); + } + +} diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java index 855cbc9c..6faa1e59 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java @@ -337,8 +337,10 @@ public class DgEfficiencyServiceImpl extends ServiceImpl 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); + } + } diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java index c823bd0b..9a07633c 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java @@ -1,9 +1,11 @@ package com.daqing.financial.hrms.dao; +import com.daqing.financial.hrms.entity.vo.EmployeeVO; import com.daqing.framework.domain.hrms.RoleEntity; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.daqing.framework.domain.hrms.ext.RoleVO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -18,4 +20,10 @@ import java.util.List; public interface RoleDao extends BaseMapper { List listRoleIdAndName(); + + List selectEmployeesByRoleId(String roleId); + + void saveUserRole(@Param("roleId") String roleId,@Param("userId") String userId); + + int removeUserRole(@Param("roleId") String roleId,@Param("userId") String userId); } diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/EmployeeVO.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/EmployeeVO.java new file mode 100644 index 00000000..7b1ef890 --- /dev/null +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/EmployeeVO.java @@ -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; + +} diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/UserRoleVO.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/UserRoleVO.java new file mode 100644 index 00000000..d807a616 --- /dev/null +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/entity/vo/UserRoleVO.java @@ -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 userIds; + +} diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/RoleService.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/RoleService.java index cb85ead6..c84a826f 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/RoleService.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/RoleService.java @@ -1,9 +1,12 @@ package com.daqing.financial.hrms.service; 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.domain.hrms.RoleEntity; +import java.util.List; import java.util.Map; /** @@ -16,5 +19,12 @@ import java.util.Map; public interface RoleService extends IService { PageUtils queryPage(Map params); + + List getEmployeesByRoleId(String roleId); + + boolean saveUserRole(UserRoleVO userRoleVO); + + boolean removeUserRole(String roleId, String userId); + } diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java index 9b69d6de..90160e42 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java @@ -1,6 +1,10 @@ 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 java.util.List; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -26,4 +30,24 @@ public class RoleServiceImpl extends ServiceImpl implements return new PageUtils(page); } + @Override + public List getEmployeesByRoleId(String roleId) { + return baseMapper.selectEmployeesByRoleId(roleId); + } + + @Override + public boolean saveUserRole(UserRoleVO userRoleVO) { + String roleId = userRoleVO.getRoleId(); + List 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; + } } \ No newline at end of file diff --git a/dq-financial-hrms/src/main/resources/mapper/hrms/RoleDao.xml b/dq-financial-hrms/src/main/resources/mapper/hrms/RoleDao.xml index e8d187e9..81dbebb4 100644 --- a/dq-financial-hrms/src/main/resources/mapper/hrms/RoleDao.xml +++ b/dq-financial-hrms/src/main/resources/mapper/hrms/RoleDao.xml @@ -12,8 +12,25 @@ + + insert into hrms_employee_role (user_id,role_id) values (#{userId},#{roleId}) + + + + DELETE FROM hrms_employee_role WHERE user_id = #{userId} and role_id = #{roleId} + + + + \ No newline at end of file