Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -1,29 +1,43 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetSensitiveWordList() (wordList []*model.SensitiveWord, err error) {
|
||||
sql := `SELECT * FROM sensitive_word WHERE deleted_at = ?`
|
||||
err = GetRows(nil, &wordList, sql, utils.DefaultTimeValue)
|
||||
/*VendorID = -2 的时候是通用,-1 查询所有,保留之前的1,看后面会不会有扩展*/
|
||||
func GetSensitiveWordList(vendorID int) (wordList []*model.SensitiveWord, err error) {
|
||||
if vendorID == 0 {
|
||||
vendorID = -2
|
||||
}
|
||||
if vendorID == -1 {
|
||||
sql := `SELECT * FROM sensitive_word WHERE deleted_at = ?`
|
||||
err = GetRows(nil, &wordList, sql, utils.DefaultTimeValue)
|
||||
} else {
|
||||
sql := `SELECT * FROM sensitive_word WHERE deleted_at = ? AND vendor_id = ?`
|
||||
err = GetRows(nil, &wordList, sql, utils.DefaultTimeValue, vendorID)
|
||||
}
|
||||
return wordList, err
|
||||
}
|
||||
|
||||
func InsertSensitiveWord(word string, vendorID int, userName string) error {
|
||||
if vendorID == 0 {
|
||||
vendorID = -2
|
||||
}
|
||||
sensitiveWord := &model.SensitiveWord{Word: word, VendorID: vendorID}
|
||||
WrapAddIDCULDEntity(sensitiveWord, userName)
|
||||
return CreateEntity(nil, sensitiveWord)
|
||||
}
|
||||
|
||||
func DeleteSensitiveWord(wordList *model.SensitiveWord, id int, userName string) (word *model.SensitiveWord, err error) {
|
||||
if id == 0 {
|
||||
return nil, errors.New("入参错误,找不到相应ID")
|
||||
func DeleteSensitiveWord(wordList *model.SensitiveWord, id int, userName string, vendorID int) (word *model.SensitiveWord, err error) {
|
||||
if vendorID == 0 {
|
||||
vendorID = -2
|
||||
}
|
||||
wordList.ID = id
|
||||
if id != 0 {
|
||||
wordList.ID = id
|
||||
}
|
||||
wordList.VendorID = id
|
||||
wordList.DeletedAt = time.Now()
|
||||
wordList.LastOperator = userName
|
||||
if _, err := UpdateEntity(nil, wordList, "deleted_at", "id", "last_operator", "vendor_id"); err != nil {
|
||||
@@ -32,11 +46,14 @@ func DeleteSensitiveWord(wordList *model.SensitiveWord, id int, userName string)
|
||||
return wordList, nil
|
||||
}
|
||||
|
||||
func UpdateSensitiveWord(wordList *model.SensitiveWord, id int, userName string, params ...string) (word *model.SensitiveWord, err error) {
|
||||
if id == 0 {
|
||||
return nil, errors.New("入参错误,找不到相应ID")
|
||||
func UpdateSensitiveWord(wordList *model.SensitiveWord, vendorID int, id int, userName string, params ...string) (word *model.SensitiveWord, err error) {
|
||||
if vendorID == 0 {
|
||||
vendorID = -2
|
||||
}
|
||||
wordList.ID = id
|
||||
if id != 0 {
|
||||
wordList.ID = id
|
||||
}
|
||||
wordList.VendorID = vendorID
|
||||
wordList.UpdatedAt = time.Now()
|
||||
wordList.LastOperator = userName
|
||||
if _, err := UpdateEntity(nil, wordList, params...); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user