feat(格口管理): 添加通过ID直接重置格口状态的功能
在管理端添加直接通过格口ID重置格口状态的功能,无需验证密码 将重置逻辑提取到独立方法中复用
This commit is contained in:
parent
b4b382d56d
commit
94b403898d
|
|
@ -105,4 +105,12 @@ public class CabinetCellController extends BaseController {
|
|||
cabinetCellApplicationService.clearGoodsCells(cellId);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "重置格口状态")
|
||||
@AccessLog(title = "格口管理", businessType = BusinessTypeEnum.MODIFY)
|
||||
@PutMapping("/reset/{cellId}")
|
||||
public ResponseDTO<Void> resetCellById(@PathVariable Long cellId) {
|
||||
cabinetCellApplicationService.resetCellById(cellId);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
}
|
||||
|
|
@ -231,16 +231,21 @@ public class CabinetCellApplicationService {
|
|||
throw new RuntimeException("密码错误或格口不存在");
|
||||
}
|
||||
|
||||
// 加载格口模型并重置状态
|
||||
UpdateWrapper<CabinetCellEntity> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.set("password", null)
|
||||
.set("usage_status", 1) // 空闲
|
||||
.eq("cell_id", cell.getCellId());
|
||||
cabinetCellService.update(updateWrapper);
|
||||
// 调用resetCellById方法重置格口
|
||||
cabinetCellService.resetCellById(cell.getCellId());
|
||||
|
||||
log.info("格口重置成功:cellId={}, cabinetId={}", cell.getCellId(), cell.getCabinetId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理端根据cellId直接重置格口状态
|
||||
* @param cellId 格口ID
|
||||
*/
|
||||
public void resetCellById(Long cellId) {
|
||||
cabinetCellService.resetCellById(cellId);
|
||||
log.info("管理端重置格口成功:cellId={}", cellId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public CabinetCellDTO storeItemToCell(StoreItemToCellCommand command) {
|
||||
// 根据shopId获取该店铺下的所有柜子ID列表
|
||||
|
|
|
|||
|
|
@ -42,4 +42,6 @@ public interface CabinetCellService extends IService<CabinetCellEntity> {
|
|||
List<CabinetCellLatestOrderDTO> selectLatestOrderInfoByCell(List<Long> cellIds);
|
||||
|
||||
List<CabinetCellEntity> selectRentedCellsByAb98UserIdAndCorpid(Long ab98UserId, String corpid);
|
||||
|
||||
void resetCellById(Long cellId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
|||
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.List;
|
||||
|
|
@ -91,4 +92,17 @@ public class CabinetCellServiceImpl extends ServiceImpl<CabinetCellMapper, Cabin
|
|||
.eq("au.ab98_user_id", ab98UserId);
|
||||
return baseMapper.selectRentedCellsByAb98UserIdAndCorpid(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCellById(Long cellId) {
|
||||
UpdateWrapper<CabinetCellEntity> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.set("password", null)
|
||||
.set("usage_status", 1) // 空闲
|
||||
.eq("cell_id", cellId)
|
||||
.eq("deleted", 0);
|
||||
boolean success = update(updateWrapper);
|
||||
if (!success) {
|
||||
throw new RuntimeException("格口不存在或已删除");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue