43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package backend
|
|
|
|
import (
|
|
"cron_admin/app/constants/errorcode"
|
|
"cron_admin/app/http/controllers"
|
|
"cron_admin/app/http/entities/backend"
|
|
"cron_admin/app/models/userinfomodel"
|
|
"cron_admin/app/services"
|
|
"github.com/ahmetb/go-linq/v3"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func Login(c *gin.Context) {
|
|
|
|
}
|
|
|
|
func List(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.UserListRequest)
|
|
count, list, err := services.GetListByWhere(request, request.Page, request.PageSize)
|
|
if err != nil {
|
|
controllers.HandRes(c, nil, errorcode.NotFound)
|
|
} else {
|
|
UserList := make([]backend.UserListResponse, 0)
|
|
linq.From(list).SelectT(func(in userinfomodel.UserInfo) (d backend.UserListResponse) {
|
|
d.ResponseFromDb(in)
|
|
return d
|
|
}).ToSlice(&UserList)
|
|
controllers.HandRes(c, gin.H{"data": UserList, "count": count}, err)
|
|
}
|
|
}
|
|
|
|
func GerUserInfoHandler(c *gin.Context) {
|
|
request := controllers.GetRequest(c).(*backend.UserInfoRequest)
|
|
has, userInfo, err := services.UserInfo(request.Id)
|
|
if err != nil || has == false {
|
|
controllers.HandRes(c, nil, errorcode.NotFound)
|
|
} else {
|
|
UserInfoResponse := backend.UserListResponse{}
|
|
UserInfoResponse.ResponseFromDb(userInfo)
|
|
controllers.HandRes(c, UserInfoResponse, nil)
|
|
}
|
|
}
|