Commit d5bd3e5c3289d3f13c4b94cd326e2cbc00d3e81c
Merge remote-tracking branch 'origin/develop' into develop
Showing
6 changed files
with
46 additions
and
6 deletions
src/main/java/com/huaheng/pc/config/warehouse/mapper/WarehouseMapper.java
@@ -3,6 +3,7 @@ package com.huaheng.pc.config.warehouse.mapper; | @@ -3,6 +3,7 @@ package com.huaheng.pc.config.warehouse.mapper; | ||
3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
4 | import com.huaheng.pc.config.warehouse.domain.Warehouse; | 4 | import com.huaheng.pc.config.warehouse.domain.Warehouse; |
5 | import com.huaheng.pc.system.user.domain.SysUserWarehouse; | 5 | import com.huaheng.pc.system.user.domain.SysUserWarehouse; |
6 | +import org.apache.ibatis.annotations.Param; | ||
6 | 7 | ||
7 | import java.util.List; | 8 | import java.util.List; |
8 | 9 | ||
@@ -13,4 +14,6 @@ public interface WarehouseMapper extends BaseMapper<Warehouse> { | @@ -13,4 +14,6 @@ public interface WarehouseMapper extends BaseMapper<Warehouse> { | ||
13 | public List<Warehouse> selectWarehouseByUserId(Integer userId); | 14 | public List<Warehouse> selectWarehouseByUserId(Integer userId); |
14 | 15 | ||
15 | public List<Warehouse> selectWarehouseAll(); | 16 | public List<Warehouse> selectWarehouseAll(); |
17 | + | ||
18 | + int companyCopy(@Param("warehouseCode") String warehouseCode, @Param("newWarehouseCode")String newWarehouseCode); | ||
16 | } | 19 | } |
17 | \ No newline at end of file | 20 | \ No newline at end of file |
src/main/java/com/huaheng/pc/config/warehouse/service/WarehouseServiceImpl.java
@@ -159,6 +159,10 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse | @@ -159,6 +159,10 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse | ||
159 | if (!shipmentTypeService.ShipmentTypeCopy(warehouseCode, newWarehouseCode)){ | 159 | if (!shipmentTypeService.ShipmentTypeCopy(warehouseCode, newWarehouseCode)){ |
160 | throw new ServiceException("复制出库类型表失败"); | 160 | throw new ServiceException("复制出库类型表失败"); |
161 | } | 161 | } |
162 | + /* 复制仓库货主关系*/ | ||
163 | + if (warehouseMapper.companyCopy(warehouseCode, newWarehouseCode) < 1){ | ||
164 | + throw new ServiceException("复制仓库货主关系表失败"); | ||
165 | + } | ||
162 | /* 复制角色*/ | 166 | /* 复制角色*/ |
163 | if (!roleService.roleCopy(warehouseCode, newWarehouseCode)){ | 167 | if (!roleService.roleCopy(warehouseCode, newWarehouseCode)){ |
164 | throw new ServiceException("复制角色表失败"); | 168 | throw new ServiceException("复制角色表失败"); |
src/main/java/com/huaheng/pc/system/role/mapper/RoleMapper.java
@@ -94,4 +94,7 @@ public interface RoleMapper | @@ -94,4 +94,7 @@ public interface RoleMapper | ||
94 | 94 | ||
95 | public int roleCopy(@Param("code")String code, @Param("newCode")String newCode); | 95 | public int roleCopy(@Param("code")String code, @Param("newCode")String newCode); |
96 | 96 | ||
97 | + | ||
98 | + public int roleUserCopy(@Param("code")String code); | ||
99 | + | ||
97 | } | 100 | } |
src/main/java/com/huaheng/pc/system/role/service/RoleServiceImpl.java
@@ -5,6 +5,8 @@ import java.util.Arrays; | @@ -5,6 +5,8 @@ import java.util.Arrays; | ||
5 | import java.util.HashSet; | 5 | import java.util.HashSet; |
6 | import java.util.List; | 6 | import java.util.List; |
7 | import java.util.Set; | 7 | import java.util.Set; |
8 | + | ||
9 | +import com.huaheng.common.exception.service.ServiceException; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
10 | import com.huaheng.common.constant.UserConstants; | 12 | import com.huaheng.common.constant.UserConstants; |
@@ -17,6 +19,8 @@ import com.huaheng.pc.system.role.mapper.RoleMapper; | @@ -17,6 +19,8 @@ import com.huaheng.pc.system.role.mapper.RoleMapper; | ||
17 | import com.huaheng.pc.system.role.mapper.RoleMenuMapper; | 19 | import com.huaheng.pc.system.role.mapper.RoleMenuMapper; |
18 | import com.huaheng.pc.system.user.mapper.UserRoleMapper; | 20 | import com.huaheng.pc.system.user.mapper.UserRoleMapper; |
19 | 21 | ||
22 | +import javax.annotation.Resource; | ||
23 | + | ||
20 | /** | 24 | /** |
21 | * 角色 业务层处理 | 25 | * 角色 业务层处理 |
22 | * | 26 | * |
@@ -26,13 +30,13 @@ import com.huaheng.pc.system.user.mapper.UserRoleMapper; | @@ -26,13 +30,13 @@ import com.huaheng.pc.system.user.mapper.UserRoleMapper; | ||
26 | public class RoleServiceImpl implements IRoleService | 30 | public class RoleServiceImpl implements IRoleService |
27 | { | 31 | { |
28 | 32 | ||
29 | - @Autowired | 33 | + @Resource |
30 | private RoleMapper roleMapper; | 34 | private RoleMapper roleMapper; |
31 | 35 | ||
32 | @Autowired | 36 | @Autowired |
33 | private RoleMenuMapper roleMenuMapper; | 37 | private RoleMenuMapper roleMenuMapper; |
34 | 38 | ||
35 | - @Autowired | 39 | + @Resource |
36 | private UserRoleMapper userRoleMapper; | 40 | private UserRoleMapper userRoleMapper; |
37 | 41 | ||
38 | /** | 42 | /** |
@@ -263,11 +267,19 @@ public class RoleServiceImpl implements IRoleService | @@ -263,11 +267,19 @@ public class RoleServiceImpl implements IRoleService | ||
263 | //复制角色 | 267 | //复制角色 |
264 | @Override | 268 | @Override |
265 | public Boolean roleCopy(String code, String newCode) { | 269 | public Boolean roleCopy(String code, String newCode) { |
266 | - int i = roleMapper.roleCopy(code,newCode); | ||
267 | - if(i > 0){ | ||
268 | - return true; | 270 | + int i = 0; |
271 | + i = roleMapper.roleCopy(code,newCode); | ||
272 | + if(i < 1){ | ||
273 | + throw new ServiceException("复制角色表失败"); | ||
274 | + } | ||
275 | + if(i < 1){ | ||
276 | + throw new ServiceException("复制角色菜单关系表失败"); | ||
277 | + } | ||
278 | + i = roleMapper.roleUserCopy(newCode); | ||
279 | + if(i < 1){ | ||
280 | + throw new ServiceException("复制用户角色关系表失败"); | ||
269 | } | 281 | } |
270 | - return false; | 282 | + return true; |
271 | } | 283 | } |
272 | 284 | ||
273 | } | 285 | } |
src/main/resources/mybatis/config/WarehouseMapper.xml
@@ -61,4 +61,9 @@ | @@ -61,4 +61,9 @@ | ||
61 | lastUpdated, lastUpdatedBy, version, userDef1, userDef2, userDef3, userDef4, userDef5, | 61 | lastUpdated, lastUpdatedBy, version, userDef1, userDef2, userDef3, userDef4, userDef5, |
62 | userDef6, userDef7, userDef8, delete | 62 | userDef6, userDef7, userDef8, delete |
63 | </sql> | 63 | </sql> |
64 | + | ||
65 | + <insert id="companyCopy"> | ||
66 | + insert into warehouse_company(warehouseCode,companyId,companyCode) | ||
67 | + select #{newWarehouseCode},companyId,companyCode from warehouse_company where warehouseCode=#{warehouseCode} | ||
68 | + </insert> | ||
64 | </mapper> | 69 | </mapper> |
65 | \ No newline at end of file | 70 | \ No newline at end of file |
src/main/resources/mybatis/system/RoleMapper.xml
@@ -129,5 +129,18 @@ | @@ -129,5 +129,18 @@ | ||
129 | insert into sys_role(roleName,roleCode,roleSort,warehouseCode,enable,remark) | 129 | insert into sys_role(roleName,roleCode,roleSort,warehouseCode,enable,remark) |
130 | select roleName,roleCode,roleSort,#{newCode},enable,remark from sys_role where warehouseCode=#{code} | 130 | select roleName,roleCode,roleSort,#{newCode},enable,remark from sys_role where warehouseCode=#{code} |
131 | </insert> | 131 | </insert> |
132 | + | ||
133 | + | ||
134 | + <update id="updateRoleMenu"> | ||
135 | + update sys_role_menu r inner join sys_menu m | ||
136 | + on r.roleId = (select id from sys_role where warehouseCode = #{code} limit 1) | ||
137 | + set r. | ||
138 | + </update> | ||
139 | + | ||
140 | + <insert id="roleUserCopy"> | ||
141 | + insert into sys_user_role(userId,roleId) | ||
142 | + values(1,(select id from sys_role where warehouseCode = #{code} limit 1)) | ||
143 | + | ||
144 | + </insert> | ||
132 | 145 | ||
133 | </mapper> | 146 | </mapper> |
134 | \ No newline at end of file | 147 | \ No newline at end of file |