35 lines
686 B
Go
35 lines
686 B
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
|
|
|
"36wisdom/biz/model/dto"
|
|
"36wisdom/biz/service"
|
|
)
|
|
|
|
type adminUser struct{}
|
|
|
|
var AdminUser = &adminUser{}
|
|
|
|
func (c *adminUser) Get(ctx context.Context, req *dto.AdminUserGetReq) (*dto.AdminUserGetRes, error) {
|
|
rec, err := service.AdminUser.GetByUsername(ctx, req.Username)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res := &dto.AdminUserGetRes{}
|
|
if !rec.IsEmpty() {
|
|
res.AdminUser = adminUserItem(rec)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
func adminUserItem(r gdb.Record) dto.AdminUserItem {
|
|
return dto.AdminUserItem{
|
|
Id: r["id"].Int64(),
|
|
Username: r["username"].String(),
|
|
Status: r["status"].Int(),
|
|
}
|
|
}
|