软质押任务修改

This commit is contained in:
lianghuanjie
2025-01-08 16:02:11 +08:00
parent 6dea53e53c
commit 29abba438c
11 changed files with 187 additions and 38 deletions

View File

@@ -31,6 +31,7 @@ type (
nhTaskModel
withSession(session sqlx.Session) NhTaskModel
FindTasksByCommunity(ctx context.Context, communityId uint) ([]*NhTask, error)
FindDailyPayTask(ctx context.Context) (*NhTask, error)
}
customNhTaskModel struct {
@@ -38,6 +39,20 @@ type (
}
)
func (m *customNhTaskModel) FindDailyPayTask(ctx context.Context) (*NhTask, error) {
query := fmt.Sprintf("select %s from %s where `status` = 1 and `type` = ? limit 1", nhTaskRows, m.table)
var resp NhTask
err := m.conn.QueryRowCtx(ctx, &resp, query, TASKTYPE_DAILY_PAY)
switch {
case err == nil:
return &resp, nil
case errors.Is(err, sqlx.ErrNotFound):
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *customNhTaskModel) FindTasksByCommunity(ctx context.Context, communityId uint) ([]*NhTask, error) {
query := fmt.Sprintf("select %s from %s where `status` = 1 and community_id = ? order by `sort`", nhTaskRows, m.table)
var tasks []*NhTask