区域管理-启用or 禁用

This commit is contained in:
大米 2025-02-07 10:43:36 +08:00
parent a7487dcafa
commit 20b27b6e0c
8 changed files with 55 additions and 8 deletions

View File

@ -124,4 +124,25 @@ public class BaseAreaController extends ControllerBase {
}
@PostMapping("enable")
@MethodInfoMark(value = "启用" ,menuName = "区域管理")
public ApiResult<Boolean> enable(@RequestBody List<Long> ids){
VUtils.trueThrow(CollUtil.isEmpty(ids)).throwMessage(STATE.ParamErr,"请选择要启用的行");
baseAreaService.upState(1, ids, AdminUserUtil.getUserNo(), AdminUserUtil.getUserName());
return ApiResult.success(true);
}
@PostMapping("disable")
@MethodInfoMark(value = "禁用" ,menuName = "区域管理")
public ApiResult<Boolean> disable(@RequestBody List<Long> ids){
VUtils.trueThrow(CollUtil.isEmpty(ids)).throwMessage(STATE.ParamErr,"请选择要禁用的行");
baseAreaService.upState(0, ids, AdminUserUtil.getUserNo(), AdminUserUtil.getUserName());
return ApiResult.success(true);
}
}

View File

@ -33,8 +33,8 @@ public class AdminBaseAreaService {
Page<TBaseAreaVO> result = baseAreaService.getList(new Page<>(query.getPage(),query.getPageSize()), query);
List<TBaseAreaVO> dataResult = Convert.toList(TBaseAreaVO.class, result);
if(StrUtil.isNotBlank(query.getAreaCodeOrName())){
List<TBaseAreaVO> allAreaList = Convert.toList(TBaseAreaVO.class,baseAreaService.lambdaQuery().eq(TBaseArea::getAreaState,1).list()) ;
Map<Long, TBaseAreaVO> collect = allAreaList.stream().collect(Collectors.toMap(TBaseAreaVO::getRowId, Function.identity()));
List<TBaseAreaVO> allAreaList = Convert.toList(TBaseAreaVO.class,baseAreaService.lambdaQuery().eq(TBaseArea::getDelIs,0).list()) ;
Map<Long, TBaseAreaVO> collect = allAreaList.stream().collect(Collectors.toMap(TBaseAreaVO::getId, Function.identity()));
List<TBaseAreaVO> allParents=new ArrayList<>();
for (TBaseAreaVO data:dataResult){
allParents.addAll(getAllParents(data, collect)) ;
@ -51,7 +51,7 @@ public class AdminBaseAreaService {
}
private void initNodeChildren(TBaseAreaVO node) {
List<TBaseAreaVO> immediateChildren = findChildDepartmentsByParentId(node.getRowId());
List<TBaseAreaVO> immediateChildren = findChildDepartmentsByParentId(node.getId());
node.setChildren(immediateChildren);
for (TBaseAreaVO child : immediateChildren) {
initNodeChildren(child);
@ -59,7 +59,7 @@ public class AdminBaseAreaService {
}
private List<TBaseAreaVO> findChildDepartmentsByParentId(Long parentId) {
List<TBaseArea> areas = baseAreaService.lambdaQuery().eq(TBaseArea::getParentAreaRowId, parentId).eq(TBaseArea::getAreaState,1).list();
List<TBaseArea> areas = baseAreaService.lambdaQuery().eq(TBaseArea::getParentAreaRowId, parentId).eq(TBaseArea::getDelIs,0).list();
return Convert.toList(TBaseAreaVO.class,areas);
}
@ -85,7 +85,7 @@ public class AdminBaseAreaService {
private List<TBaseAreaVO> buildTree(List<TBaseAreaVO> nodes) {
// 使用Map存储id到Node的映射便于快速查找父节点
Map<Long, TBaseAreaVO> idToNodeMap = nodes.stream()
.collect(Collectors.toMap(TBaseAreaVO::getRowId, Function.identity()));
.collect(Collectors.toMap(TBaseAreaVO::getId, Function.identity()));
List<TBaseAreaVO> roots = new ArrayList<>();

View File

@ -26,7 +26,7 @@ public class TBaseAreaVO implements Serializable {
/**
* row_id
*/
private Long rowId;
private Long id;
/**
* 区域编码

View File

@ -80,4 +80,9 @@ public class TBaseArea implements Serializable {
* 最近修改时间
*/
private LocalDateTime dataModifyTime;
/**
* 是否删除0- 1-
*/
private Integer delIs;
}

View File

@ -23,5 +23,7 @@ public interface TBaseAreaMapper extends BaseMapper<TBaseArea> {
void delByIds(@Param("ids")List<Long> ids ,@Param("userNo")String userNo , @Param("userName")String userName);
void upState(@Param("areaState") Integer areaState , @Param("ids")List<Long> ids ,@Param("userNo")String userNo , @Param("userName")String userName);
Integer getCount();
}

View File

@ -24,6 +24,9 @@ public interface ITBaseAreaService extends IService<TBaseArea> {
void delByIds(@Param("ids") List<Long> ids, String userNo, String userName);
void upState(@Param("areaState") Integer areaState , @Param("ids")List<Long> ids ,@Param("userNo")String userNo , @Param("userName")String userName);
Integer getCount();
List<AreaSimpleVO> getSimpleAreas();

View File

@ -34,6 +34,11 @@ public class TBaseAreaServiceImpl extends ServiceImpl<TBaseAreaMapper, TBaseArea
this.getBaseMapper().delByIds(ids,userNo,userName);
}
public void upState(@Param("areaState") Integer areaState , @Param("ids")List<Long> ids ,@Param("userNo")String userNo , @Param("userName")String userName){
this.getBaseMapper().upState(areaState, ids, userNo,userName);
}
public Integer getCount(){
return this.getBaseMapper().getCount();
}

View File

@ -6,11 +6,14 @@
<if test="query.areaCodeOrName!=null and query.areaCodeOrName!=''">
and (area_code =#{query.areaCodeOrName} or area_name = #{query.areaCodeOrName} )
</if>
<if test="query.areaState!=null">
and area_state=#{query.areaState}
</if>
</sql>
<select id="getList" resultType="com.nflg.mobilebroken.common.pojo.vo.TBaseAreaVO">
select * from t_base_area where area_state=1
select * from t_base_area where del_is=0
<if test="query.areaCodeOrName==null or query.areaCodeOrName==''">
and parent_area_row_id=0
</if>
@ -19,13 +22,21 @@
</select>
<update id="delByIds">
update t_base_area set area_state=0 , data_modify_time=now(), data_modify_user_no=#{userNo},
update t_base_area set del_is=1 , data_modify_time=now(), data_modify_user_no=#{userNo},
data_modify_user_name=#{userName} where id in
<foreach collection="ids" item="=item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<update id="upState">
update t_base_area set area_state=#{areaState} , data_modify_time=now(), data_modify_user_no=#{userNo},
data_modify_user_name=#{userName} where id in
<foreach collection="ids" item="=item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<select id="getCount" resultType="java.lang.Integer">
select count(1) from t_base_area
</select>