39 lines
1011 B
Go
39 lines
1011 B
Go
// 库存预警服务
|
||
// 职责:预警查询(无Create/Update/Delete,由定时任务或库存变动触发)
|
||
// 紧密耦合:dao.InventoryWarning
|
||
// 注意:预警记录由系统自动生成,非用户手动创建
|
||
package service
|
||
|
||
import (
|
||
dao "assets/dao/stock"
|
||
dto "assets/model/dto/stock"
|
||
"context"
|
||
|
||
"gitea.com/red-future/common/utils"
|
||
)
|
||
|
||
type inventoryWarning struct{}
|
||
|
||
var InventoryWarning = new(inventoryWarning)
|
||
|
||
func (s *inventoryWarning) GetOne(ctx context.Context, req *dto.GetInventoryWarningReq) (res *dto.GetInventoryWarningRes, err error) {
|
||
one, err := dao.InventoryWarning.GetOne(ctx, req)
|
||
if err != nil {
|
||
return
|
||
}
|
||
err = utils.Struct(one, &res)
|
||
return
|
||
}
|
||
|
||
func (s *inventoryWarning) List(ctx context.Context, req *dto.ListInventoryWarningReq) (res *dto.ListInventoryWarningRes, err error) {
|
||
list, total, err := dao.InventoryWarning.List(ctx, req)
|
||
if err != nil {
|
||
return
|
||
}
|
||
res = &dto.ListInventoryWarningRes{
|
||
Total: total,
|
||
}
|
||
err = utils.Struct(list, &res.List)
|
||
return
|
||
}
|