增加社区列表接口,任务相关接口修改
This commit is contained in:
45
internal/model/nh_task_community_model.go
Executable file
45
internal/model/nh_task_community_model.go
Executable file
@@ -0,0 +1,45 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
var _ NhTaskCommunityModel = (*customNhTaskCommunityModel)(nil)
|
||||
|
||||
type (
|
||||
// NhTaskCommunityModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customNhTaskCommunityModel.
|
||||
NhTaskCommunityModel interface {
|
||||
nhTaskCommunityModel
|
||||
withSession(session sqlx.Session) NhTaskCommunityModel
|
||||
All(ctx context.Context) ([]NhTaskCommunity, error)
|
||||
}
|
||||
|
||||
customNhTaskCommunityModel struct {
|
||||
*defaultNhTaskCommunityModel
|
||||
}
|
||||
)
|
||||
|
||||
func (m *customNhTaskCommunityModel) All(ctx context.Context) ([]NhTaskCommunity, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `status` = 1", nhTaskCommunityRows, m.table)
|
||||
var resp []NhTaskCommunity
|
||||
err := m.conn.QueryRowsCtx(ctx, &resp, query)
|
||||
if err != nil && !errors.Is(err, sqlx.ErrNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// NewNhTaskCommunityModel returns a model for the database table.
|
||||
func NewNhTaskCommunityModel(conn sqlx.SqlConn) NhTaskCommunityModel {
|
||||
return &customNhTaskCommunityModel{
|
||||
defaultNhTaskCommunityModel: newNhTaskCommunityModel(conn),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhTaskCommunityModel) withSession(session sqlx.Session) NhTaskCommunityModel {
|
||||
return NewNhTaskCommunityModel(sqlx.NewSqlConnFromSession(session))
|
||||
}
|
||||
Reference in New Issue
Block a user