|
|
@@ -31,20 +31,20 @@ func NewDistributorService(ctx context.Context) (svc *distributorService, err er
|
|
|
return svc, nil
|
|
|
}
|
|
|
|
|
|
-//GetList 经销商信息列表
|
|
|
+// GetList 经销商信息列表
|
|
|
func (s *distributorService) GetList(req *model.BaseDistributorSearchReq) (total int, distributorList []*model.DistributorRonp, err error) {
|
|
|
distributorModel := s.Dao.M
|
|
|
if req.DistCode != "" {
|
|
|
- distributorModel = distributorModel.Where(s.Dao.Columns.DistCode+" like ?", "%"+req.DistCode+"%")
|
|
|
+ distributorModel = distributorModel.Where(s.Dao.C.DistCode+" like ?", "%"+req.DistCode+"%")
|
|
|
}
|
|
|
if req.DistName != "" {
|
|
|
- distributorModel = distributorModel.Where(s.Dao.Columns.DistName+" like ?", "%"+req.DistName+"%")
|
|
|
+ distributorModel = distributorModel.Where(s.Dao.C.DistName+" like ?", "%"+req.DistName+"%")
|
|
|
}
|
|
|
if req.BelongSale != "" {
|
|
|
- distributorModel = distributorModel.Where(s.Dao.Columns.BelongSale+" like ?", "%"+req.BelongSale+"%")
|
|
|
+ distributorModel = distributorModel.Where(s.Dao.C.BelongSale+" like ?", "%"+req.BelongSale+"%")
|
|
|
}
|
|
|
if req.ProvinceId > 0 {
|
|
|
- distributorModel = distributorModel.Where(s.Dao.Columns.ProvinceId+" in (?)", req.ProvinceId)
|
|
|
+ distributorModel = distributorModel.Where(s.Dao.C.ProvinceId+" in (?)", req.ProvinceId)
|
|
|
}
|
|
|
total, err = distributorModel.Count()
|
|
|
if err != nil {
|
|
|
@@ -55,7 +55,7 @@ func (s *distributorService) GetList(req *model.BaseDistributorSearchReq) (total
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//Create 经销商创建
|
|
|
+// Create 经销商创建
|
|
|
func (s *distributorService) Create(req *model.AddDistributor) (lastId int64, err error) {
|
|
|
DistributorData := new(model.BaseDistributor)
|
|
|
if err = gconv.Struct(req, DistributorData); err != nil {
|
|
|
@@ -72,9 +72,9 @@ func (s *distributorService) Create(req *model.AddDistributor) (lastId int64, er
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//GetEntityById 详情
|
|
|
+// GetEntityById 详情
|
|
|
func (s *distributorService) GetEntityById(id int64) (distributorInfo *model.DistributorRonp, err error) {
|
|
|
- err = s.Dao.Where(base.BaseProduct.Columns.Id, id).Scan(&distributorInfo)
|
|
|
+ err = s.Dao.Where(base.BaseProduct.C.Id, id).Scan(&distributorInfo)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
@@ -99,8 +99,8 @@ func (s *distributorService) UpdateById(req *model.UpdateDistributorReq) (err er
|
|
|
return
|
|
|
}
|
|
|
service.SetUpdatedInfo(distData, s.GetCxtUserId(), s.GetCxtUserName())
|
|
|
- _, err = s.Dao.FieldsEx(s.Dao.Columns.DistCode, s.Dao.Columns.Id,
|
|
|
- s.Dao.Columns.CreatedName, s.Dao.Columns.CreatedBy, s.Dao.Columns.CreatedTime).WherePri(s.Dao.Columns.Id, req.Id).Update(distData)
|
|
|
+ _, err = s.Dao.FieldsEx(s.Dao.C.DistCode, s.Dao.C.Id,
|
|
|
+ s.Dao.C.CreatedName, s.Dao.C.CreatedBy, s.Dao.C.CreatedTime).WherePri(s.Dao.C.Id, req.Id).Update(distData)
|
|
|
if err != nil {
|
|
|
g.Log().Error(err)
|
|
|
return
|
|
|
@@ -108,7 +108,7 @@ func (s *distributorService) UpdateById(req *model.UpdateDistributorReq) (err er
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//DeleteByIds 删除
|
|
|
+// DeleteByIds 删除
|
|
|
func (s *distributorService) DeleteByIds(ids []int64) (err error) {
|
|
|
if len(ids) == 1 {
|
|
|
count, err := s.Dao.WherePri(ids[0]).Count()
|
|
|
@@ -120,12 +120,12 @@ func (s *distributorService) DeleteByIds(ids []int64) (err error) {
|
|
|
return myerrors.TipsError("数据不存在或已被删除,请刷新页面")
|
|
|
}
|
|
|
} else {
|
|
|
- _, err := s.Dao.WhereIn(s.Dao.Columns.Id, ids).LockShared().Count()
|
|
|
+ _, err := s.Dao.WhereIn(s.Dao.C.Id, ids).LockShared().Count()
|
|
|
if err != nil {
|
|
|
g.Log().Error(err)
|
|
|
return err
|
|
|
}
|
|
|
- result, err := s.Dao.WhereIn(s.Dao.Columns.Id, ids).Delete()
|
|
|
+ result, err := s.Dao.WhereIn(s.Dao.C.Id, ids).Delete()
|
|
|
if err != nil {
|
|
|
g.Log().Error(err)
|
|
|
return err
|