正在显示
8 个修改的文件
包含
21 行增加
和
21 行删除
| @@ -8,11 +8,11 @@ import ( | @@ -8,11 +8,11 @@ import ( | ||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | type Department struct { | 10 | type Department struct { |
| 11 | - Id int `orm:"column(id);auto"` | ||
| 12 | - CompanyId int `orm:"column(company_id)" description:"公司id"` | 11 | + Id int64 `orm:"column(id);auto"` |
| 12 | + CompanyId int64 `orm:"column(company_id)" description:"公司id"` | ||
| 13 | Name string `orm:"column(name);size(30)" description:"部门名称"` | 13 | Name string `orm:"column(name);size(30)" description:"部门名称"` |
| 14 | CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` | 14 | CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` |
| 15 | - ParentId int `orm:"column(parent_id)" description:"父级id"` | 15 | + ParentId int64 `orm:"column(parent_id)" description:"父级id"` |
| 16 | Relation string `orm:"column(relation);size(400)" description:"父子级关系树"` | 16 | Relation string `orm:"column(relation);size(400)" description:"父子级关系树"` |
| 17 | DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"` | 17 | DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"` |
| 18 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` | 18 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` |
| @@ -37,7 +37,7 @@ func AddDepartment(m *Department) (id int64, err error) { | @@ -37,7 +37,7 @@ func AddDepartment(m *Department) (id int64, err error) { | ||
| 37 | 37 | ||
| 38 | // GetDepartmentById retrieves Department by Id. Returns error if | 38 | // GetDepartmentById retrieves Department by Id. Returns error if |
| 39 | // Id doesn't exist | 39 | // Id doesn't exist |
| 40 | -func GetDepartmentById(id int) (v *Department, err error) { | 40 | +func GetDepartmentById(id int64) (v *Department, err error) { |
| 41 | o := orm.NewOrm() | 41 | o := orm.NewOrm() |
| 42 | v = &Department{Id: id} | 42 | v = &Department{Id: id} |
| 43 | if err = o.Read(v); err == nil { | 43 | if err = o.Read(v); err == nil { |
| @@ -63,7 +63,7 @@ func UpdateDepartmentById(m *Department) (err error) { | @@ -63,7 +63,7 @@ func UpdateDepartmentById(m *Department) (err error) { | ||
| 63 | 63 | ||
| 64 | // DeleteDepartment deletes Department by Id and returns error if | 64 | // DeleteDepartment deletes Department by Id and returns error if |
| 65 | // the record to be deleted doesn't exist | 65 | // the record to be deleted doesn't exist |
| 66 | -func DeleteDepartment(id int) (err error) { | 66 | +func DeleteDepartment(id int64) (err error) { |
| 67 | o := orm.NewOrm() | 67 | o := orm.NewOrm() |
| 68 | v := Department{Id: id} | 68 | v := Department{Id: id} |
| 69 | // ascertain id exists in the database | 69 | // ascertain id exists in the database |
| @@ -125,7 +125,7 @@ type DepartmentStatistics struct { | @@ -125,7 +125,7 @@ type DepartmentStatistics struct { | ||
| 125 | 125 | ||
| 126 | /*DepartmentStatistic 单部门统计*/ | 126 | /*DepartmentStatistic 单部门统计*/ |
| 127 | type DepartmentStatisticRequest struct { | 127 | type DepartmentStatisticRequest struct { |
| 128 | - DepartmentId int `json:"departmentId"` | 128 | + DepartmentId int64 `json:"departmentId"` |
| 129 | } | 129 | } |
| 130 | type DepartmentStatisticResponse struct { | 130 | type DepartmentStatisticResponse struct { |
| 131 | DepartmentStatistic DepartmentStatistics `json:"departmentStatistic"` | 131 | DepartmentStatistic DepartmentStatistics `json:"departmentStatistic"` |
| @@ -47,7 +47,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isInclude | @@ -47,7 +47,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isInclude | ||
| 47 | lastId = chance.ApproveTime.Unix() | 47 | lastId = chance.ApproveTime.Unix() |
| 48 | } | 48 | } |
| 49 | if departmentId > 0 { | 49 | if departmentId > 0 { |
| 50 | - dIds, _ = GetDepartmentIds(cid, departmentId, isIncludeSubDeps) | 50 | + dIds, _ = GetDepartmentIds(cid, int64(departmentId), isIncludeSubDeps) |
| 51 | } | 51 | } |
| 52 | log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid)) | 52 | log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid)) |
| 53 | switch check { | 53 | switch check { |
| @@ -103,12 +103,12 @@ func ChanceApprovingStatistic(header *protocol.RequestHeader, departmentIds []in | @@ -103,12 +103,12 @@ func ChanceApprovingStatistic(header *protocol.RequestHeader, departmentIds []in | ||
| 103 | 103 | ||
| 104 | //获取部门以及子部门编号 | 104 | //获取部门以及子部门编号 |
| 105 | //@isIncludeSubDeps 是否包含子部门 | 105 | //@isIncludeSubDeps 是否包含子部门 |
| 106 | -func GetDepartmentIds(companyId int64, dId int, isIncludeSubDeps bool) (departmentIds []int, err error) { | 106 | +func GetDepartmentIds(companyId int64, dId int64, isIncludeSubDeps bool) (departmentIds []int, err error) { |
| 107 | if dId == 0 { | 107 | if dId == 0 { |
| 108 | return []int{}, nil | 108 | return []int{}, nil |
| 109 | } | 109 | } |
| 110 | if !isIncludeSubDeps { | 110 | if !isIncludeSubDeps { |
| 111 | - return []int{dId}, nil | 111 | + return []int{int(dId)}, nil |
| 112 | } | 112 | } |
| 113 | if d, e := models.GetDepartmentById(dId); e != nil { | 113 | if d, e := models.GetDepartmentById(dId); e != nil { |
| 114 | log.Error(err) | 114 | log.Error(err) |
| @@ -20,7 +20,7 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme | @@ -20,7 +20,7 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme | ||
| 20 | rsp = &protocol.AchievementPoolResponse{} | 20 | rsp = &protocol.AchievementPoolResponse{} |
| 21 | rsp.List = make([]*protocol.AchievementCommonListItem, 0) | 21 | rsp.List = make([]*protocol.AchievementCommonListItem, 0) |
| 22 | if request.DepartmentId > 0 && request.IncludeSubDepartment { | 22 | if request.DepartmentId > 0 && request.IncludeSubDepartment { |
| 23 | - if d, e := models.GetDepartmentById(request.DepartmentId); e != nil { | 23 | + if d, e := models.GetDepartmentById(int64(request.DepartmentId)); e != nil { |
| 24 | log.Error(err) | 24 | log.Error(err) |
| 25 | err = e | 25 | err = e |
| 26 | return | 26 | return |
| @@ -1336,13 +1336,13 @@ func resolveActionType(t uint) string { | @@ -1336,13 +1336,13 @@ func resolveActionType(t uint) string { | ||
| 1336 | func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) (ids []int64, err error) { | 1336 | func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) (ids []int64, err error) { |
| 1337 | var ( | 1337 | var ( |
| 1338 | departments *models.Department | 1338 | departments *models.Department |
| 1339 | - lastDepartmentId int | 1339 | + lastDepartmentId int64 |
| 1340 | ) | 1340 | ) |
| 1341 | //if err = models.GetUserDepartments(header.UserId, header.CompanyId, &departments); err != nil { | 1341 | //if err = models.GetUserDepartments(header.UserId, header.CompanyId, &departments); err != nil { |
| 1342 | // log.Error(header.UserId,header.CompanyId,err) | 1342 | // log.Error(header.UserId,header.CompanyId,err) |
| 1343 | // return | 1343 | // return |
| 1344 | //} | 1344 | //} |
| 1345 | - if departments, err = models.GetDepartmentById(int(relatedDeparmentId)); err != nil { | 1345 | + if departments, err = models.GetDepartmentById(relatedDeparmentId); err != nil { |
| 1346 | log.Error(relatedDeparmentId, err) | 1346 | log.Error(relatedDeparmentId, err) |
| 1347 | return | 1347 | return |
| 1348 | } | 1348 | } |
| @@ -1370,7 +1370,7 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) | @@ -1370,7 +1370,7 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) | ||
| 1370 | if departments.ParentId != 0 { | 1370 | if departments.ParentId != 0 { |
| 1371 | //relatedDeparmentId = int64departments.ParentId | 1371 | //relatedDeparmentId = int64departments.ParentId |
| 1372 | lastDepartmentId = departments.ParentId | 1372 | lastDepartmentId = departments.ParentId |
| 1373 | - if departments, err = models.GetDepartmentById(int(departments.ParentId)); err != nil { | 1373 | + if departments, err = models.GetDepartmentById(departments.ParentId); err != nil { |
| 1374 | log.Error(departments.ParentId, err) | 1374 | log.Error(departments.ParentId, err) |
| 1375 | err = nil | 1375 | err = nil |
| 1376 | break | 1376 | break |
| @@ -1409,7 +1409,7 @@ func getRoleUsers(header *protocol.RequestHeader, roleId int) (ids []int64, err | @@ -1409,7 +1409,7 @@ func getRoleUsers(header *protocol.RequestHeader, roleId int) (ids []int64, err | ||
| 1409 | } | 1409 | } |
| 1410 | 1410 | ||
| 1411 | //递归寻找上一级部门长 | 1411 | //递归寻找上一级部门长 |
| 1412 | -func getParentDepartmentors(pid int) (ids []int64) { | 1412 | +func getParentDepartmentors(pid int64) (ids []int64) { |
| 1413 | var ( | 1413 | var ( |
| 1414 | department *models.Department | 1414 | department *models.Department |
| 1415 | err error | 1415 | err error |
| @@ -52,7 +52,7 @@ func Departments(header *protocol.RequestHeader, request *protocol.DepartmentsRe | @@ -52,7 +52,7 @@ func Departments(header *protocol.RequestHeader, request *protocol.DepartmentsRe | ||
| 52 | //遍历部门 | 52 | //遍历部门 |
| 53 | func walkDepartment(to *protocol.Department, dfrom *models.Department) (err error) { | 53 | func walkDepartment(to *protocol.Department, dfrom *models.Department) (err error) { |
| 54 | var newD *protocol.Department = &protocol.Department{ | 54 | var newD *protocol.Department = &protocol.Department{ |
| 55 | - DepartmentId: dfrom.Id, | 55 | + DepartmentId: int(dfrom.Id), |
| 56 | Name: dfrom.Name, | 56 | Name: dfrom.Name, |
| 57 | CreateTime: dfrom.CreateAt, | 57 | CreateTime: dfrom.CreateAt, |
| 58 | Departments: []*protocol.Department{}, | 58 | Departments: []*protocol.Department{}, |
| @@ -63,7 +63,7 @@ func walkDepartment(to *protocol.Department, dfrom *models.Department) (err erro | @@ -63,7 +63,7 @@ func walkDepartment(to *protocol.Department, dfrom *models.Department) (err erro | ||
| 63 | return | 63 | return |
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | - if to.DepartmentId == dfrom.ParentId { | 66 | + if to.DepartmentId == int(dfrom.ParentId) { |
| 67 | to.Departments = append(to.Departments, newD) | 67 | to.Departments = append(to.Departments, newD) |
| 68 | } | 68 | } |
| 69 | for i := range to.Departments { | 69 | for i := range to.Departments { |
| @@ -86,7 +86,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DepartmentStat | @@ -86,7 +86,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DepartmentStat | ||
| 86 | companyDep := departmentsResponse.GetCompanyDepartment() | 86 | companyDep := departmentsResponse.GetCompanyDepartment() |
| 87 | if companyDep.DepartmentId > 0 { | 87 | if companyDep.DepartmentId > 0 { |
| 88 | var companyDepStatistic *protocol.DepartmentStatisticResponse | 88 | var companyDepStatistic *protocol.DepartmentStatisticResponse |
| 89 | - if companyDepStatistic, err = DepartmentStatistic(header, &protocol.DepartmentStatisticRequest{DepartmentId: companyDep.DepartmentId}); err != nil { | 89 | + if companyDepStatistic, err = DepartmentStatistic(header, &protocol.DepartmentStatisticRequest{DepartmentId: int64(companyDep.DepartmentId)}); err != nil { |
| 90 | log.Error(err) | 90 | log.Error(err) |
| 91 | return | 91 | return |
| 92 | } | 92 | } |
| @@ -155,7 +155,7 @@ func DepartmentStatistic(header *protocol.RequestHeader, request *protocol.Depar | @@ -155,7 +155,7 @@ func DepartmentStatistic(header *protocol.RequestHeader, request *protocol.Depar | ||
| 155 | } | 155 | } |
| 156 | departmentStatistic := protocol.DepartmentStatistics{} | 156 | departmentStatistic := protocol.DepartmentStatistics{} |
| 157 | departmentStatistic.Dep = protocol.Dep{ | 157 | departmentStatistic.Dep = protocol.Dep{ |
| 158 | - Id: deparment.Id, | 158 | + Id: int(deparment.Id), |
| 159 | Name: deparment.Name, | 159 | Name: deparment.Name, |
| 160 | } | 160 | } |
| 161 | if dIds, err = agg.GetDepartmentIds(header.CompanyId, request.DepartmentId, false); err != nil { | 161 | if dIds, err = agg.GetDepartmentIds(header.CompanyId, request.DepartmentId, false); err != nil { |
| @@ -163,7 +163,7 @@ func DepartmentStatistic(header *protocol.RequestHeader, request *protocol.Depar | @@ -163,7 +163,7 @@ func DepartmentStatistic(header *protocol.RequestHeader, request *protocol.Depar | ||
| 163 | return | 163 | return |
| 164 | } | 164 | } |
| 165 | departmentStatistic.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds) | 165 | departmentStatistic.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds) |
| 166 | - departmentStatistic.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, request.DepartmentId, false, 0, 0, nil) | 166 | + departmentStatistic.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, int(request.DepartmentId), false, 0, 0, nil) |
| 167 | departmentStatistic.ACTotal = departmentStatistic.AchievementTotal + departmentStatistic.ChanceApprovedTotal | 167 | departmentStatistic.ACTotal = departmentStatistic.AchievementTotal + departmentStatistic.ChanceApprovedTotal |
| 168 | departmentStatistic.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, dIds) | 168 | departmentStatistic.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, dIds) |
| 169 | rsp.DepartmentStatistic = departmentStatistic | 169 | rsp.DepartmentStatistic = departmentStatistic |
| @@ -245,12 +245,12 @@ func GetRankSortItems(header *protocol.RequestHeader, request *protocol.GetRankS | @@ -245,12 +245,12 @@ func GetRankSortItems(header *protocol.RequestHeader, request *protocol.GetRankS | ||
| 245 | return | 245 | return |
| 246 | } | 246 | } |
| 247 | if len(sortItems) > 0 { | 247 | if len(sortItems) > 0 { |
| 248 | + rsp.RankSortItems = sortItems | ||
| 249 | + } | ||
| 248 | if len(sortItems) > 4 { | 250 | if len(sortItems) > 4 { |
| 249 | rsp.RankSortItems = sortItems[0:4] | 251 | rsp.RankSortItems = sortItems[0:4] |
| 250 | return | 252 | return |
| 251 | } | 253 | } |
| 252 | - rsp.RankSortItems = sortItems | ||
| 253 | - } | ||
| 254 | return | 254 | return |
| 255 | } | 255 | } |
| 256 | 256 |
-
请 注册 或 登录 后发表评论