|
@@ -60,7 +60,12 @@ func (c *UserController) List() {
|
|
|
// 查询
|
|
|
T_name := c.GetString("T_name")
|
|
|
T_power := c.GetString("T_power")
|
|
|
- R_List, R_cnt := Account.Read_User_List(T_name, T_power, page, page_z)
|
|
|
+ T_dept, _ := c.GetInt("T_dept")
|
|
|
+ T_dept_leader, _ := c.GetInt("T_dept_leader")
|
|
|
+ if T_dept_leader == 1 {
|
|
|
+ T_dept = c.User.T_dept
|
|
|
+ }
|
|
|
+ R_List, R_cnt := Account.Read_User_List(T_name, T_power, T_dept, T_dept_leader, page, page_z)
|
|
|
|
|
|
var r_jsons lib.R_JSONS
|
|
|
r_jsons.Num = R_cnt
|
|
@@ -73,6 +78,24 @@ func (c *UserController) List() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func (c *UserController) Get() {
|
|
|
+
|
|
|
+ T_uuid := c.GetString("T_uuid")
|
|
|
+ user, err := Account.Read_User_ByT_uuid(T_uuid)
|
|
|
+ if err != nil {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var r_jsons lib.R_JSONS
|
|
|
+ r_jsons.Data = Account.UserToUser_R(user)
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// 个人信息
|
|
|
func (c *UserController) Info() {
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Account.UserToUser_R(c.User)}
|
|
@@ -86,16 +109,54 @@ func (c *UserController) Add() {
|
|
|
T_name := c.GetString("T_name")
|
|
|
T_user := c.GetString("T_user")
|
|
|
T_pass := c.GetString("T_pass")
|
|
|
- T_dept := c.GetString("T_dept")
|
|
|
- T_post := c.GetString("T_post")
|
|
|
+ T_dept, _ := c.GetInt("T_dept")
|
|
|
+ T_post, _ := c.GetInt("T_post")
|
|
|
+ T_dept_leader, _ := c.GetInt("T_dept_leader")
|
|
|
+
|
|
|
+ T_sex, _ := c.GetInt("T_sex")
|
|
|
+ T_id_card := c.GetString("T_id_card")
|
|
|
+ T_nation := c.GetString("T_nation")
|
|
|
+ T_school := c.GetString("T_school")
|
|
|
+ T_major := c.GetString("T_major")
|
|
|
+ T_education := c.GetString("T_education")
|
|
|
+ T_phone := c.GetString("T_phone")
|
|
|
+ T_marry, _ := c.GetInt("T_marry")
|
|
|
+ T_spouse_name := c.GetString("T_spouse_name")
|
|
|
+ T_spouse_phone := c.GetString("T_spouse_phone")
|
|
|
+ T_entry_time := c.GetString("T_entry_time")
|
|
|
+ T_positive_time := c.GetString("T_positive_time")
|
|
|
+ T_entry_type := c.GetString("T_entry_type")
|
|
|
+ T_contract_start_time := c.GetString("T_contract_start_time")
|
|
|
+ T_contract_end_time := c.GetString("T_contract_end_time")
|
|
|
+ T_expire, _ := c.GetInt("T_expire")
|
|
|
+ T_remark := c.GetString("T_remark")
|
|
|
|
|
|
var_ := Account.User{
|
|
|
- T_power: T_power,
|
|
|
- T_name: T_name,
|
|
|
- T_user: T_user,
|
|
|
- T_pass: T_pass,
|
|
|
- T_dept: T_dept,
|
|
|
- T_post: T_post,
|
|
|
+ T_power: T_power,
|
|
|
+ T_name: T_name,
|
|
|
+ T_user: T_user,
|
|
|
+ T_pass: T_pass,
|
|
|
+ T_dept: T_dept,
|
|
|
+ T_post: T_post,
|
|
|
+ T_dept_leader: T_dept_leader,
|
|
|
+
|
|
|
+ T_sex: T_sex,
|
|
|
+ T_id_card: T_id_card,
|
|
|
+ T_nation: T_nation,
|
|
|
+ T_school: T_school,
|
|
|
+ T_major: T_major,
|
|
|
+ T_education: T_education,
|
|
|
+ T_phone: T_phone,
|
|
|
+ T_marry: T_marry,
|
|
|
+ T_spouse_name: T_spouse_name,
|
|
|
+ T_spouse_phone: T_spouse_phone,
|
|
|
+ T_entry_time: T_entry_time,
|
|
|
+ T_positive_time: T_positive_time,
|
|
|
+ T_entry_type: T_entry_type,
|
|
|
+ T_contract_start_time: T_contract_start_time,
|
|
|
+ T_contract_end_time: T_contract_end_time,
|
|
|
+ T_expire: T_expire,
|
|
|
+ T_remark: T_remark,
|
|
|
}
|
|
|
if len(T_power) < 1 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 204, Msg: "权限异常!"}
|
|
@@ -142,18 +203,9 @@ func (c *UserController) Add() {
|
|
|
// 修改个人信息
|
|
|
func (c *UserController) Post() {
|
|
|
|
|
|
- T_name := c.GetString("T_name")
|
|
|
T_pass := c.GetString("T_pass")
|
|
|
|
|
|
user := c.User
|
|
|
- if len(T_name) > 0 {
|
|
|
- if len(T_name) < 3 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 204, Msg: "名字格式不正确!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- user.T_name = T_name
|
|
|
- }
|
|
|
|
|
|
if len(T_pass) > 0 {
|
|
|
if len(T_pass) < 8 {
|
|
@@ -164,16 +216,13 @@ func (c *UserController) Post() {
|
|
|
user.T_pass = T_pass
|
|
|
}
|
|
|
|
|
|
- if err := Account.Update_User(user, "T_power", "T_name", "T_user", "T_pass"); err != nil {
|
|
|
- if len(T_pass) < 8 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
+ if err := Account.Update_User(user, "T_pass"); err != nil {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- user.T_pass = "******"
|
|
|
- System.Add_UserLogs_T(c.User.T_uuid, "用户", "修改个人信息", user)
|
|
|
+ System.Add_UserLogs_T(c.User.T_uuid, "用户", "修改登录密码", "")
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
c.ServeJSON()
|
|
@@ -188,11 +237,31 @@ func (c *UserController) Edit() {
|
|
|
T_power := c.GetString("T_power")
|
|
|
T_name := c.GetString("T_name")
|
|
|
T_pass := c.GetString("T_pass")
|
|
|
- T_dept := c.GetString("T_dept")
|
|
|
- T_post := c.GetString("T_post")
|
|
|
+ T_dept, _ := c.GetInt("T_dept")
|
|
|
+ T_post, _ := c.GetInt("T_post")
|
|
|
+ T_dept_leader, T_dept_leader_err := c.GetInt("T_dept_leader")
|
|
|
+
|
|
|
+ T_sex, T_sex_err := c.GetInt("T_sex")
|
|
|
+ T_id_card := c.GetString("T_id_card")
|
|
|
+ T_nation := c.GetString("T_nation")
|
|
|
+ T_school := c.GetString("T_school")
|
|
|
+ T_major := c.GetString("T_major")
|
|
|
+ T_education := c.GetString("T_education")
|
|
|
+ T_phone := c.GetString("T_phone")
|
|
|
+ T_marry, T_marry_err := c.GetInt("T_marry")
|
|
|
+ T_spouse_name := c.GetString("T_spouse_name")
|
|
|
+ T_spouse_phone := c.GetString("T_spouse_phone")
|
|
|
+ T_entry_time := c.GetString("T_entry_time")
|
|
|
+ T_positive_time := c.GetString("T_positive_time")
|
|
|
+ T_entry_type := c.GetString("T_entry_type")
|
|
|
+ T_contract_start_time := c.GetString("T_contract_start_time")
|
|
|
+ T_contract_end_time := c.GetString("T_contract_end_time")
|
|
|
+ T_expire, T_expire_err := c.GetInt("T_expire")
|
|
|
+ T_remark := c.GetString("T_remark")
|
|
|
|
|
|
var err error
|
|
|
var user Account.User
|
|
|
+ var cols []string
|
|
|
|
|
|
if len(T_uuid) > 0 {
|
|
|
user, err = Account.Read_User_ByT_uuid(T_uuid)
|
|
@@ -204,21 +273,23 @@ func (c *UserController) Edit() {
|
|
|
}
|
|
|
|
|
|
if len(T_name) > 0 {
|
|
|
- if len(T_name) < 3 {
|
|
|
+ if len(T_name) < 2 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 204, Msg: "名字格式不正确!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
user.T_name = T_name
|
|
|
+ cols = append(cols, "T_name")
|
|
|
}
|
|
|
|
|
|
if len(T_pass) > 0 {
|
|
|
- if len(T_power) < 8 {
|
|
|
+ if len(T_pass) < 8 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 206, Msg: "密码格式不正确!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
user.T_pass = T_pass
|
|
|
+ cols = append(cols, "T_pass")
|
|
|
}
|
|
|
|
|
|
if len(T_power) > 0 {
|
|
@@ -229,17 +300,94 @@ func (c *UserController) Edit() {
|
|
|
return
|
|
|
}
|
|
|
user.T_power = T_power
|
|
|
+ cols = append(cols, "T_power")
|
|
|
}
|
|
|
|
|
|
- if len(T_dept) > 0 {
|
|
|
+ if T_dept > 0 {
|
|
|
user.T_dept = T_dept
|
|
|
+ cols = append(cols, "T_dept")
|
|
|
}
|
|
|
|
|
|
- if len(T_post) > 0 {
|
|
|
+ if T_post > 0 {
|
|
|
user.T_post = T_post
|
|
|
+ cols = append(cols, "T_post")
|
|
|
+ }
|
|
|
+
|
|
|
+ if T_dept_leader_err != nil {
|
|
|
+ user.T_dept_leader = T_dept_leader
|
|
|
+ cols = append(cols, "T_dept_leader")
|
|
|
+ }
|
|
|
+
|
|
|
+ if T_sex_err != nil {
|
|
|
+ user.T_sex = T_sex
|
|
|
+ cols = append(cols, "T_sex")
|
|
|
+ }
|
|
|
+ if len(T_id_card) > 0 {
|
|
|
+ user.T_id_card = T_id_card
|
|
|
+ cols = append(cols, "T_id_card")
|
|
|
+ }
|
|
|
+ if len(T_nation) > 0 {
|
|
|
+ user.T_nation = T_nation
|
|
|
+ cols = append(cols, "T_nation")
|
|
|
+ }
|
|
|
+ if len(T_school) > 0 {
|
|
|
+ user.T_school = T_school
|
|
|
+ cols = append(cols, "T_school")
|
|
|
+ }
|
|
|
+ if len(T_major) > 0 {
|
|
|
+ user.T_major = T_major
|
|
|
+ cols = append(cols, "T_major")
|
|
|
+ }
|
|
|
+ if len(T_education) > 0 {
|
|
|
+ user.T_education = T_education
|
|
|
+ cols = append(cols, "T_education")
|
|
|
+ }
|
|
|
+ if len(T_phone) > 0 {
|
|
|
+ user.T_phone = T_phone
|
|
|
+ cols = append(cols, "T_phone")
|
|
|
+ }
|
|
|
+ if T_marry_err != nil {
|
|
|
+ user.T_marry = T_marry
|
|
|
+ cols = append(cols, "T_marry")
|
|
|
+ }
|
|
|
+ if len(T_spouse_name) > 0 {
|
|
|
+ user.T_spouse_name = T_spouse_name
|
|
|
+ cols = append(cols, "T_spouse_name")
|
|
|
+ }
|
|
|
+ if len(T_spouse_phone) > 0 {
|
|
|
+ user.T_spouse_phone = T_spouse_phone
|
|
|
+ cols = append(cols, "T_spouse_phone")
|
|
|
+ }
|
|
|
+ if len(T_entry_time) > 0 {
|
|
|
+ user.T_entry_time = T_entry_time
|
|
|
+ cols = append(cols, "T_entry_time")
|
|
|
+ }
|
|
|
+ if len(T_positive_time) > 0 {
|
|
|
+ user.T_positive_time = T_positive_time
|
|
|
+ cols = append(cols, "T_positive_time")
|
|
|
+ }
|
|
|
+ if len(T_entry_type) > 0 {
|
|
|
+ user.T_entry_type = T_entry_type
|
|
|
+ cols = append(cols, "T_entry_type")
|
|
|
+ }
|
|
|
+ if len(T_contract_start_time) > 0 {
|
|
|
+ user.T_contract_start_time = T_contract_start_time
|
|
|
+ cols = append(cols, "T_contract_start_time")
|
|
|
+ }
|
|
|
+ if len(T_contract_end_time) > 0 {
|
|
|
+ user.T_contract_end_time = T_contract_end_time
|
|
|
+ cols = append(cols, "T_contract_end_time")
|
|
|
+ }
|
|
|
+ if T_expire_err != nil {
|
|
|
+ user.T_expire = T_expire
|
|
|
+ cols = append(cols, "T_expire")
|
|
|
+ }
|
|
|
+ if len(T_remark) > 0 {
|
|
|
+ user.T_remark = T_remark
|
|
|
+ cols = append(cols, "T_remark")
|
|
|
}
|
|
|
|
|
|
- if err = Account.Update_User(user, "T_power", "T_name", "T_pass", "T_dept", "T_post"); err != nil {
|
|
|
+ if err = Account.Update_User(user, cols...); err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 208, Msg: "修改失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
@@ -269,6 +417,11 @@ func (c *UserController) Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
+ if user.Id == 1 {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "禁止删除超级管理员!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
if err = Account.Delete_User(user); err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|