部件入库、入库记录,加密关闭
This commit is contained in:
parent
fed8f1ed54
commit
4bbffd7ca7
@ -152,9 +152,7 @@ public class CustomCipherTextFilter implements GlobalFilter, Ordered {
|
||||
return originalResponseBody;
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ResponseDto responseDto = null;
|
||||
|
||||
responseDto = objectMapper.readValue(originalResponseBody, ResponseDto.class);
|
||||
ResponseDto responseDto = objectMapper.readValue(originalResponseBody, ResponseDto.class);
|
||||
|
||||
// 只对data字段进行加密处理
|
||||
Object data = responseDto.getData();
|
||||
|
||||
@ -87,7 +87,7 @@ cdzy:
|
||||
gateway:
|
||||
secure:
|
||||
request-switch:
|
||||
enable: true
|
||||
enable: false
|
||||
response-switch:
|
||||
enable: false
|
||||
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
package com.cdzy.operations.controller;
|
||||
|
||||
import com.cdzy.common.model.response.JsonResult;
|
||||
import com.cdzy.operations.model.vo.EbikeInventoryVo;
|
||||
import com.cdzy.operations.service.EbikeInventoryService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 库存表 控制层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ebikeInventory")
|
||||
public class EbikeInventoryController {
|
||||
|
||||
@Resource
|
||||
private EbikeInventoryService ebikeInventoryService;
|
||||
|
||||
/**
|
||||
* 添加库存。
|
||||
*
|
||||
* @param ebikeInventory 库存表
|
||||
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||
*/
|
||||
@PostMapping("addInventory")
|
||||
public JsonResult<?> addInventory(@RequestBody EbikeInventoryVo ebikeInventory) {
|
||||
ebikeInventoryService.addInventory(ebikeInventory);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 减少库存。
|
||||
*
|
||||
* @param ebikeInventory 库存表
|
||||
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||
*/
|
||||
@PostMapping("reduceInventory")
|
||||
public JsonResult<?> reduceInventory(@RequestBody EbikeInventoryVo ebikeInventory) {
|
||||
ebikeInventoryService.reduceInventory(ebikeInventory);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.cdzy.operations.controller;
|
||||
|
||||
import com.cdzy.common.model.request.PageParam;
|
||||
import com.cdzy.common.model.response.JsonResult;
|
||||
import com.cdzy.operations.model.entity.EbikeInventoryRecord;
|
||||
import com.cdzy.operations.service.EbikeInventoryRecordService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 库存记录表 控制层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ebikeInventoryRecord")
|
||||
public class EbikeInventoryRecordController {
|
||||
|
||||
@Resource
|
||||
private EbikeInventoryRecordService ebikeInventoryRecordService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询库存记录表。
|
||||
*
|
||||
* @param pageParam 分页对象
|
||||
* @param inventoryType 分页对象
|
||||
* @return 分页对象
|
||||
*/
|
||||
@GetMapping("page")
|
||||
public JsonResult<?> page(PageParam pageParam, Integer inventoryType) {
|
||||
Page<EbikeInventoryRecord> page = ebikeInventoryRecordService.page(pageParam, inventoryType);
|
||||
return JsonResult.success(page);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cdzy.operations.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.cdzy.operations.model.entity.EbikeInventory;
|
||||
|
||||
/**
|
||||
* 库存表 映射层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
public interface EbikeInventoryMapper extends BaseMapper<EbikeInventory> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cdzy.operations.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.cdzy.operations.model.entity.EbikeInventoryRecord;
|
||||
|
||||
/**
|
||||
* 库存记录表 映射层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
public interface EbikeInventoryRecordMapper extends BaseMapper<EbikeInventoryRecord> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.cdzy.operations.model.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 库存表 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("ebike_inventory")
|
||||
public class EbikeInventory implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 库存ID
|
||||
*/
|
||||
@Id
|
||||
private Long inventoryId;
|
||||
|
||||
/**
|
||||
* 运营商ID
|
||||
*/
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 库存类型
|
||||
*/
|
||||
private Integer inventoryType;
|
||||
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
private Long inventoryNum;
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.cdzy.operations.model.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 库存记录表 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("ebike_inventory_record")
|
||||
public class EbikeInventoryRecord implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 库存记录ID
|
||||
*/
|
||||
@Id
|
||||
private Long inventoryRecordId;
|
||||
|
||||
/**
|
||||
* 运营商ID
|
||||
*/
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 库存类型
|
||||
*/
|
||||
private Integer inventoryType;
|
||||
|
||||
/**
|
||||
* 库存记录数(减少/增加的数量
|
||||
*/
|
||||
private Long inventoryRecordNum;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private Timestamp createdTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.cdzy.operations.model.vo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 库存表 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EbikeInventoryVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 库存类型
|
||||
*/
|
||||
@NotNull(message = "库存部件类型不能为空")
|
||||
private Integer inventoryType;
|
||||
|
||||
/**
|
||||
* 添加库存数量
|
||||
*/
|
||||
@NotNull(message = "库存数量不能为空")
|
||||
private Long inventoryNum;
|
||||
|
||||
/**
|
||||
* 运营商ID
|
||||
*/
|
||||
private Long operatorId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.cdzy.operations.service;
|
||||
|
||||
import com.cdzy.common.model.request.PageParam;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.operations.model.entity.EbikeInventoryRecord;
|
||||
|
||||
/**
|
||||
* 库存记录表 服务层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
public interface EbikeInventoryRecordService extends IService<EbikeInventoryRecord> {
|
||||
|
||||
/**
|
||||
* 分页查询入库记录
|
||||
* @param pageParam 分页参数
|
||||
* @param inventoryType 类型
|
||||
* @return 结果
|
||||
*/
|
||||
Page<EbikeInventoryRecord> page(PageParam pageParam, Integer inventoryType);
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.cdzy.operations.service;
|
||||
|
||||
import com.cdzy.operations.model.vo.EbikeInventoryVo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.operations.model.entity.EbikeInventory;
|
||||
|
||||
/**
|
||||
* 库存表 服务层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
public interface EbikeInventoryService extends IService<EbikeInventory> {
|
||||
|
||||
/**
|
||||
* 添加库存
|
||||
* @param ebikeInventory 库存信息
|
||||
*/
|
||||
void addInventory(EbikeInventoryVo ebikeInventory);
|
||||
|
||||
/**
|
||||
* 减少库存
|
||||
* @param ebikeInventory 库存信息
|
||||
*/
|
||||
void reduceInventory(EbikeInventoryVo ebikeInventory);
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.cdzy.operations.service.impl;
|
||||
|
||||
import com.cdzy.common.model.request.PageParam;
|
||||
import com.cdzy.operations.mapper.EbikeInventoryRecordMapper;
|
||||
import com.cdzy.operations.model.entity.EbikeInventoryRecord;
|
||||
import com.cdzy.operations.service.EbikeInventoryRecordService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeInventoryRecordTableDef.EBIKE_INVENTORY_RECORD;
|
||||
|
||||
/**
|
||||
* 库存记录表 服务层实现。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
@Service
|
||||
public class EbikeInventoryRecordServiceImpl extends ServiceImpl<EbikeInventoryRecordMapper, EbikeInventoryRecord> implements EbikeInventoryRecordService{
|
||||
|
||||
@Override
|
||||
public Page<EbikeInventoryRecord> page(PageParam pageParam, Integer inventoryType) {
|
||||
QueryWrapper queryWrapper = QueryWrapper
|
||||
.create()
|
||||
.where(EBIKE_INVENTORY_RECORD.INVENTORY_TYPE.eq(inventoryType, Objects.nonNull(inventoryType)));
|
||||
return this.mapper.paginate(pageParam.getPage(), queryWrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package com.cdzy.operations.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.operations.mapper.EbikeInventoryMapper;
|
||||
import com.cdzy.operations.mapper.EbikeInventoryRecordMapper;
|
||||
import com.cdzy.operations.model.entity.EbikeInventory;
|
||||
import com.cdzy.operations.model.entity.EbikeInventoryRecord;
|
||||
import com.cdzy.operations.model.vo.EbikeInventoryVo;
|
||||
import com.cdzy.operations.service.EbikeInventoryService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeInventoryTableDef.EBIKE_INVENTORY;
|
||||
|
||||
/**
|
||||
* 库存表 服务层实现。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-13
|
||||
*/
|
||||
@Service
|
||||
public class EbikeInventoryServiceImpl extends ServiceImpl<EbikeInventoryMapper, EbikeInventory> implements EbikeInventoryService {
|
||||
|
||||
@Resource
|
||||
EbikeInventoryRecordMapper recordMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void addInventory(EbikeInventoryVo ebikeInventory) {
|
||||
if (ebikeInventory.getInventoryNum() <= 0){
|
||||
throw new EbikeException("添加库存时填入数量不能小于/等于0");
|
||||
}
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_INVENTORY.INVENTORY_TYPE.eq(ebikeInventory.getInventoryType()));
|
||||
EbikeInventory inventory = this.mapper.selectOneByQuery(queryWrapper);
|
||||
if (inventory != null) {
|
||||
long num = inventory.getInventoryNum() + ebikeInventory.getInventoryNum();
|
||||
inventory.setInventoryNum(num);
|
||||
this.mapper.update(inventory);
|
||||
}else {
|
||||
inventory = new EbikeInventory();
|
||||
inventory.setOperatorId(ebikeInventory.getOperatorId());
|
||||
inventory.setInventoryType(ebikeInventory.getInventoryType());
|
||||
inventory.setInventoryNum(ebikeInventory.getInventoryNum());
|
||||
this.mapper.insert(inventory);
|
||||
}
|
||||
EbikeInventoryRecord inventoryRecord = EbikeInventoryRecord.builder()
|
||||
.operatorId(ebikeInventory.getOperatorId())
|
||||
.inventoryType(ebikeInventory.getInventoryType())
|
||||
.inventoryRecordNum(ebikeInventory.getInventoryNum())
|
||||
.createdBy(StpUtil.getLoginIdAsLong())
|
||||
.build();
|
||||
recordMapper.insert(inventoryRecord);
|
||||
//该类型值存入字典
|
||||
if (ebikeInventory.getInventoryType() == 1){
|
||||
//TODO:二维码生产,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void reduceInventory(EbikeInventoryVo ebikeInventory) {
|
||||
if (ebikeInventory.getInventoryNum() <= 0){
|
||||
throw new EbikeException("添加库存时填入数量不能大于/等于0");
|
||||
}
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_INVENTORY.INVENTORY_TYPE.eq(ebikeInventory.getInventoryType()));
|
||||
EbikeInventory inventory = this.mapper.selectOneByQuery(queryWrapper);
|
||||
if (inventory != null) {
|
||||
long num = inventory.getInventoryNum() + ebikeInventory.getInventoryNum();
|
||||
if (num < 0){
|
||||
throw new EbikeException("当前库存总数不足");
|
||||
}
|
||||
inventory.setInventoryNum(num);
|
||||
this.mapper.update(inventory);
|
||||
}else {
|
||||
if (ebikeInventory.getInventoryNum() < 0){
|
||||
throw new EbikeException("暂无库存");
|
||||
}
|
||||
}
|
||||
EbikeInventoryRecord inventoryRecord = EbikeInventoryRecord.builder()
|
||||
.operatorId(ebikeInventory.getOperatorId())
|
||||
.inventoryType(ebikeInventory.getInventoryType())
|
||||
.inventoryRecordNum(ebikeInventory.getInventoryNum())
|
||||
.createdBy(StpUtil.getLoginIdAsLong())
|
||||
.build();
|
||||
recordMapper.insert(inventoryRecord);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user