正在显示
5 个修改的文件
包含
103 行增加
和
0 行删除
| @@ -3,6 +3,7 @@ package controllers | @@ -3,6 +3,7 @@ package controllers | ||
| 3 | import ( | 3 | import ( |
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | "oppmg/common/log" | 5 | "oppmg/common/log" |
| 6 | + "oppmg/models" | ||
| 6 | "oppmg/protocol" | 7 | "oppmg/protocol" |
| 7 | serveachievement "oppmg/services/achievement" | 8 | serveachievement "oppmg/services/achievement" |
| 8 | ) | 9 | ) |
| @@ -95,3 +96,91 @@ func (c AchievementController) AchievementInfo() { | @@ -95,3 +96,91 @@ func (c AchievementController) AchievementInfo() { | ||
| 95 | msg = protocol.NewReturnResponse(rspData, nil) | 96 | msg = protocol.NewReturnResponse(rspData, nil) |
| 96 | return | 97 | return |
| 97 | } | 98 | } |
| 99 | + | ||
| 100 | +//EditAchievement 删除成果 | ||
| 101 | +//@router /achievement/delete | ||
| 102 | +func (c AchievementController) DeleteAchievement() { | ||
| 103 | + var msg *protocol.ResponseMessage | ||
| 104 | + defer func() { | ||
| 105 | + c.ResposeJson(msg) | ||
| 106 | + }() | ||
| 107 | + type Parameter struct { | ||
| 108 | + Id int64 `json:"id"` | ||
| 109 | + } | ||
| 110 | + var param Parameter | ||
| 111 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
| 112 | + log.Error("json 解析失败 err:%s", err) | ||
| 113 | + msg = protocol.BadRequestParam("1") | ||
| 114 | + return | ||
| 115 | + } | ||
| 116 | + companyid := c.GetCompanyId() | ||
| 117 | + var ( | ||
| 118 | + err error | ||
| 119 | + achievementData *models.Achievement | ||
| 120 | + ) | ||
| 121 | + achievementData, err = models.GetAchievementById(param.Id) | ||
| 122 | + if err != nil { | ||
| 123 | + log.Error("获取achievement数据失败:%s", err) | ||
| 124 | + msg = protocol.BadRequestParam("1") | ||
| 125 | + return | ||
| 126 | + } | ||
| 127 | + if achievementData.CompanyId != companyid { | ||
| 128 | + log.Error("achievement数据公司不匹配") | ||
| 129 | + msg = protocol.BadRequestParam("1") | ||
| 130 | + return | ||
| 131 | + } | ||
| 132 | + achievementData.Status = models.ACHIEVEMENT_STATUS_DEL | ||
| 133 | + err = models.UpdateAchievementById(achievementData, []string{"Status"}) | ||
| 134 | + if err != nil { | ||
| 135 | + log.Error("更新achievement数据失败:%s", err) | ||
| 136 | + } | ||
| 137 | + msg = protocol.NewReturnResponse(nil, nil) | ||
| 138 | + return | ||
| 139 | +} | ||
| 140 | + | ||
| 141 | +//EditAchievement 显示隐藏成果 | ||
| 142 | +//@router /achievement/forbid_allow | ||
| 143 | +func (c AchievementController) ForbidAllowAchievement() { | ||
| 144 | + var msg *protocol.ResponseMessage | ||
| 145 | + defer func() { | ||
| 146 | + c.ResposeJson(msg) | ||
| 147 | + }() | ||
| 148 | + type Parameter struct { | ||
| 149 | + Id int64 `json:"id"` | ||
| 150 | + Status int8 `json:"status"` //[1:显示][2:隐藏] | ||
| 151 | + } | ||
| 152 | + var param Parameter | ||
| 153 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
| 154 | + log.Error("json 解析失败 err:%s", err) | ||
| 155 | + msg = protocol.BadRequestParam("1") | ||
| 156 | + return | ||
| 157 | + } | ||
| 158 | + if param.Status != 1 && param.Status != 2 { | ||
| 159 | + msg = protocol.BadRequestParam("1") | ||
| 160 | + return | ||
| 161 | + } | ||
| 162 | + companyid := c.GetCompanyId() | ||
| 163 | + var ( | ||
| 164 | + err error | ||
| 165 | + achievementData *models.Achievement | ||
| 166 | + ) | ||
| 167 | + achievementData, err = models.GetAchievementById(param.Id) | ||
| 168 | + if err != nil { | ||
| 169 | + log.Error("获取achievement数据失败:%s", err) | ||
| 170 | + msg = protocol.BadRequestParam("1") | ||
| 171 | + return | ||
| 172 | + } | ||
| 173 | + if achievementData.CompanyId != companyid { | ||
| 174 | + log.Error("achievement数据公司不匹配") | ||
| 175 | + msg = protocol.BadRequestParam("1") | ||
| 176 | + return | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + achievementData.Status = param.Status | ||
| 180 | + err = models.UpdateAchievementById(achievementData, []string{"Status"}) | ||
| 181 | + if err != nil { | ||
| 182 | + log.Error("更新achievement数据失败:%s", err) | ||
| 183 | + } | ||
| 184 | + msg = protocol.NewReturnResponse(nil, nil) | ||
| 185 | + return | ||
| 186 | +} |
| @@ -35,6 +35,13 @@ func init() { | @@ -35,6 +35,13 @@ func init() { | ||
| 35 | orm.RegisterModel(new(Achievement)) | 35 | orm.RegisterModel(new(Achievement)) |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | +//机会状态 1:开启 2:关闭 0:删除 | ||
| 39 | +const ( | ||
| 40 | + ACHIEVEMENT_STATUS_DEL int8 = 0 //删除 | ||
| 41 | + ACHIEVEMENT_STATUS_YES int8 = 1 //开启 | ||
| 42 | + ACHIEVEMENT_STATUS_NO int8 = 2 //关闭 | ||
| 43 | +) | ||
| 44 | + | ||
| 38 | // AddAchievement insert a new Achievement into database and returns | 45 | // AddAchievement insert a new Achievement into database and returns |
| 39 | // last inserted Id on success. | 46 | // last inserted Id on success. |
| 40 | func AddAchievement(m *Achievement, om ...orm.Ormer) (id int64, err error) { | 47 | func AddAchievement(m *Achievement, om ...orm.Ormer) (id int64, err error) { |
| @@ -131,6 +131,8 @@ func init() { | @@ -131,6 +131,8 @@ func init() { | ||
| 131 | beego.NSRouter("/add", &controllers.AchievementController{}, "post:AddAchievement"), | 131 | beego.NSRouter("/add", &controllers.AchievementController{}, "post:AddAchievement"), |
| 132 | beego.NSRouter("/edit", &controllers.AchievementController{}, "post:EditAchievement"), | 132 | beego.NSRouter("/edit", &controllers.AchievementController{}, "post:EditAchievement"), |
| 133 | beego.NSRouter("/info", &controllers.AchievementController{}, "post:AchievementInfo"), | 133 | beego.NSRouter("/info", &controllers.AchievementController{}, "post:AchievementInfo"), |
| 134 | + beego.NSRouter("/delete", &controllers.AchievementController{}, "post:DeleteAchievement"), | ||
| 135 | + beego.NSRouter("/forbid_allow", &controllers.AchievementController{}, "post:ForbidAllowAchievement"), | ||
| 134 | ), | 136 | ), |
| 135 | ) | 137 | ) |
| 136 | 138 |
| @@ -72,6 +72,7 @@ func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) er | @@ -72,6 +72,7 @@ func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) er | ||
| 72 | UserGraspScore: addData.UserGraspScore, | 72 | UserGraspScore: addData.UserGraspScore, |
| 73 | CreateAt: nowTime, | 73 | CreateAt: nowTime, |
| 74 | UpdateAt: nowTime, | 74 | UpdateAt: nowTime, |
| 75 | + Status: models.ACHIEVEMENT_STATUS_YES, | ||
| 75 | } | 76 | } |
| 76 | if imgData, err := json.Marshal(addData.Images); err == nil { | 77 | if imgData, err := json.Marshal(addData.Images); err == nil { |
| 77 | achievementData.Images = string(imgData) | 78 | achievementData.Images = string(imgData) |
| @@ -19,6 +19,8 @@ const ( | @@ -19,6 +19,8 @@ const ( | ||
| 19 | M_SYSTEM_OPPORTUNITY_TEMPLATE string = "SYSTEM_OPPORTUNITY-TEMPLATE" //机会模板管理 | 19 | M_SYSTEM_OPPORTUNITY_TEMPLATE string = "SYSTEM_OPPORTUNITY-TEMPLATE" //机会模板管理 |
| 20 | M_SYSTEM_RATING string = "SYSTEM_RATING" //评分模式设置 | 20 | M_SYSTEM_RATING string = "SYSTEM_RATING" //评分模式设置 |
| 21 | M_SYSTEM_ANNOUNCEMENT string = "SYSTEM_ANNOUNCEMENT" //公告管理 | 21 | M_SYSTEM_ANNOUNCEMENT string = "SYSTEM_ANNOUNCEMENT" //公告管理 |
| 22 | + M_SYSTEM_ACHIEVEMENT string = "SYSTEM_ACHIEVEMENT" //成果管理 | ||
| 23 | + M_SYSTEM_RANK string = "SYSTEM_RANK" //排行榜配置管理 | ||
| 22 | ) | 24 | ) |
| 23 | 25 | ||
| 24 | type PermissionOptionObject interface { | 26 | type PermissionOptionObject interface { |
| @@ -102,6 +104,8 @@ var CodePermissionObject = map[string]CodeToObject{ | @@ -102,6 +104,8 @@ var CodePermissionObject = map[string]CodeToObject{ | ||
| 102 | M_SYSTEM_RATING: NewPermissionOptionBase, //评分模式 | 104 | M_SYSTEM_RATING: NewPermissionOptionBase, //评分模式 |
| 103 | M_SYSTEM_OPPORTUNITY: NewOptionOpportunity, //机会管理 | 105 | M_SYSTEM_OPPORTUNITY: NewOptionOpportunity, //机会管理 |
| 104 | M_SYSTEM_ANNOUNCEMENT: NewPermissionOptionBase, //公告管理 | 106 | M_SYSTEM_ANNOUNCEMENT: NewPermissionOptionBase, //公告管理 |
| 107 | + M_SYSTEM_ACHIEVEMENT: NewPermissionOptionBase, //成果管理 | ||
| 108 | + M_SYSTEM_RANK: NewPermissionOptionBase, //排行榜配置管理 | ||
| 105 | } | 109 | } |
| 106 | 110 | ||
| 107 | func GetUserPermission(userCompanyid int64, code ...string) (map[string]PermissionOptionObject, error) { | 111 | func GetUserPermission(userCompanyid int64, code ...string) (map[string]PermissionOptionObject, error) { |
-
请 注册 或 登录 后发表评论