| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | package controllersimport (    "wb/ctrl"    "wb/ii"    "wb/om"    "wb/ctrl/uibuilder"    "wb/cc"    "eps/models/etc"    "eps/models/companyMgr"    "wb/st"    "eps/models/userMgr"    "wb/lg"    "wb/ut")type UserController struct {    ctrl.ItemController    item string}func (this *UserController) NestPrepare() {    this.CtxItemInfo, _ = ii.ItemInfoMap[etc.Tbl.User]}func (this *UserController)UiAdd(){    this.UiAddItem(this.CtxItemInfo)    companys := companyMgr.GetAllCompany()    this.Data["CompanyOptions"] = uibuilder.BuildSelectOptions(companys, "", etc.Col.Sn, etc.Col.Name)    this.TplName = "user/add.tpl"}func (this *UserController)UiUpdate(){    statusMap := map[string]string{}    statusMap[etc.Col.UserName] = cc.Disabled    statusMap[etc.Col.Name] = cc.Disabled    oldMObject := this.UiUpdateItemWithStatus(this.CtxItemInfo, statusMap)    companys := companyMgr.GetAllCompany()    oldCompany := ut.Maps.GetString(oldMObject, etc.Col.Company)    this.Data["CompanyOptions"] = uibuilder.BuildSelectOptions(companys, oldCompany, etc.Col.Sn, etc.Col.Name)    this.TplName = "user/add.tpl"}func (this *UserController) MdyPwd(){    uonepasd := this.GetString("oldPassword")    params := map[string]interface{}{        etc.Col.UserName: this.GetSessionUser().GetUserName(),        etc.Col.Password: uonepasd,    }    if c, _ := userMgr.GetValidUser(params); c == st.Success {        newPass := this.GetString("newPassword")        params := map[string]interface{}{            etc.Col.Sn: this.GetSessionUser().GetSn(),            etc.Col.Password: newPass,        }        lg.SInfo("[U] User:", this.GetSessionUser().GetSn(), "Password changed!")        c, r := om.Table(etc.Tbl.User).Update(params)        this.SendJsonResult(c, r)    } else {        lg.SError("[U] User:", this.GetSessionUser().GetSn(), "Password changed error old password wrong!")        this.SendJsonResult(st.Failed, st.PasswordCheckFailed)    }}
 |