Compare commits
3 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
1d657a7c00 | 3 weeks ago |
|
|
738d72b7c0 | 1 month ago |
|
|
ddec3b406d | 1 month ago |
8 changed files with 419 additions and 26 deletions
@ -0,0 +1,318 @@ |
|||||
|
package humanResources |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2026-02-12 10:28:16 |
||||
|
@ 功能: 根据权限获取员工列表 |
||||
|
*/ |
||||
|
func (a *ApiMethod) AuthorizeEmployeeList(c *gin.Context) { |
||||
|
dataVal, err := publicmethod.ReceiveData(c) //接收数据处理
|
||||
|
if err != nil { |
||||
|
publicmethod.Result(102, err, c) |
||||
|
return |
||||
|
} |
||||
|
var requestData SearchPowPople |
||||
|
err = json.Unmarshal(dataVal, &requestData) |
||||
|
if requestData.Page < 0 { |
||||
|
requestData.Page = 1 |
||||
|
} |
||||
|
if requestData.PageSize < 0 { |
||||
|
requestData.PageSize = 10 |
||||
|
} |
||||
|
//获取当前操作人
|
||||
|
context, _ := c.Get(overall.MyContJwt) |
||||
|
var myContInfo modelshr.ManCont |
||||
|
jsonCont, _ := json.Marshal(context) |
||||
|
json.Unmarshal(jsonCont, &myContInfo) |
||||
|
//获取权限
|
||||
|
myPower := publicmethod.GetMyMenuPower(myContInfo.Key, requestData.MenuId) |
||||
|
//获取人员列表
|
||||
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.UserOrgCont{}).Select("`id`").Where("`number` NOT LIKE ?", "%W%") |
||||
|
if requestData.Name != "" { |
||||
|
gormDb = gormDb.Where("`number` LIKE ? OR `name` LIKE ? OR `mobilephone` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%", "%"+requestData.Name+"%") |
||||
|
} |
||||
|
if len(requestData.Employ) > 0 { |
||||
|
gormDb = gormDb.Where("`emp_type` IN ?", requestData.Employ) |
||||
|
} else { |
||||
|
if requestData.OnJob != 0 { |
||||
|
gormDb = gormDb.Where("`emp_type` BETWEEN ? AND ?", 11, 14) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`emp_type` BETWEEN ? AND ?", 1, 10) |
||||
|
} |
||||
|
} |
||||
|
if len(requestData.Team) > 0 { |
||||
|
gormDb = gormDb.Where("`teamid` IN ?", requestData.Team) |
||||
|
} |
||||
|
if requestData.JoinTime != "" { |
||||
|
startTime, endTime := publicmethod.OenDayStartOrEndTime(requestData.JoinTime, 1) |
||||
|
gormDb = gormDb.Where("`entrydate` BETWEEN ? AND ?", startTime, endTime) |
||||
|
} |
||||
|
fmt.Printf("可见范围---------->%v\n\n", myPower.Scope) |
||||
|
switch myPower.Scope { //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
|
||||
|
case 2: |
||||
|
gormDb = gormDb.Where("`position` = ?", myContInfo.Position) |
||||
|
case 3: |
||||
|
var sunOrg publicmethod.GetOrgAllParent |
||||
|
sunOrg.GetOrgSun(int64(myContInfo.MainDeparment)) |
||||
|
sunOrg.Id = append(sunOrg.Id, int64(myContInfo.MainDeparment)) |
||||
|
if requestData.OrgId != 0 { |
||||
|
if publicmethod.IsInTrue[int64](int64(requestData.OrgId), sunOrg.Id) { |
||||
|
var pickSunOrg publicmethod.GetOrgAllParent |
||||
|
pickSunOrg.GetOrgSun(int64(requestData.OrgId)) |
||||
|
pickSunOrg.Id = append(pickSunOrg.Id, int64(requestData.OrgId)) |
||||
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", pickSunOrg.Id, pickSunOrg.Id) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", sunOrg.Id, sunOrg.Id) |
||||
|
} |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", sunOrg.Id, sunOrg.Id) |
||||
|
} |
||||
|
|
||||
|
case 4: |
||||
|
if requestData.OrgId != 0 { |
||||
|
if int64(requestData.OrgId) == myContInfo.Company { |
||||
|
gormDb = gormDb.Where("`company` = ?", myContInfo.Company) |
||||
|
} else { |
||||
|
var sunOrg publicmethod.GetOrgAllParent |
||||
|
sunOrg.GetOrgSun(myContInfo.Company) |
||||
|
if publicmethod.IsInTrue[int64](int64(requestData.OrgId), sunOrg.Id) { |
||||
|
var pickSunOrg publicmethod.GetOrgAllParent |
||||
|
pickSunOrg.GetOrgSun(int64(requestData.OrgId)) |
||||
|
pickSunOrg.Id = append(pickSunOrg.Id, int64(requestData.OrgId)) |
||||
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", pickSunOrg.Id, pickSunOrg.Id) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`company` = ?", myContInfo.Company) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
var sunOrg publicmethod.GetOrgAllParent |
||||
|
sunOrg.GetOrgSun(myContInfo.Company) |
||||
|
if publicmethod.IsInTrue[int64](int64(requestData.OrgId), sunOrg.Id) { |
||||
|
var pickSunOrg publicmethod.GetOrgAllParent |
||||
|
pickSunOrg.GetOrgSun(int64(requestData.OrgId)) |
||||
|
pickSunOrg.Id = append(pickSunOrg.Id, int64(requestData.OrgId)) |
||||
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", pickSunOrg.Id, pickSunOrg.Id) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`company` = ?", myContInfo.Company) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
case 5: |
||||
|
if requestData.OrgId != 0 { |
||||
|
//目标行政组织
|
||||
|
var sunOrg publicmethod.GetOrgAllParent |
||||
|
sunOrg.GetOrgSun(int64(requestData.OrgId)) |
||||
|
sunOrg.Id = append(sunOrg.Id, int64(requestData.OrgId)) |
||||
|
//可观测的行政组织
|
||||
|
var oid []int64 |
||||
|
for _, v := range myPower.ScopeManAry { |
||||
|
oid = append(oid, int64(v)) |
||||
|
} |
||||
|
lookOrg := publicmethod.Intersect[int64](sunOrg.Id, oid) |
||||
|
if len(lookOrg) > 0 { |
||||
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", lookOrg, lookOrg) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`orgid` = ? OR `admin_org` = ?", myContInfo.AdminOrg, myContInfo.AdminOrg) |
||||
|
} |
||||
|
} |
||||
|
case 6: |
||||
|
if requestData.OrgId != 0 { |
||||
|
var sunOrg publicmethod.GetOrgAllParent |
||||
|
sunOrg.GetOrgSun(int64(requestData.OrgId)) |
||||
|
sunOrg.Id = append(sunOrg.Id, int64(requestData.OrgId)) |
||||
|
if len(sunOrg.Id) > 0 { |
||||
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", sunOrg.Id, sunOrg.Id) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`orgid` = ? OR `admin_org` = ?", requestData.OrgId, requestData.OrgId) |
||||
|
} |
||||
|
} |
||||
|
default: |
||||
|
gormDb = gormDb.Where("`key` = ?", myContInfo.Key) |
||||
|
} |
||||
|
//获取人员总数
|
||||
|
var total int64 |
||||
|
totalErr := gormDb.Count(&total).Error |
||||
|
if totalErr != nil { |
||||
|
total = 0 |
||||
|
} |
||||
|
var idAry []int64 |
||||
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
||||
|
err = gormDb.Order("`time` DESC").Find(&idAry).Error |
||||
|
if err != nil && len(idAry) < 1 { |
||||
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(idAry)), idAry, c) |
||||
|
return |
||||
|
} |
||||
|
var manContList []modelshr.ManCont |
||||
|
err = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Order("`time` DESC").Find(&manContList).Error |
||||
|
if err != nil { |
||||
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(idAry)), idAry, c) |
||||
|
return |
||||
|
} |
||||
|
var sendList []SendPowerPeople |
||||
|
for _, v := range manContList { |
||||
|
var sendCont SendPowerPeople |
||||
|
sendCont.ManCont = v |
||||
|
sendCont.KeyStr = strconv.FormatInt(v.Key, 10) |
||||
|
sendCont.EmploymentHistory = MyAppointment(v) |
||||
|
sendCont.PersonInCharge = 2 |
||||
|
if v.PersonInCharge == 1 { |
||||
|
orgResList := strings.Split(v.ResponsibleDepartment, ",") |
||||
|
if len(orgResList) > 0 { |
||||
|
orgIdStr := strconv.FormatInt(int64(requestData.OrgId), 10) |
||||
|
if publicmethod.IsInTrue[string](orgIdStr, orgResList) == true { |
||||
|
sendCont.PersonInCharge = 1 |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
sendList = append(sendList, sendCont) |
||||
|
} |
||||
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2026-02-12 11:17:24 |
||||
|
@ 功能: 获取任职情况 |
||||
|
*/ |
||||
|
func MyAppointment(userCont modelshr.ManCont) (list []EmploymentHistoryInfo) { |
||||
|
if userCont.Key == 0 { |
||||
|
return |
||||
|
} |
||||
|
var orgHistory []modelshr.UserOrg |
||||
|
overall.CONSTANT_DB_HR.Where("`userKey` = ?", userCont.Key).Find(&orgHistory) |
||||
|
for _, v := range orgHistory { |
||||
|
var contVal EmploymentHistoryInfo |
||||
|
var orgAllName []string |
||||
|
if v.Orgid != 0 { |
||||
|
_, companyId, departmentId, sunDepartId, workShopId := publicmethod.GetOrgStructurees(v.Orgid) |
||||
|
|
||||
|
if companyId != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, orgCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if departmentId != 0 { |
||||
|
var departCont modelshr.AdministrativeOrganization |
||||
|
departCont.GetCont(map[string]interface{}{"`id`": departmentId}, "`name`") |
||||
|
if departCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](departCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, departCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if sunDepartId != 0 { |
||||
|
var sunDepartCont modelshr.AdministrativeOrganization |
||||
|
sunDepartCont.GetCont(map[string]interface{}{"`id`": sunDepartId}, "`name`") |
||||
|
if sunDepartCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](sunDepartCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, sunDepartCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if workShopId != 0 { |
||||
|
var workCont modelshr.AdministrativeOrganization |
||||
|
workCont.GetCont(map[string]interface{}{"`id`": workShopId}, "`name`") |
||||
|
if workCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](workCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, workCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} else if v.Company != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, orgCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
contVal.OrgAllName = strings.Join(orgAllName, " / ") |
||||
|
if v.Position != 0 { |
||||
|
var postCont modelshr.Position |
||||
|
postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`") |
||||
|
contVal.PositionName = postCont.Name |
||||
|
} |
||||
|
if v.TeamsId != 0 { |
||||
|
var teamCont modelshr.TeamGroup |
||||
|
teamCont.GetCont(map[string]interface{}{"`id`": v.TeamsId}, "`name`") |
||||
|
contVal.TeamName = teamCont.Name |
||||
|
} |
||||
|
contVal.Attribute = v.AssignType |
||||
|
list = append(list, contVal) |
||||
|
} |
||||
|
if len(list) < 1 { |
||||
|
var contVal EmploymentHistoryInfo |
||||
|
var orgAllName []string |
||||
|
if userCont.Company != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, orgCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if userCont.MainDeparment != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": userCont.MainDeparment}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, orgCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if userCont.SunMainDeparment != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": userCont.SunMainDeparment}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, orgCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if userCont.AdminOrg != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": userCont.AdminOrg}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) { |
||||
|
orgAllName = append(orgAllName, orgCont.Name) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
contVal.OrgAllName = strings.Join(orgAllName, " / ") |
||||
|
if userCont.Position != 0 { |
||||
|
var postCont modelshr.Position |
||||
|
postCont.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`") |
||||
|
contVal.PositionName = postCont.Name |
||||
|
} |
||||
|
if userCont.TeamId != 0 { |
||||
|
var teamCont modelshr.TeamGroup |
||||
|
teamCont.GetCont(map[string]interface{}{"`id`": userCont.TeamId}, "`name`") |
||||
|
contVal.TeamName = teamCont.Name |
||||
|
} |
||||
|
contVal.Attribute = 1 |
||||
|
list = append(list, contVal) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,63 @@ |
|||||
|
package modelshr |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
type UserOrg struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
||||
|
Userkey int64 `json:"userKey" gorm:"primaryKey;column:userKey;type:bigint(20) unsigned;not null;comment:员工唯一识别符;"` |
||||
|
Company int64 `json:"company" gorm:"primaryKey;column:company;type:bigint(20) unsigned;not null;comment:所属公司;"` |
||||
|
Orgid int64 `json:"orgid" gorm:"primaryKey;column:orgid;type:bigint(20) unsigned;not null;comment:行政组织ID;"` |
||||
|
Position int64 `json:"position" gorm:"primaryKey;column:position;type:bigint(20) unsigned;not null;comment:职位;"` |
||||
|
TeamsId int64 `json:"teamsId" gorm:"primaryKey;column:teamsId;type:bigint(20) unsigned;not null;comment:班组Id;"` |
||||
|
StartTime int64 `json:"startTime" gorm:"primaryKey;column:startTime;type:bigint(20) unsigned;not null;comment:任职开始时间;"` |
||||
|
AssignType int `json:"assignType" gorm:"column:assignType;type:int(1) unsigned;default:50;not null;comment:1:主职;2:兼职"` |
||||
|
Time int64 `json:"time" gorm:"primaryKey;column:time;type:bigint(20) unsigned;not null;comment:编辑时间;"` |
||||
|
} |
||||
|
|
||||
|
func (UserOrg *UserOrg) TableName() string { |
||||
|
return "userOrg" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *UserOrg) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *UserOrg) GetCont(whereMap interface{}, field ...string) (err error) { |
||||
|
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
gormDb = gormDb.Where(whereMap) |
||||
|
err = gormDb.First(&cont).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 根据条件获取总数
|
||||
|
func (cont *UserOrg) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *UserOrg) ContMap(whereMap interface{}, field ...string) (countAry []UserOrg, err error) { |
||||
|
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
err = gormDb.Where(whereMap).Find(&countAry).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 删除内容
|
||||
|
func (cont *UserOrg) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
Loading…
Reference in new issue