pg_users_dao.go
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package dao
import (
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction"
)
type UsersDao struct {
transactionContext *transaction.TransactionContext
}
func NewUsersDao(transactionContext *transaction.TransactionContext) (*UsersDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &UsersDao{
transactionContext: transactionContext,
}, nil
}
}
func (dao UsersDao) UpdateUserStatus(ids []int64, ststus int8) error {
tx := dao.transactionContext.PgTx
m := &models.Users{}
_, err := tx.Model(m).
Set("status=?", ststus).
WhereIn("id in(?)", ids).
Update()
return err
}
// UpdateUserPhone 更新用户手机号
func (dao UsersDao) UpdateUserPhone(oldPhone string, newPhone string) error {
tx := dao.transactionContext.PgTx
m := &models.Users{}
_, err := tx.Model(m).
Set("phone=?", newPhone).
Where("phone=?", oldPhone).
Update()
return err
}