正在显示
6 个修改的文件
包含
71 行增加
和
1 行删除
@@ -2,6 +2,7 @@ package controllers | @@ -2,6 +2,7 @@ package controllers | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | + "fmt" | ||
5 | "oppmg/common/log" | 6 | "oppmg/common/log" |
6 | "oppmg/protocol" | 7 | "oppmg/protocol" |
7 | "oppmg/services/platform" | 8 | "oppmg/services/platform" |
@@ -31,3 +32,26 @@ func (c PlatformController) UpdateData() { | @@ -31,3 +32,26 @@ func (c PlatformController) UpdateData() { | ||
31 | msg = protocol.NewReturnResponse(nil, err) | 32 | msg = protocol.NewReturnResponse(nil, err) |
32 | return | 33 | return |
33 | } | 34 | } |
35 | + | ||
36 | +func (c PlatformController) CompanyAdminChance() { | ||
37 | + type Parameter struct { | ||
38 | + CompanyId int64 `json:"company_id"` | ||
39 | + Phone string `json:"phone"` | ||
40 | + } | ||
41 | + var msg = protocol.ErrWithMessage{} | ||
42 | + var param Parameter | ||
43 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
44 | + e := fmt.Errorf("json 解析失败 err:%s", err) | ||
45 | + log.Error(e.Error()) | ||
46 | + msg.Errmsg = e.Error() | ||
47 | + return | ||
48 | + } | ||
49 | + err := platform.AdminChance(param.CompanyId, param.Phone) | ||
50 | + if err != nil { | ||
51 | + log.Error("总后台调用CompanyAdminChance发生错误;%s", err) | ||
52 | + msg.Errmsg = err.Error() | ||
53 | + } | ||
54 | + c.Data["json"] = msg | ||
55 | + c.ServeJSON() | ||
56 | + return | ||
57 | +} |
@@ -84,4 +84,5 @@ type ResponseAchievementInfo struct { | @@ -84,4 +84,5 @@ type ResponseAchievementInfo struct { | ||
84 | Provider []AchievementProvider `json:"provider"` //机会提供者 | 84 | Provider []AchievementProvider `json:"provider"` //机会提供者 |
85 | SourceContent string `json:"source_content"` //成果描述文本 | 85 | SourceContent string `json:"source_content"` //成果描述文本 |
86 | Images []AchievementImage `json:"image"` //图片 | 86 | Images []AchievementImage `json:"image"` //图片 |
87 | + CrreateAt string `json:"create_at"` | ||
87 | } | 88 | } |
@@ -111,7 +111,6 @@ func NewReturnResponse(data interface{}, eRR error) (msg *ResponseMessage) { | @@ -111,7 +111,6 @@ func NewReturnResponse(data interface{}, eRR error) (msg *ResponseMessage) { | ||
111 | return x.ParseToMessage() | 111 | return x.ParseToMessage() |
112 | } | 112 | } |
113 | msg = NewMessage("1") | 113 | msg = NewMessage("1") |
114 | - msg.Errmsg = eRR.Error() | ||
115 | return | 114 | return |
116 | } | 115 | } |
117 | 116 |
@@ -12,6 +12,7 @@ func init() { | @@ -12,6 +12,7 @@ func init() { | ||
12 | nsPlatform := beego.NewNamespace("/platform", | 12 | nsPlatform := beego.NewNamespace("/platform", |
13 | beego.NSBefore(middleware.LogRequestData), | 13 | beego.NSBefore(middleware.LogRequestData), |
14 | beego.NSRouter("/update", &controllers.PlatformController{}, "post:UpdateData"), | 14 | beego.NSRouter("/update", &controllers.PlatformController{}, "post:UpdateData"), |
15 | + beego.NSRouter("/admins_change", &controllers.PlatformController{}, "post:CompanyAdminChance"), | ||
15 | ) | 16 | ) |
16 | beego.AddNamespace(nsPlatform) | 17 | beego.AddNamespace(nsPlatform) |
17 | } | 18 | } |
@@ -286,6 +286,7 @@ func GetAchievementInfo(id int64, companyId int64) *protocol.ResponseAchievement | @@ -286,6 +286,7 @@ func GetAchievementInfo(id int64, companyId int64) *protocol.ResponseAchievement | ||
286 | rspData.Images = img | 286 | rspData.Images = img |
287 | rspData.GraspScore = achievementData.GraspScore | 287 | rspData.GraspScore = achievementData.GraspScore |
288 | rspData.UserCompanyId = achievementData.UserCompanyId | 288 | rspData.UserCompanyId = achievementData.UserCompanyId |
289 | + rspData.CrreateAt = achievementData.CreateAt.Format("2006-01-02 15:04:05") | ||
289 | } else { | 290 | } else { |
290 | log.Error("获取achievement数据失败:%s", err) | 291 | log.Error("获取achievement数据失败:%s", err) |
291 | } | 292 | } |
services/platform/company.go
0 → 100644
1 | +package platform | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "oppmg/common/log" | ||
6 | + "oppmg/models" | ||
7 | +) | ||
8 | + | ||
9 | +// AdminChance | ||
10 | +//companyid 总管理后台的公司id | ||
11 | +func AdminChance(companyid int64, phone string) error { | ||
12 | + var ( | ||
13 | + companyData *models.Company | ||
14 | + userData *models.User | ||
15 | + // userCompanyData *models.UserCompany | ||
16 | + err error | ||
17 | + ) | ||
18 | + companyData, err = models.GetCompanyByUCenter(companyid) | ||
19 | + if err != nil { | ||
20 | + e := fmt.Errorf("获取公司数据失败,总后台company_id:%d", companyid) | ||
21 | + log.Error(err.Error()) | ||
22 | + return e | ||
23 | + } | ||
24 | + userData, err = models.GetUserByPhone(phone) | ||
25 | + if err != nil { | ||
26 | + e := fmt.Errorf("获取用户数据失败,phone:%s", phone) | ||
27 | + log.Error(err.Error()) | ||
28 | + return e | ||
29 | + } | ||
30 | + _, err = models.GetUserCompanyBy(userData.Id, companyData.Id) | ||
31 | + if err != nil { | ||
32 | + e := fmt.Errorf("获取用户和公司的对应关系数据失败,user_id:%d,company_id:%d", userData.Id, companyData.Id) | ||
33 | + log.Error(e.Error()) | ||
34 | + return e | ||
35 | + } | ||
36 | + companyData.AdminId = userData.Id | ||
37 | + err = models.UpdateCompanyById(companyData, []string{"AdminId"}) | ||
38 | + if err != nil { | ||
39 | + e := fmt.Errorf("更新公司数据失败,err:%s", err) | ||
40 | + log.Error(e.Error()) | ||
41 | + return e | ||
42 | + } | ||
43 | + return nil | ||
44 | +} |
-
请 注册 或 登录 后发表评论