...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"oppmg/models"
|
|
|
"oppmg/protocol"
|
|
|
"oppmg/utils"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
|
|
|
"github.com/astaxie/beego/orm"
|
...
|
...
|
@@ -40,9 +41,10 @@ func addAchievementChance(addData []protocol.AchievementChance, achievementId in |
|
|
)
|
|
|
nowTime := time.Now()
|
|
|
for _, v := range addData {
|
|
|
chanceId, _ := strconv.ParseInt(v.Id, 10, 64)
|
|
|
m := models.AchievementChance{
|
|
|
AchievementId: achievementId,
|
|
|
ChanceId: v.Id,
|
|
|
ChanceId: chanceId,
|
|
|
ChanceCode: v.Code,
|
|
|
CreateAt: nowTime,
|
|
|
}
|
...
|
...
|
@@ -63,8 +65,8 @@ func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) er |
|
|
CompanyId: companyid,
|
|
|
DepartmentId: addData.DepartmentId,
|
|
|
UserCompanyId: addData.UserCompanyId,
|
|
|
ChanceTypeId: addData.TypeIdA,
|
|
|
AuditTemplateId: addData.TypeIdB,
|
|
|
ChanceTypeId: addData.ChanceTypeId,
|
|
|
AuditTemplateId: addData.AuditTemplateId,
|
|
|
SourceContent: addData.SourceContent,
|
|
|
GraspScore: addData.GraspScore,
|
|
|
UserGraspScore: addData.UserGraspScore,
|
...
|
...
|
@@ -117,8 +119,8 @@ func EditAchievement(editData *protocol.RequestEditAchievement, companyid int64) |
|
|
achievementData.UpdateAt = nowTime
|
|
|
achievementData.DepartmentId = editData.DepartmentId
|
|
|
achievementData.UserCompanyId = editData.UserCompanyId
|
|
|
achievementData.ChanceTypeId = editData.TypeIdA
|
|
|
achievementData.AuditTemplateId = editData.TypeIdB
|
|
|
achievementData.ChanceTypeId = editData.ChanceTypeId
|
|
|
achievementData.AuditTemplateId = editData.AuditTemplateId
|
|
|
achievementData.SourceContent = editData.SourceContent
|
|
|
achievementData.GraspScore = editData.GraspScore
|
|
|
achievementData.UserGraspScore = editData.UserGraspScore
|
...
|
...
|
@@ -262,17 +264,83 @@ func GetAchievementList(pageIndex int, pageSize int, companyId int64, status int |
|
|
}
|
|
|
|
|
|
func GetAchievementInfo(id int64, companyId int64) *protocol.ResponseAchievementInfo {
|
|
|
// rspData := &protocol.ResponseAchievementInfo{
|
|
|
// Images: make([]string, 0),
|
|
|
// Provider: make([]protocol.AchievementProvider, 0),
|
|
|
// ChanceData: make([]protocol.AchievementChance, 0),
|
|
|
// }
|
|
|
// var (
|
|
|
// achievementData *models.Achievement
|
|
|
// providerData []models.AchievementProvider
|
|
|
// chanceData []models.AchievementChance
|
|
|
// )
|
|
|
rspData := &protocol.ResponseAchievementInfo{
|
|
|
Images: make([]protocol.AchievementImage, 0),
|
|
|
Provider: make([]protocol.AchievementProvider, 0),
|
|
|
ChanceData: make([]protocol.AchievementChance, 0),
|
|
|
}
|
|
|
var (
|
|
|
achievementData *models.Achievement
|
|
|
chanceData []models.AchievementChance
|
|
|
err error
|
|
|
)
|
|
|
achievementData, err = models.GetAchievementById(id)
|
|
|
if err == nil {
|
|
|
rspData.AchievementId = achievementData.Id
|
|
|
rspData.AuditTemplateId = achievementData.AuditTemplateId
|
|
|
rspData.ChanceTypeId = achievementData.ChanceTypeId
|
|
|
rspData.DepartmentId = achievementData.DepartmentId
|
|
|
rspData.SourceContent = achievementData.SourceContent
|
|
|
img := make([]protocol.AchievementImage, 0)
|
|
|
json.Unmarshal([]byte(achievementData.Images), &img)
|
|
|
rspData.Images = img
|
|
|
rspData.GraspScore = achievementData.GraspScore
|
|
|
rspData.UserCompanyId = achievementData.UserCompanyId
|
|
|
} else {
|
|
|
log.Error("获取achievement数据失败:%s", err)
|
|
|
}
|
|
|
chanceData, err = models.GetAchievementChanceByAchieve(id)
|
|
|
if err == nil {
|
|
|
for _, v := range chanceData {
|
|
|
m := protocol.AchievementChance{
|
|
|
Id: fmt.Sprint(v.ChanceId),
|
|
|
Code: v.ChanceCode,
|
|
|
}
|
|
|
rspData.ChanceData = append(rspData.ChanceData, m)
|
|
|
}
|
|
|
} else {
|
|
|
log.Error("获取achievement_chance数据失败:%s", err)
|
|
|
}
|
|
|
rspData.Provider = getAchievementProvider(rspData.AchievementId)
|
|
|
var (
|
|
|
usercompanyData *models.UserCompany
|
|
|
departmentData *models.Department
|
|
|
chaneTypeData *models.ChanceType
|
|
|
auditTempData *models.AuditTemplate
|
|
|
)
|
|
|
departmentData, err = models.GetDepartmentById(rspData.DepartmentId)
|
|
|
if err == nil {
|
|
|
rspData.DeparmentName = departmentData.Name
|
|
|
}
|
|
|
usercompanyData, err = models.GetUserCompanyById(rspData.UserCompanyId)
|
|
|
if err == nil {
|
|
|
rspData.UserName = usercompanyData.NickName
|
|
|
}
|
|
|
chaneTypeData, err = models.GetChanceTypeById(int(rspData.ChanceTypeId))
|
|
|
if err == nil {
|
|
|
rspData.ChanceTypeName = chaneTypeData.Name
|
|
|
}
|
|
|
auditTempData, err = models.GetAuditTemplateById(rspData.AuditTemplateId)
|
|
|
if err == nil {
|
|
|
rspData.AuditTemplateName = auditTempData.Name
|
|
|
}
|
|
|
return rspData
|
|
|
}
|
|
|
|
|
|
// models.GetAchievementById(id)
|
|
|
return nil
|
|
|
func getAchievementProvider(achievementId int64) []protocol.AchievementProvider {
|
|
|
sql := `SELECT a.achievement_id,a.department_id,a.user_company_id,a.user_grasp_score
|
|
|
,b.nick_name,c.name
|
|
|
FROM achievement_provider AS a
|
|
|
LEFT JOIN user_company AS b on a.user_company_id = b.id
|
|
|
LEFT JOIN department AS c ON a.department_id = c.id
|
|
|
WHERE achievement_id=? `
|
|
|
var (
|
|
|
err error
|
|
|
sqldata = make([]protocol.AchievementProvider, 0)
|
|
|
)
|
|
|
err = utils.ExecuteQueryAll(&sqldata, sql, achievementId)
|
|
|
if err != nil {
|
|
|
log.Error("SQL EXECUTE ERR:%s", err)
|
|
|
}
|
|
|
return sqldata
|
|
|
} |
...
|
...
|
|