示例#1
0
文件: users.go 项目: baiyuxiong/lms
func EditSelf(id int, password string, phone, phone1, email string) error {
	now := time.Now()

	if len(password) > 0 {
		u := new(models.Users)
		u.Salt = utils.Salt()
		u.UpdatedAt = now
		u.Password = utils.EncryptPassword(u.Salt, password)

		_, err := app.Engine.Id(id).Update(u)
		if err != nil {
			return errors.New("编辑用户失败" + err.Error())
		}
	}

	up := new(models.UserProfiles)
	up.Phone = phone
	up.Phone1 = phone1
	up.Email = email
	up.UpdatedAt = now

	_, err := app.Engine.Where("user_id=?", id).Update(up)
	if err != nil {
		return errors.New("编辑用户失败" + err.Error())
	}
	return nil
}
示例#2
0
文件: admin.go 项目: baiyuxiong/lms
func (c Admin) DelUser(id int) revel.Result {

	if id != 1 {
		u := new(models.Users)
		u.IsDelete = 1
		app.Engine.Id(id).Cols("is_delete").Update(u)
	}

	return c.Redirect("/admin/ListUser")
}
示例#3
0
文件: users.go 项目: baiyuxiong/lms
func EditUser(id int, username, password string, department_id, employment_type, gender, level int, name, phone, phone1, position, email string, join_date, birth_date time.Time, ip_address string) error {
	now := time.Now()

	u := new(models.Users)
	u.Username = username
	u.UpdatedAt = now
	u.IpAddress = ip_address

	if len(password) > 0 {
		u.Salt = utils.Salt()
		u.Password = utils.EncryptPassword(u.Salt, password)
	}

	_, err := app.Engine.Id(id).Update(u)
	if err != nil {
		return errors.New("编辑用户失败" + err.Error())
	}

	up := new(models.UserProfiles)
	up.DepartmentId = department_id
	up.Gender = gender
	up.Level = level
	up.EmploymentType = employment_type
	up.Name = name
	up.Phone = phone
	up.Phone1 = phone1
	up.Position = position
	up.JoinDate = join_date
	up.Email = email
	up.BirthDate = birth_date
	up.UpdatedAt = now

	_, err = app.Engine.Where("user_id=?", id).Update(up)
	if err != nil {
		return errors.New("编辑用户失败" + err.Error())
	}
	return nil
}