feat: 增加真实采购任务安全模式 (#98)
This commit is contained in:
@@ -92,6 +92,7 @@ func TouchClient(db *sql.DB, clientID string) error {
|
||||
type ClientView struct {
|
||||
model.Client
|
||||
Status string
|
||||
PurchaseMode string
|
||||
AssignedUserID string
|
||||
AssignedUsername string
|
||||
}
|
||||
@@ -136,6 +137,7 @@ func listClientViews(db *sql.DB, keyword, visibleUserID string, threshold time.D
|
||||
views = append(views, ClientView{
|
||||
Client: c.Client,
|
||||
Status: c.StatusText(now, threshold),
|
||||
PurchaseMode: repository.ParseClientPurchaseMode(c.Capabilities),
|
||||
AssignedUserID: c.AssignedUserID,
|
||||
AssignedUsername: c.AssignedUsername,
|
||||
})
|
||||
@@ -185,7 +187,9 @@ func ListClientPageForUser(db *sql.DB, actor *model.User, keyword string, thresh
|
||||
views := make([]ClientView, 0, len(rows))
|
||||
for _, client := range rows {
|
||||
views = append(views, ClientView{
|
||||
Client: client.Client, Status: client.StatusText(now, threshold),
|
||||
Client: client.Client,
|
||||
Status: client.StatusText(now, threshold),
|
||||
PurchaseMode: repository.ParseClientPurchaseMode(client.Capabilities),
|
||||
AssignedUserID: client.AssignedUserID, AssignedUsername: client.AssignedUsername,
|
||||
})
|
||||
}
|
||||
@@ -252,6 +256,6 @@ func DeleteClients(db *sql.DB, clientIDs []string) (int64, error) {
|
||||
// ClaimNextTask 为客户端领取一个任务,没有可领的返回 (nil, nil)。
|
||||
//
|
||||
// 调用方拿到 nil 要返回 204 No Content,**不是 200 加空对象**。
|
||||
func ClaimNextTask(db *sql.DB, clientID string, supportedTypes []string) (*model.Task, error) {
|
||||
return repository.ClaimNextTask(db, clientID, supportedTypes)
|
||||
func ClaimNextTask(db *sql.DB, clientID string, supportedTypes []string, purchaseModes ...string) (*model.Task, error) {
|
||||
return repository.ClaimNextTask(db, clientID, supportedTypes, purchaseModes...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user