|
@@ -16,7 +16,6 @@ type User struct {
|
|
|
T_uuid string `orm:"size(256);null"` //
|
|
|
T_power int `orm:"size(2);default(0)"` // 权限
|
|
|
T_name string `orm:"size(256);null"` // 某某公司名称
|
|
|
- T_user string `orm:"size(256);null"` // 登录用户名
|
|
|
T_pass string `orm:"size(256);null"` // 密码 MD5
|
|
|
T_passstr string `orm:"size(256);null"` // 密码明文
|
|
|
T_Show int `orm:"size(200);default(1)"` // 0隐藏 1公开
|
|
@@ -28,7 +27,6 @@ type User_R struct {
|
|
|
T_uuid string //
|
|
|
T_power int // 权限
|
|
|
T_name string // 某某公司名称
|
|
|
- T_user string // 登录用户名
|
|
|
T_passstr string // 密码明文
|
|
|
T_Show int // 0 1
|
|
|
T_State int // 0 1
|
|
@@ -49,7 +47,6 @@ func UserToUser_R(T User) (T_r User_R) {
|
|
|
T_r.T_uuid = T.T_uuid
|
|
|
T_r.T_power = T.T_power
|
|
|
T_r.T_name = T.T_name
|
|
|
- T_r.T_user = T.T_user
|
|
|
T_r.T_passstr = T.T_passstr
|
|
|
T_r.T_Show = T.T_Show
|
|
|
T_r.T_State = T.T_State
|
|
@@ -68,8 +65,8 @@ func Read_User_ByT_uuid(T_uuid string) (e error, r User) {
|
|
|
|
|
|
func Read_User_verification(T_user string, T_pass string) (error, User) {
|
|
|
o := orm.NewOrm()
|
|
|
- r := User{T_user: T_user, T_pass: T_pass, T_State: 1}
|
|
|
- err := o.Read(&r, "T_user", "T_pass", "T_State") // o.Read(&r,"Tokey") 如果不是 主键 就得指定字段名
|
|
|
+ r := User{T_name: T_user, T_pass: T_pass, T_State: 1}
|
|
|
+ err := o.Read(&r, "T_name", "T_pass", "T_State") // o.Read(&r,"Tokey") 如果不是 主键 就得指定字段名
|
|
|
if err != nil {
|
|
|
logs.Error(lib.FuncName(), err)
|
|
|
}
|
|
@@ -103,6 +100,19 @@ func Read_User(T_uuid string) (r User, is bool) {
|
|
|
return r, true
|
|
|
}
|
|
|
|
|
|
+// 获取 By T_name
|
|
|
+func Read_UserByT_name(T_name string) (r User, is bool) {
|
|
|
+
|
|
|
+ o := orm.NewOrm()
|
|
|
+ qs := o.QueryTable(new(User))
|
|
|
+ err := qs.Filter("T_name", T_name).Filter("T_State", 1).One(&r)
|
|
|
+ if err != nil {
|
|
|
+ return r, false
|
|
|
+ }
|
|
|
+
|
|
|
+ return r, true
|
|
|
+}
|
|
|
+
|
|
|
// 添加
|
|
|
func Add_User(r User) (id int64, is bool) {
|
|
|
o := orm.NewOrm()
|
|
@@ -117,12 +127,7 @@ func Add_User(r User) (id int64, is bool) {
|
|
|
rand_x += 1
|
|
|
}
|
|
|
|
|
|
- err := o.Read(&r, "T_user", "T_State") // o.Read(&r,"Tokey") 如果不是 主键 就得指定字段名
|
|
|
- if err == nil {
|
|
|
- return 0, false
|
|
|
- }
|
|
|
-
|
|
|
- id, err = o.Insert(&r)
|
|
|
+ id, err := o.Insert(&r)
|
|
|
if err != nil {
|
|
|
logs.Error(lib.FuncName(), err)
|
|
|
return 0, false
|
|
@@ -181,7 +186,7 @@ func Read_User_List(T_name string, page int, page_z int) ([]User_R, int64) {
|
|
|
offset = int64((page - 1) * page_z)
|
|
|
}
|
|
|
cond := orm.NewCondition()
|
|
|
- cond1 := cond.And("T_State", 1).AndCond(cond.Or("T_name__icontains", T_name).Or("T_user__icontains", T_name))
|
|
|
+ cond1 := cond.And("T_State", 1).AndCond(cond.Or("T_name__icontains", T_name))
|
|
|
qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("-Id").All(&r)
|
|
|
cnt, _ := qs.SetCond((*orm2.Condition)(cond1)).Count()
|
|
|
|