|
|
@@ -46,6 +46,11 @@ func (s *productService) GetList(req *model.ProductSearchReq) (total int, produc
|
|
|
if req.OnlySoftware {
|
|
|
Dao = Dao.Where("prod_class in (10,20,30)")
|
|
|
}
|
|
|
+ if req.StateType == "启用" {
|
|
|
+ Dao = Dao.Where("state IS NULL OR state<>'20'")
|
|
|
+ } else if req.StateType == "禁用" {
|
|
|
+ Dao = Dao.Where("state='20'")
|
|
|
+ }
|
|
|
|
|
|
total, err = Dao.Count()
|
|
|
if err != nil {
|
|
|
@@ -78,6 +83,7 @@ func (s *productService) Create(req *model.AddProductReq) (lastInsertId int64, e
|
|
|
g.Log().Error(err)
|
|
|
return
|
|
|
}
|
|
|
+ product.State = "10"
|
|
|
service.SetCreatedInfo(product, s.GetCxtUserId(), s.GetCxtUserName())
|
|
|
lastInsertId, err = s.Dao.InsertAndGetId(product)
|
|
|
if err != nil {
|
|
|
@@ -109,6 +115,16 @@ func (s *productService) UpdateById(req *model.UpdateProductReq) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// UpdateState 修改数据
|
|
|
+func (s *productService) UpdateState(req *model.UpdateStateReq) (err error) {
|
|
|
+ _, err = s.Dao.WherePri(req.Id).Update(fmt.Sprintf("state='%v'", req.State))
|
|
|
+ if err != nil {
|
|
|
+ g.Log().Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// DeleteByIds 删掉数据
|
|
|
func (s *productService) DeleteByIds(ids []int64) (err error) {
|
|
|
if len(ids) == 1 {
|