package autoreply import ( "wechat-conf/controllers" "wechat-conf/models/model" "wechat-conf/service/autoreply" ) // AutoreplyController 信息 type AutoreplyController struct { dao *autoreply.AutoreplyServ controllers.BaseController } // Constructor 初始化 Controller // @Title Constructor // @Description 初始化 Controller, 系统自动调用 func (c *AutoreplyController) Constructor() { c.dao = autoreply.NewAutoreplyServ(c.Context) } func (c *AutoreplyController) GetAutoReplyList() { user := c.Context.Get("user").(*model.SysUser) page, _ := c.GetInt("page") pageSize, _ := c.GetInt("pagesize") autoType := c.GetString("autoType") list, err := c.dao.GetAutoReplyList(user.OrgId, autoType, page, pageSize) if err != nil { c.ResponseError(err) } c.ResponseJSON(list) } func (c *AutoreplyController) GetAutoReplyById() { autoreplyId := c.GetString(":autoreplyId") autoreply, err := c.dao.GetAutoReplyById(autoreplyId) if err != nil { c.ResponseError(err) } c.ResponseJSON(autoreply) } func (c *AutoreplyController) SaveAutoreply() { user := c.Context.Get("user").(*model.SysUser) autoreply := model.TaAutoReply{} if err := c.ParseForm(&autoreply); err != nil { c.ResponseError(err) } newAuto, err := c.dao.SaveAutoReply(autoreply, user.OrgId) if err != nil { c.ResponseError(err) } c.ResponseJSON(newAuto) } func (c *AutoreplyController) DeleteAutoReply() { autoreplyId := c.GetString(":autoreplyId") err := c.dao.DeleteAutoReply(autoreplyId) if err != nil { c.ResponseError(err) } c.ResponseJSON("删除成功") } func (c *AutoreplyController) ChangeIsUse() { user := c.Context.Get("user").(*model.SysUser) autoType := c.GetString(":autoType") isUse := c.GetString(":isUse") err := c.dao.DisableAutoreply(autoType, user.OrgId, isUse) if err != nil { c.ResponseError(err) } c.ResponseJSON("修改成功") }