func (this *JXController) UpdateMjx() { this.info = &map[string]string{ "admin": "没有权限修改月常规绩效", "no": "不存在该月常规绩效", "err": "操作失败", "ok": "操作成功", } if !this.IsAdmin() { this.error("admin") return } content := this.GetString("content") date, _ := this.GetInt64("date") score, _ := this.GetInt8("score") uid, _ := this.GetInt("uid") id, _ := this.GetInt("id") mjxOption := models.NewMjxOption() mjx, err := mjxOption.Read(id) if err != nil { this.error("no") return } mjx.Content = content mjx.Date = date mjx.Uid = uid mjx.Score = score mjx.Time = time.Now().Unix() _, err = mjxOption.Update(mjx) if err != nil { this.error("err") return } this.success("ok") }
func (this *JXController) AddMjx() { this.info = &map[string]string{ "admin": "没有权限添加月常规绩效", } if !this.IsAdmin() { this.error("admin") return } content := this.GetString("content") date, _ := this.GetInt64("date") score, _ := this.GetInt8("score") uid, _ := this.GetInt("uid") id, _ := models.NewMjxOption().Insert(models.NewMjx(uid, content, score, date)) this.success(map[string]interface{}{"id": id}) }
func (this *JXController) DeleteMjx() { this.info = &map[string]string{ "admin": "没有权限删除月常规绩效", "err": "操作失败", "ok": "操作成功", } if !this.IsAdmin() { this.error("admin") return } id, _ := this.GetInt("id") err := models.NewMjxOption().Delete(id) if err != nil { this.error("err") return } this.success("ok") }
func (this *JXController) GetMjx() { this.info = &map[string]string{ "post": "所有信息必须填写", "end": "结束时间不能早于开始时间,并且不能早于今天", } uid := this.user.Id admin := this.IsAdmin() if admin { uid, _ = this.GetInt("uid") } startTime, _ := this.GetInt64("qian") endTime, _ := this.GetInt64("hou") if endTime < startTime { this.error("end") return } mjx := models.NewMjxOption().ReadByUidInMonth(uid, startTime, endTime) this.success(mjx) }