作者 tangxvhui

微调

... ... @@ -105,3 +105,14 @@ func ExistUserDepart(departid int64, usercompanyid int64) bool {
Exist()
return ok
}
func GetUserDepartment(departId, usercompanyid int64) (*UserDepartment, error) {
m := &UserDepartment{}
o := orm.NewOrm()
err := o.QueryTable(&UserDepartment{}).
Filter("department_id", departId).
Filter("user_company_id", usercompanyid).
Filter("enable_status", USER_DEPARTMENT_ENABLE_YES).
One(m)
return m, err
}
... ...
... ... @@ -2,6 +2,7 @@ package protocol
//ProviderData 成果提供者
type AchievementProvider struct {
Id int64 `json:"id"` //前端需要的唯一id标识,使用user_department表的id
UserCompanyId int64 `json:"user_company_id"` //用户的id
UserName string `json:"user_name"`
DepartmentId int64 `json:"department_id"` //部门id
... ...
... ... @@ -316,6 +316,7 @@ func GetAchievementInfo(id int64, companyId int64) *protocol.ResponseAchievement
chaneTypeData *models.ChanceType
auditTempData *models.AuditTemplate
)
departmentData, err = models.GetDepartmentById(rspData.DepartmentId)
if err == nil {
rspData.DepartmentId = departmentData.Id
... ... @@ -354,5 +355,11 @@ func getAchievementProvider(achievementId int64) []protocol.AchievementProvider
if err != nil {
log.Error("SQL EXECUTE ERR:%s", err)
}
for i := range sqldata {
userDepartment, err := models.GetUserDepartment(sqldata[i].DepartmentId, sqldata[i].UserCompanyId)
if err == nil {
sqldata[i].Id = userDepartment.Id
}
}
return sqldata
}
... ...