新增门店 ip配置

This commit is contained in:
chy
2025-06-24 10:36:39 +08:00
parent 3166edc3dd
commit ea574905f9
14 changed files with 446 additions and 2 deletions

View File

@ -173,3 +173,93 @@ func (s *sStore) GetDesktopSetting(ctx context.Context, in *model.StoreGetDeskto
return out, nil
}
func (s *sStore) GetIPList(ctx context.Context, in *model.IPListIn) (*model.IPListout, error) {
m := dao.StoreIps.Ctx(ctx)
if in.StoreId > 0 {
m = m.Where(do.StoreIps{
StoreId: in.StoreId,
})
}
var list []model.StoreIps
var total int
err := m.Page(in.Page, in.Size).ScanAndCount(&list, &total, false)
if err != nil {
return nil, ecode.Fail.Sub("IP列表获取失败")
}
return &model.IPListout{
List: list,
Total: int64(total),
}, nil
}
func (s *sStore) CreateIP(ctx context.Context, in *model.IPCreateIn) (*model.IPCreateOut, error) {
exist, err := dao.StoreIps.Ctx(ctx).Where(do.StoreIps{StoreId: in.StoreId, IpAddress: in.Ip}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("门店IP创建失败")
}
if exist {
return nil, ecode.Params.Sub("门店IP已存在")
}
_, err = dao.StoreIps.Ctx(ctx).Insert(do.StoreIps{
IpAddress: in.Ip,
Remark: in.Remark,
StoreId: in.StoreId,
})
if err != nil {
return nil, ecode.Fail.Sub("门店IP创建失败")
}
return &model.IPCreateOut{
Success: true,
}, nil
}
func (s *sStore) UpdateIP(ctx context.Context, in *model.IPUpdateIn) (*model.IPUpdateOut, error) {
//exist, err := dao.StoreIps.Ctx(ctx).Where(do.StoreIps{StoreId: in.StoreId, IpAddress: in.Ip}).Exist()
//
//if err != nil {
// return nil, ecode.Fail.Sub("门店IP更新失败")
//}
//
//if exist {
// return nil, ecode.Params.Sub("门店IP已存在")
//}
_, err := dao.StoreIps.Ctx(ctx).Where(do.StoreIps{Id: in.Id}).Data(do.StoreIps{IpAddress: in.Ip, Remark: in.Remark}).Update()
if err != nil {
return nil, ecode.Fail.Sub("门店IP更新失败")
}
return &model.IPUpdateOut{
Success: true,
}, nil
}
func (s *sStore) DeleteIP(ctx context.Context, in *model.IPDeleteIn) (*model.IPDeleteOut, error) {
exist, err := dao.StoreIps.Ctx(ctx).Where(do.StoreIps{Id: in.Id}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("门店IP查询失败")
}
if !exist {
return nil, ecode.Params.Sub("门店不已存在")
}
_, err = dao.StoreIps.Ctx(ctx).Where(do.StoreIps{Id: in.Id}).Delete()
if err != nil {
return nil, ecode.Fail.Sub("删除门店IP失败")
}
return &model.IPDeleteOut{
Success: true,
}, nil
}