Browse Source

体积小

XMLWAN 3 years ago
parent
commit
92c13913de

+ 25 - 7
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go View File

6
 	"Xcx_New/models"
6
 	"Xcx_New/models"
7
 	"Xcx_New/service"
7
 	"Xcx_New/service"
8
 	"Xcx_New/utils"
8
 	"Xcx_New/utils"
9
+	"encoding/json"
9
 	"fmt"
10
 	"fmt"
10
 	"github.com/astaxie/beego"
11
 	"github.com/astaxie/beego"
11
 	"github.com/jinzhu/gorm"
12
 	"github.com/jinzhu/gorm"
26
 	beego.Router("/xcx/api/mobile/patient", &XcxApiController{}, "Get:GetPatientList")
27
 	beego.Router("/xcx/api/mobile/patient", &XcxApiController{}, "Get:GetPatientList")
27
 
28
 
28
 	//获取登录后的信息
29
 	//获取登录后的信息
29
-	beego.Router("/xcx/api/mobile/getdatainfo", &XcxApiController{}, "Get:GetDataInfo")
30
+	beego.Router("/xcx/api/mobile/getdatainfo", &XcxApiController{}, "Post:GetDataInfo")
30
 
31
 
31
 	//获取排班数据
32
 	//获取排班数据
32
 	beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
33
 	beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
201
 }
202
 }
202
 
203
 
203
 func (this *XcxApiController) GetDataInfo() {
204
 func (this *XcxApiController) GetDataInfo() {
205
+	dataBody := make(map[string]interface{}, 0)
206
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
207
+	if err != nil {
208
+		utils.ErrorLog(err.Error())
209
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
210
+		return
211
+	}
212
+	appid := dataBody["appid"].(string)
213
+	key := dataBody["key"].(string)
214
+	iv := dataBody["iv"].(string)
215
+	encryptedData := dataBody["encryptedData"].(string)
204
 
216
 
205
-	appid := this.GetString("appid")
206
-	key := this.GetString("key")
207
-	iv := this.GetString("iv")
208
-	encryptedData := this.GetString("encryptedData")
209
 	list, err := service.DecryptData(appid, key, iv, encryptedData)
217
 	list, err := service.DecryptData(appid, key, iv, encryptedData)
210
 	if err == nil {
218
 	if err == nil {
211
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
219
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
219
 
227
 
220
 func (this *XcxApiController) GetScheduleInfo() {
228
 func (this *XcxApiController) GetScheduleInfo() {
221
 	thisWeekMonday := service.GetFirstDateOfWeek()
229
 	thisWeekMonday := service.GetFirstDateOfWeek()
222
-
230
+	weekDayWeek := service.GetWeekDayOfWeek()
223
 	TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
231
 	TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
232
+	weekDays, _ := time.Parse("2006-01-02", weekDayWeek)
224
 	lastWeekMonday := TimeMonday.AddDate(0, 0, -7)
233
 	lastWeekMonday := TimeMonday.AddDate(0, 0, -7)
225
-	nextWeekMonday := TimeMonday.AddDate(0, 0, +7)
234
+	nextWeekMonday := weekDays.AddDate(0, 0, +13)
226
 	var weekMonday = lastWeekMonday.Format("2006-01-02")
235
 	var weekMonday = lastWeekMonday.Format("2006-01-02")
227
 	var weekDay = nextWeekMonday.Format("2006-01-02")
236
 	var weekDay = nextWeekMonday.Format("2006-01-02")
228
 	fmt.Println("weekmodonday", weekMonday)
237
 	fmt.Println("weekmodonday", weekMonday)
229
 	fmt.Println("nextweeekday", weekDay)
238
 	fmt.Println("nextweeekday", weekDay)
239
+
240
+	timeLayout := "2006-01-02 15:04:05"
241
+	loc, _ := time.LoadLocation("Local")
242
+
243
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekMonday+" 00:00:00", loc)
244
+
245
+	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekDay+" 00:00:00", loc)
246
+
247
+	fmt.Println(startTime.Unix(), endTime.Unix())
230
 }
248
 }

+ 13 - 0
service/xcx_mobile_api_service.go View File

120
 	return
120
 	return
121
 }
121
 }
122
 
122
 
123
+func GetWeekDayOfWeek() (weekMonday string) {
124
+	now := time.Now()
125
+
126
+	offset := int(time.Monday - now.Weekday())
127
+	if offset > 0 {
128
+		offset = -6
129
+	}
130
+
131
+	weekStartDate := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
132
+	weekMonday = weekStartDate.Format("2006-01-02")
133
+	return
134
+}
135
+
123
 func GetMobilePatient(mobile string) (*models.XcxPatients, error) {
136
 func GetMobilePatient(mobile string) (*models.XcxPatients, error) {
124
 
137
 
125
 	patient := models.XcxPatients{}
138
 	patient := models.XcxPatients{}