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 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
4 | 4 | import com.huaheng.pc.config.warehouse.domain.Warehouse; |
5 | 5 | import com.huaheng.pc.system.user.domain.SysUserWarehouse; |
6 | +import org.apache.ibatis.annotations.Param; | |
6 | 7 | |
7 | 8 | import java.util.List; |
8 | 9 | |
... | ... | @@ -13,4 +14,6 @@ public interface WarehouseMapper extends BaseMapper<Warehouse> { |
13 | 14 | public List<Warehouse> selectWarehouseByUserId(Integer userId); |
14 | 15 | |
15 | 16 | public List<Warehouse> selectWarehouseAll(); |
17 | + | |
18 | + int companyCopy(@Param("warehouseCode") String warehouseCode, @Param("newWarehouseCode")String newWarehouseCode); | |
16 | 19 | } |
17 | 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 | 159 | if (!shipmentTypeService.ShipmentTypeCopy(warehouseCode, newWarehouseCode)){ |
160 | 160 | throw new ServiceException("复制出库类型表失败"); |
161 | 161 | } |
162 | + /* 复制仓库货主关系*/ | |
163 | + if (warehouseMapper.companyCopy(warehouseCode, newWarehouseCode) < 1){ | |
164 | + throw new ServiceException("复制仓库货主关系表失败"); | |
165 | + } | |
162 | 166 | /* 复制角色*/ |
163 | 167 | if (!roleService.roleCopy(warehouseCode, newWarehouseCode)){ |
164 | 168 | throw new ServiceException("复制角色表失败"); |
... | ... |
src/main/java/com/huaheng/pc/system/role/mapper/RoleMapper.java
src/main/java/com/huaheng/pc/system/role/service/RoleServiceImpl.java
... | ... | @@ -5,6 +5,8 @@ import java.util.Arrays; |
5 | 5 | import java.util.HashSet; |
6 | 6 | import java.util.List; |
7 | 7 | import java.util.Set; |
8 | + | |
9 | +import com.huaheng.common.exception.service.ServiceException; | |
8 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
9 | 11 | import org.springframework.stereotype.Service; |
10 | 12 | import com.huaheng.common.constant.UserConstants; |
... | ... | @@ -17,6 +19,8 @@ import com.huaheng.pc.system.role.mapper.RoleMapper; |
17 | 19 | import com.huaheng.pc.system.role.mapper.RoleMenuMapper; |
18 | 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 | 30 | public class RoleServiceImpl implements IRoleService |
27 | 31 | { |
28 | 32 | |
29 | - @Autowired | |
33 | + @Resource | |
30 | 34 | private RoleMapper roleMapper; |
31 | 35 | |
32 | 36 | @Autowired |
33 | 37 | private RoleMenuMapper roleMenuMapper; |
34 | 38 | |
35 | - @Autowired | |
39 | + @Resource | |
36 | 40 | private UserRoleMapper userRoleMapper; |
37 | 41 | |
38 | 42 | /** |
... | ... | @@ -263,11 +267,19 @@ public class RoleServiceImpl implements IRoleService |
263 | 267 | //复制角色 |
264 | 268 | @Override |
265 | 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 | 61 | lastUpdated, lastUpdatedBy, version, userDef1, userDef2, userDef3, userDef4, userDef5, |
62 | 62 | userDef6, userDef7, userDef8, delete |
63 | 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 | 69 | </mapper> |
65 | 70 | \ No newline at end of file |
... | ... |
src/main/resources/mybatis/system/RoleMapper.xml
... | ... | @@ -129,5 +129,18 @@ |
129 | 129 | insert into sys_role(roleName,roleCode,roleSort,warehouseCode,enable,remark) |
130 | 130 | select roleName,roleCode,roleSort,#{newCode},enable,remark from sys_role where warehouseCode=#{code} |
131 | 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 | 146 | </mapper> |
134 | 147 | \ No newline at end of file |
... | ... |