Skip to content

Commit e599d34

Browse files
committed
fix: Fix block update bug
1 parent 9ef51fb commit e599d34

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

base/src/main/java/com/tinyengine/it/mapper/BlockGroupBlockMapper.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,16 @@ public interface BlockGroupBlockMapper extends BaseMapper<BlockGroupBlock> {
9494
* 通过区块分组id和区块删除区块与分组关联关系
9595
* @param blockId the block id
9696
* @param groupId the block group id
97-
* @return the list
97+
* @return the Integer
9898
*/
9999
@Delete("delete from r_block_group_block where block_group_id = #{groupId} and block_id = #{blockId}")
100100
Integer deleteByGroupIdAndBlockId(Integer groupId, Integer blockId);
101+
102+
/**
103+
* 通过区块id删除区块与分组关联关系
104+
* @param blockId the block id
105+
* @return the Integer
106+
*/
107+
@Delete("delete from r_block_group_block where block_id = #{blockId}")
108+
Integer deleteByBlockId(Integer blockId);
101109
}

base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ public List<Block> queryBlockByCondition(Block block) {
153153
*/
154154
@Override
155155
public Integer deleteBlockById(Integer id) {
156-
return baseMapper.deleteBlockById(id);
156+
baseMapper.deleteBlockById(id);
157+
return blockGroupBlockMapper.deleteByBlockId(id);
157158
}
158159

159160
/**
@@ -171,7 +172,7 @@ public Result<BlockDto> updateBlockById(BlockParam blockParam) {
171172
if (blockResult == null) {
172173
return Result.failed(ExceptionEnum.CM001);
173174
}
174-
if (!Objects.equals(blockResult.getAppId(), blockParam.getAppId())) {
175+
if (!Objects.equals(blockResult.getOccupierBy(), loginUserContext.getLoginUserId())) {
175176
return Result.failed(ExceptionEnum.CM007);
176177
}
177178
// 把前端传参赋值给实体

base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.tinyengine.it.common.base.Result;
2828
import com.tinyengine.it.common.context.LoginUserContext;
2929
import com.tinyengine.it.mapper.AppMapper;
30+
import com.tinyengine.it.mapper.BlockGroupBlockMapper;
3031
import com.tinyengine.it.mapper.BlockGroupMapper;
3132
import com.tinyengine.it.mapper.BlockMapper;
3233
import com.tinyengine.it.mapper.UserMapper;
@@ -69,6 +70,9 @@ class BlockServiceImplTest {
6970
@Mock
7071
private LoginUserContext loginUserContext;
7172

73+
@Mock
74+
private BlockGroupBlockMapper blockGroupBlockMapper;
75+
7276
@InjectMocks
7377
private BlockServiceImpl blockServiceImpl;
7478

@@ -110,6 +114,7 @@ void testQueryBlockByCondition() {
110114
@Test
111115
void testDeleteBlockById() {
112116
when(blockMapper.deleteBlockById(123)).thenReturn(1);
117+
when(blockGroupBlockMapper.deleteByBlockId(123)).thenReturn(1);
113118

114119
Integer result = blockServiceImpl.deleteBlockById(123);
115120
Assertions.assertEquals(1, result);

0 commit comments

Comments
 (0)