feat:完善信息
This commit is contained in:
@ -1,13 +1,50 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type UserManage struct {
|
||||
*model.UserManage
|
||||
}
|
||||
|
||||
type (
|
||||
// UserManageForExpert 专家信息
|
||||
UserManageForExpert struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
}
|
||||
)
|
||||
|
||||
// Expert 专家数据
|
||||
func (m *UserManage) Expert(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*UserManageForExpert, error) {
|
||||
query := orm.GetDB().Table(m.TableName()+" AS m").
|
||||
Select(strings.Join([]string{"m.id", "m.name", "u.mobile"}, ",")).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON m.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Where("m.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("m.identity = ?", config.TenantUserIdentityForExpert)
|
||||
|
||||
out := make([]*UserManageForExpert, 0)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
query = query.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
if err := query.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := query.Order("m.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// LastChooseInfo 最后一次选中的信息
|
||||
func (m *UserManage) LastChooseInfo(uid uint64) error {
|
||||
_, err := model.FirstField(m.UserManage, []string{"id", "tenant_id", "uuid", "identity"},
|
||||
|
Reference in New Issue
Block a user