|
@@ -27,6 +27,9 @@ func XcxApiControllersRegisterRouters() {
|
27
|
27
|
|
28
|
28
|
//获取登录后的信息
|
29
|
29
|
beego.Router("/xcx/api/mobile/getdatainfo", &XcxApiController{}, "Get:GetDataInfo")
|
|
30
|
+
|
|
31
|
+ //获取排班数据
|
|
32
|
+ beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
|
30
|
33
|
}
|
31
|
34
|
|
32
|
35
|
type XcxApiController struct {
|
|
@@ -61,39 +64,50 @@ func (this *XcxApiController) GetUserRegister() {
|
61
|
64
|
mobile := this.GetString("mobile")
|
62
|
65
|
code := this.GetString("code")
|
63
|
66
|
|
64
|
|
- role := models.XcxAdminUserRole{
|
65
|
|
- PatientName: name,
|
66
|
|
- IdCardNo: id_card_no,
|
67
|
|
- Mobile: mobile,
|
68
|
|
- Code: code,
|
69
|
|
- PatientId: 0,
|
70
|
|
- UserOrgId: 0,
|
71
|
|
- Status: 0,
|
72
|
|
- Ctime: 0,
|
73
|
|
- Mtime: 0,
|
74
|
|
- Appid: "",
|
75
|
|
- Appsecret: "",
|
76
|
|
- SessionKey: "",
|
77
|
|
- }
|
78
|
|
-
|
79
|
|
- //查找该电话号码是否存在
|
80
|
|
- _, errcode := service.GetXcxMobileInformation(mobile)
|
81
|
|
- if errcode == gorm.ErrRecordNotFound {
|
|
67
|
+ patient, errcodes := service.GetMobilePatient(id_card_no)
|
|
68
|
+ if errcodes == gorm.ErrRecordNotFound {
|
|
69
|
+ role := models.XcxAdminUserRole{
|
|
70
|
+ PatientName: name,
|
|
71
|
+ IdCardNo: id_card_no,
|
|
72
|
+ Mobile: mobile,
|
|
73
|
+ Code: code,
|
|
74
|
+ PatientId: patient.ID,
|
|
75
|
+ UserOrgId: patient.UserOrgId,
|
|
76
|
+ Status: 1,
|
|
77
|
+ Ctime: time.Now().Unix(),
|
|
78
|
+ Mtime: 0,
|
|
79
|
+ Appid: "",
|
|
80
|
+ Appsecret: "",
|
|
81
|
+ SessionKey: "",
|
|
82
|
+ }
|
82
|
83
|
|
83
|
|
- err := service.CreateXcxAdminUser(role)
|
84
|
|
- if err == nil {
|
85
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
86
|
|
- return
|
|
84
|
+ //查找该电话号码是否存在
|
|
85
|
+ _, errcode := service.GetMobilePatient(mobile)
|
|
86
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
87
|
+ err := service.CreateXcxAdminUser(role)
|
|
88
|
+ if err == nil {
|
|
89
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
90
|
+ return
|
|
91
|
+ }
|
|
92
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
93
|
+ "role": role,
|
|
94
|
+ })
|
|
95
|
+ } else if errcode == nil {
|
|
96
|
+ mobilePatient, _ := service.GetMobilePatient(id_card_no)
|
|
97
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
98
|
+ "is_bind": true,
|
|
99
|
+ "patient": mobilePatient,
|
|
100
|
+ })
|
87
|
101
|
}
|
|
102
|
+
|
|
103
|
+ fmt.Println("roler", role)
|
|
104
|
+ } else if errcodes == nil {
|
88
|
105
|
this.ServeSuccessJSON(map[string]interface{}{
|
89
|
|
- "role": role,
|
|
106
|
+ "is_bind": false,
|
|
107
|
+ "patient": patient,
|
90
|
108
|
})
|
91
|
|
- } else if errcode == nil {
|
92
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
93
|
|
- return
|
94
|
109
|
}
|
95
|
110
|
|
96
|
|
- fmt.Println("roler", role)
|
97
|
111
|
}
|
98
|
112
|
|
99
|
113
|
func (this *XcxApiController) GetCodeInfo() {
|
|
@@ -202,3 +216,15 @@ func (this *XcxApiController) GetDataInfo() {
|
202
|
216
|
"list": list,
|
203
|
217
|
})
|
204
|
218
|
}
|
|
219
|
+
|
|
220
|
+func (this *XcxApiController) GetScheduleInfo() {
|
|
221
|
+ thisWeekMonday := service.GetFirstDateOfWeek()
|
|
222
|
+
|
|
223
|
+ TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
|
|
224
|
+ lastWeekMonday := TimeMonday.AddDate(0, 0, -7)
|
|
225
|
+ nextWeekMonday := TimeMonday.AddDate(0, 0, +7)
|
|
226
|
+ var weekMonday = lastWeekMonday.Format("2006-01-02")
|
|
227
|
+ var weekDay = nextWeekMonday.Format("2006-01-02")
|
|
228
|
+ fmt.Println("weekmodonday", weekMonday)
|
|
229
|
+ fmt.Println("nextweeekday", weekDay)
|
|
230
|
+}
|