1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package service
import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
)
func CreateUserAuthe(userAuthe model.SysUserAuthe) error {
sqlStr := "INSERT INTO sys_user_authe(user_id, identity, name, phone, working_years," +
" working_place, position, hospital_province, hospital_city, hospital_county," +
" hospital_address, hospital_face_img, qualification_img,delflag" +
" ) VALUE(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
global.GVA_DB.Exec(sqlStr, userAuthe.UserId, userAuthe.Identity, userAuthe.Name, userAuthe.Phone, userAuthe.WorkingYears,
userAuthe.WorkingPlace, userAuthe.Position, userAuthe.HospitalProvince, userAuthe.HospitalCity, userAuthe.HospitalCounty,
userAuthe.HospitalAddress, userAuthe.HospitalFaceImg, userAuthe.QualificationImg, 0)
return global.GVA_DB.Error
}
func IsUserAuthe(u model.SysUserAuthe) int64 {
var line int64
sqlStr := "SELECT count(id) as line " +
" FROM sys_user_authe" +
" where user_id=? AND delflag=0"
global.GVA_DB.Raw(sqlStr, u.UserId).Find(&line)
if global.GVA_DB.Error != nil || line > 0 {
return 1
}
return 2
}
func DeleteUserAuthe(userId int) (err error) {
sqlStr := "UPDATE sys_user_authe SET delflag=? WHERE user_id=?"
global.GVA_DB.Exec(sqlStr, 1, userId)
return global.GVA_DB.Error
}
func UserAutheInfo(userId uint) (error, request.GetUserInfoReply) {
userInfo := new(request.GetUserInfoReply)
sqlStr := "SELECT id, user_id, identity, name, phone, working_years, working_place, " +
" position, hospital_province, hospital_city, hospital_county, hospital_address," +
" hospital_face_img, qualification_img, create_time, update_time " +
" FROM sys_user_authe" +
" where user_id=? AND delflag=0"
global.GVA_DB.Raw(sqlStr, userId).Find(&userInfo)
if global.GVA_DB.Error != nil {
return global.GVA_DB.Error, request.GetUserInfoReply{}
}
return nil, *userInfo
}