Beispiel #1
0
func (this *LoginController) Post() {
	username := this.GetString("login_username")
	password := this.GetString("login_password")

	loginRet := rpc.JsonResult{}
	if username == "" || password == "" {
		loginRet.Result = "请输入用户名和密码!"
	}
	params := t.Params{
		"username": username,
		"password": password,
	}
	code, user := svc.Get("user", params)

	if code != "success" {
		beego.Error("User:%s login error code: %s", username, code)
		loginRet.Result = "用户名或密码错误!"
		this.Data["json"] = &loginRet
		this.ServeJson()
		return
	}
	loginRet = this.setSessionFromUser(user)
	if loginRet.Ret == "success" {
		this.SetSession(SessionUserUserName, username)
	}
	this.Data["json"] = &loginRet
	this.ServeJson()
}
Beispiel #2
0
func Get(sn string) (map[string]interface{}, bool) {
	params := t.Params{
		s.Sn: sn,
	}
	status, retMap := svc.Get(s.Product, params)
	return retMap, strings.EqualFold(stat.Success, status)
}
Beispiel #3
0
func (this *UiController) Update() {
	item, ok := this.Ctx.Input.Params[":hi"]
	if !ok {
		beego.Error(stat.ParamItemError)
		this.Ctx.WriteString(stat.ParamItemError)
		return
	}
	oItemDef, ok := itemDef.EntityDefMap[item]
	if !ok {
		beego.Error(fmt.Sprintf("Item %s not define", item))
		this.Ctx.WriteString(stat.ItemNotDefine)
		return
	}
	sn := this.GetString(s.Sn)
	if sn == "" {
		beego.Error("ui.Update", stat.ParamSnIsNone)
		this.Ctx.WriteString(stat.ParamSnIsNone)
		return
	}
	params := t.Params{s.Sn: sn}
	code, oldValueMap := svc.Get(item, params)
	if code == "success" {
		this.Data["Service"] = "/item/update/" + item
		this.Data["Form"] = ui.BuildUpdatedForm(oItemDef, oldValueMap)
		this.Data["Onload"] = ui.BuildUpdateOnLoadJs(oItemDef)
		this.TplNames = "item/update.tpl"
	} else {
		this.Ctx.WriteString(stat.ItemNotFound)
	}
}
Beispiel #4
0
func (this *SupplierController) UiUpdate() {
	item := s.Supplier
	oItemDef, _ := itemDef.EntityDefMap[item]
	sn := this.GetString(s.Sn)
	if sn == "" {
		beego.Error("ui.Update", stat.ParamSnIsNone)
		this.Ctx.WriteString(stat.ParamSnIsNone)
		return
	}
	params := t.Params{s.Sn: sn}
	code, oldValueMap := svc.Get(item, params)
	if code == "success" {
		this.Data["Service"] = "/item/update/" + item
		oItemDef.FillEnum(s.Category, getCategoryEnumList())
		this.Data["Form"] = ui.BuildUpdatedForm(oItemDef, oldValueMap)
		this.Data["Onload"] = ui.BuildUpdateOnLoadJs(oItemDef)
		this.TplNames = "item/update.tpl"
	} else {
		this.Ctx.WriteString(stat.ItemNotFound)
	}
}
Beispiel #5
0
func (this *ProductController) UiUpdate() {
	item := s.Product
	oItemDef, _ := itemDef.EntityDefMap[item]
	sn := this.GetString(s.Sn)
	if sn == "" {
		beego.Error("UiUpdate error: ", stat.ParamSnIsNone)
		this.Ctx.WriteString(stat.ParamSnIsNone)
		return
	}
	params := t.Params{s.Sn: sn}
	code, oldValueMap := svc.Get(item, params)
	if code == "success" {
		oldValueMap = transProductMap(oldValueMap)
		this.FillFormElement(ui.BuildFormElement(oItemDef, oldValueMap, map[string]string{}))
		_, suppliers := supplierMgr.GetSupplierListByProductSn(sn)
		this.Data["supplierList"] = suppliers
		_, categorys := svc.GetAll(s.Category)
		this.Data["CategoryOptions"] = ui.BuildSelectOptions(categorys, "", s.Key, s.Name, s.Flag)
		this.TplNames = "product/update.tpl"
	} else {
		this.Ctx.WriteString(stat.ItemNotFound)
	}
}
Beispiel #6
0
func (this *TravelController) UiUpdate() {
	if this.GetCurRole() == s.RoleUser {
		this.Ctx.WriteString("没有权限")
		return
	}
	item := s.Travel
	oItemDef, _ := itemDef.EntityDefMap[item]
	sn := this.GetString(s.Sn)
	if sn == "" {
		beego.Error("TravelController.UiUpdate", stat.ParamSnIsNone)
		this.Ctx.WriteString(stat.ParamSnIsNone)
		return
	}
	params := t.Params{s.Sn: sn}
	code, oldValueMap := svc.Get(item, params)
	if code == "success" {
		this.Data["Service"] = "/item/update/" + item
		this.Data["Form"] = ui.BuildUpdatedForm(extendUserField(oItemDef, s.Approver), expandTravelMapForUpdate(oldValueMap))
		this.Data["Onload"] = ui.BuildUpdateOnLoadJs(oItemDef)
		this.TplNames = "travel/update.tpl"
	} else {
		this.Ctx.WriteString(stat.ItemNotFound)
	}
}
Beispiel #7
0
func Get(sn string) (string, map[string]interface{}) {
	params := t.Params{
		s.Sn: sn,
	}
	return svc.Get(s.User, params)
}