You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.0 KiB
77 lines
2.0 KiB
|
3 years ago
|
package jurisdictionpc
|
||
|
|
|
||
|
|
import (
|
||
|
|
"key_performance_indicators/models/modelshr"
|
||
|
|
"key_performance_indicators/overall"
|
||
|
|
"key_performance_indicators/overall/publicmethod"
|
||
|
|
"strconv"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
/*
|
||
|
|
*
|
||
|
|
@ 作者: 秦东
|
||
|
|
@ 时间: 2023-03-21 11:06:07
|
||
|
|
@ 功能: 搜索人员
|
||
|
|
@ 参数
|
||
|
|
|
||
|
|
#
|
||
|
|
|
||
|
|
@ 返回值
|
||
|
|
|
||
|
|
#
|
||
|
|
|
||
|
|
@ 方法原型
|
||
|
|
|
||
|
|
#
|
||
|
|
*/
|
||
|
|
func (a *ApiMethod) SearchPeople(c *gin.Context) {
|
||
|
|
var receivedValue FlowGetRoleList
|
||
|
|
err := c.ShouldBindJSON(&receivedValue)
|
||
|
|
if err != nil {
|
||
|
|
publicmethod.Result(100, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if receivedValue.Name == "" {
|
||
|
|
publicmethod.Result(101, receivedValue, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if receivedValue.Page == 0 {
|
||
|
|
receivedValue.Page = 1
|
||
|
|
}
|
||
|
|
if receivedValue.PageSize == 0 {
|
||
|
|
receivedValue.PageSize = 20
|
||
|
|
}
|
||
|
|
var listCont []modelshr.PersonArchives
|
||
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Where("`emp_type` BETWEEN ? AND ?", 1, 10)
|
||
|
|
if receivedValue.Name != "" {
|
||
|
|
gormDb = gormDb.Where("`name` LIKE ?", "%"+receivedValue.Name+"%")
|
||
|
|
}
|
||
|
|
var total int64
|
||
|
|
gormDbTotal := gormDb
|
||
|
|
totalErr := gormDbTotal.Count(&total).Error
|
||
|
|
if totalErr != nil {
|
||
|
|
total = 0
|
||
|
|
}
|
||
|
|
gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize)
|
||
|
|
err = gormDb.Find(&listCont).Error
|
||
|
|
if err != nil {
|
||
|
|
publicmethod.Result(107, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var sendContList []EmployeesCont
|
||
|
|
for _, v := range listCont {
|
||
|
|
var sendCont EmployeesCont
|
||
|
|
sendCont.Id = strconv.FormatInt(v.Id, 10) //`json:"id"`
|
||
|
|
sendCont.EmployeeName = v.Name //`json:"employeeName"` //人员名称
|
||
|
|
sendCont.IsLeave = "0" //`json:"isLeave"` //行政组织名称
|
||
|
|
sendCont.Open = "false" //`json:"open"` //上级ID
|
||
|
|
sendCont.Icon = v.Icon //`json:"icon"` //头像
|
||
|
|
sendCont.IconToBase64 = v.IconPhoto //`json:"iconToBase64"` //头像
|
||
|
|
sendContList = append(sendContList, sendCont)
|
||
|
|
}
|
||
|
|
publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(sendContList)), sendContList, c)
|
||
|
|
|
||
|
|
}
|