- remove literal '1970-01-01 00:00:00'
This commit is contained in:
@@ -33,8 +33,10 @@ func GetVendorCategories(vendorID int, parentID string) (vendorCats []*model.Sku
|
||||
|
||||
// parentID 为-1表示所有
|
||||
func GetCategories(parentID int) (cats []*model.SkuCategory, err error) {
|
||||
params := []interface{}{}
|
||||
sql := "SELECT * FROM sku_category WHERE deleted_at = '1970-01-01 00:00:00' "
|
||||
params := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
sql := "SELECT * FROM sku_category WHERE deleted_at = ?"
|
||||
if parentID != -1 {
|
||||
sql += " AND parent_id = ?"
|
||||
params = append(params, parentID)
|
||||
@@ -120,16 +122,16 @@ func DeleteCategory(categoryID int, userName string) (num int64, err error) {
|
||||
if err = dao.GetRows(db, &countInfos, `
|
||||
SELECT COUNT(*) ct
|
||||
FROM sku t1
|
||||
WHERE t1.category_id = ?
|
||||
WHERE t1.category_id = ? AND t1.deleted_at = ?
|
||||
UNION ALL
|
||||
SELECT COUNT(*) ct
|
||||
FROM sku_name t1
|
||||
WHERE t1.category_id = ?
|
||||
WHERE t1.category_id = ? AND t1.deleted_at = ?
|
||||
UNION ALL
|
||||
SELECT COUNT(*) ct
|
||||
FROM sku_category t1
|
||||
WHERE t1.parent_id = ?
|
||||
`, categoryID, categoryID, categoryID, &countInfos); err == nil {
|
||||
WHERE t1.parent_id = ? AND t1.deleted_at = ?
|
||||
`, categoryID, utils.DefaultTimeValue, categoryID, utils.DefaultTimeValue, categoryID, utils.DefaultTimeValue, &countInfos); err == nil {
|
||||
if countInfos[0].Ct != 0 {
|
||||
return 0, errors.New("还有商品使用此类别,不能删除")
|
||||
} else if countInfos[1].Ct != 0 {
|
||||
@@ -148,10 +150,13 @@ func GetSkuNames(keyword string, params map[string]interface{}, offset, pageSize
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
FROM sku_name t1
|
||||
LEFT JOIN sku t2 ON t1.id = t2.name_id AND t2.deleted_at = '1970-01-01 00:00:00'
|
||||
LEFT JOIN sku t2 ON t1.id = t2.name_id AND t2.deleted_at = ?
|
||||
LEFT JOIN sku_name_place_bind t3 ON t1.id = t3.name_id
|
||||
WHERE t1.deleted_at = '1970-01-01 00:00:00'`
|
||||
sqlParams := make([]interface{}, 0)
|
||||
WHERE t1.deleted_at = ?`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if keyword != "" {
|
||||
keywordLike := "%" + keyword + "%"
|
||||
sql += " AND (t1.name LIKE ? OR t1.prefix LIKE ? OR t2.comment LIKE ?"
|
||||
|
||||
Reference in New Issue
Block a user