Commit 1551edad by xuyamei

修改可约时间接口信息

parent 2312415a
...@@ -6,6 +6,7 @@ import com.xiaomai.client.DataUserInfo; ...@@ -6,6 +6,7 @@ import com.xiaomai.client.DataUserInfo;
import com.xiaomai.enums.ApiModule; import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.RequestType; import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal; import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.TimeUtils;
import com.xiaomai.utils.XMBaseTest; import com.xiaomai.utils.XMBaseTest;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -20,6 +21,12 @@ import org.springframework.stereotype.Component; ...@@ -20,6 +21,12 @@ import org.springframework.stereotype.Component;
@Component("reserveTools") @Component("reserveTools")
public class ReserveTools extends XMBaseTest { public class ReserveTools extends XMBaseTest {
public void setUp(String name,DataUserInfo...dataUserInfo) {
dataApi.setApiModule(ApiModule.Polar_Reserve)
.setApiName(name)
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfo);
}
/** /**
* @description: 添加预约 * @description: 添加预约
...@@ -307,5 +314,192 @@ public class ReserveTools extends XMBaseTest { ...@@ -307,5 +314,192 @@ public class ReserveTools extends XMBaseTest {
} }
/**
* @description: 私教列表
* @author: xuyamei
* @date: 2024/7/8 11:20
* @param searchContext :搜索姓名或手机号
* @param dataUserInfo
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject pageStudioPersonalCoach(String searchContext,DataUserInfo...dataUserInfo){
setUp("API_pageStudioPersonalCoach",dataUserInfo);
JSONObject body = new JSONObject();
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("operatorId", dataApi.getLoginInfo().getAdminId()); // 操作人id
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("searchContext", searchContext); // 搜索文本:手机号或者员工昵称
body.put("state", "DUTY"); // 状态:搜索在职的
body.put("current", 0);
body.put("size", 20);
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON().getJSONObject("result");
}
/**
* @description:获取具体某个私教的可约时间
* @author: xuyamei
* @date: 2024/7/8 11:24
* @param id 员工id
* @param vo [normalTimeVOS,specialTimeVOS]
* ex-enum-descriptions:[常规时间,特定可约时间]
* @param dataUserInfo
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONArray getPersonalCoachTime(String id,String vo,DataUserInfo...dataUserInfo){
setUp("API_getPersonalCoachTime",dataUserInfo);
JSONObject body = new JSONObject();
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("operatorId", dataApi.getLoginInfo().getAdminId()); // 操作人id
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("id", id); // 员工id
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON().getJSONObject("result").getJSONArray(vo);
}
/**
* @description 查询具体某个私教历史特定可约时间
* @author: xuyamei
* @date: 2024/7/8 11:50
* @param
* @return: com.alibaba.fastjson.JSONArray
**/
public JSONArray getCoachHistorySpecialDate(String id){
setUp("API_getCoachHistorySpecialDate");
JSONObject body = new JSONObject();
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("operatorId", dataApi.getLoginInfo().getAdminId()); // 操作人id
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("id", id); // 员工id
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON().getJSONArray("result");
}
/**
* @description: 设置常规可约时间
* @author: xuyamei
* @date: 2024/7/8 14:44
* @param coachId :教练id
* @param normalTimeInfoRequests :常规时间(可传空)
* @param userInfo
* @return: com.alibaba.fastjson.JSONArray
**/
public JSONArray createNormalDate(String coachId,JSONArray normalTimeInfoRequests,DataUserInfo...userInfo){
setUp("API_createNormalDate",userInfo);
JSONObject body = new JSONObject();
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("operatorId", dataApi.getLoginInfo().getAdminId()); // 操作人id
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("coachId", coachId); // 员工id
JSONObject infoRequests = new JSONObject();
// 常规时间为空,则快速新建
if (normalTimeInfoRequests.size() == 0){
JSONArray timePeriodInfos = new JSONArray();
int[] minuteOffset = {300,720,1080};
int[] spanMinutes = {420,360,300};
for (int i = 0; i < 3; i++){
JSONObject timeInfo = new JSONObject();
timeInfo.put("minuteOffset",minuteOffset[i]);
timeInfo.put("spanMinutes",spanMinutes[i]);
timePeriodInfos.add(timeInfo);
}
infoRequests.put("timePeriodInfos",timePeriodInfos);
// 每星期
String[] weekdays = {"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"};
infoRequests.put("weekdays",weekdays);
normalTimeInfoRequests.add(infoRequests);
}
body.put("normalTimeInfoRequests",normalTimeInfoRequests);
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON().getJSONArray("result");
}
/**
* @description:创建特殊可约时间
* @author: xuyamei
* @date: 2024/7/23 16:39
* @param coachId
* @param dutyType ["OFF_DUTY","ON_DUTY"] ["全天休息","可约时间"]
* @param specialTimeInfoRequests
* @param userInfo
* @return: void
**/
public void createSpecialDate(String coachId,String dutyType,JSONObject specialTimeInfoRequests,DataUserInfo...userInfo){
setUp("API_createSpecialDate",userInfo);
JSONObject body = new JSONObject();
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("coachId", coachId);
// 如果不传可约时间,则快速新建
if (specialTimeInfoRequests.size() == 0){
// 可约时间类型
specialTimeInfoRequests.put("dutyType", dutyType);
// 设置特定日期
JSONArray selectedDates = new JSONArray();
selectedDates.add(TimeUtils.getBeforeDayDate(3));
specialTimeInfoRequests.put("selectedDates", selectedDates);
// 如果是可约时间非全天休息,则传可约时间段
if (dutyType.equals("ON_DUTY")){
// 时间段 00:00 ~ 23:59
JSONArray timePeriodInfos = new JSONArray();
JSONObject timeInfo = new JSONObject();
timeInfo.put("minuteOffset", 0);
timeInfo.put("spanMinutes", 1380);
timePeriodInfos.add(timeInfo);
specialTimeInfoRequests.put("timePeriodInfos", timePeriodInfos);
}
}
body.put("specialTimeInfoRequest", specialTimeInfoRequests);
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
}
/**
* @description: 删除特殊可约时间
* @author: xuyamei
* @date: 2024/7/23 16:39
* @param id 特约日期id
* @param userInfo
**/
public void deleteSpecialDate(String id,DataUserInfo...userInfo){
setUp("API_deleteSpecialDate",userInfo);
JSONObject body = new JSONObject();
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
JSONArray ids = new JSONArray();
ids.add(id);
body.put("ids", ids);
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
}
} }
package com.xiaomai.cases.polar.reserve.personal;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.cases.polar.reserve.ReserveTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.Terminal;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.lunar.reserve
* @Author: xuyamei
* @CreateTime: 2024-07-08 14:47
* @Description: 设置常规可约时间
* @Version: 1.0
*/
public class TestCreateNormalDate extends BaseTestImpl {
@Resource(name = "reserveTools")
ReserveTools reserveTools;
@BeforeClass
public void beforeTest(){
setTestInfo(ApiModule.Polar_Reserve,"API_createNormalDate", LoginAccount.GYM_PROD, Terminal.B,"xym");
super.beforeTest();
}
@Test(description = "设置周一至周日 统一一个时间点")
public void testCreateNormalDate(){
// 设置可约时间
JSONArray normalTimeInfoRequests = new JSONArray();
JSONObject infoRequests = new JSONObject();
JSONArray timePeriodInfos = new JSONArray();
// 三个时段 5:00-12:00 12:00-18:00 18:00-23:00
int[] minuteOffset = {300,720,1080};
int[] spanMinutes = {420,360,300};
for (int i = 0; i < 3; i++){
JSONObject timeInfo = new JSONObject();
timeInfo.put("minuteOffset",minuteOffset[i]);
timeInfo.put("spanMinutes",spanMinutes[i]);
timePeriodInfos.add(timeInfo);
}
infoRequests.put("timePeriodInfos",timePeriodInfos);
// 每星期
String[] weekdays = {"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"};
infoRequests.put("weekdays",weekdays);
normalTimeInfoRequests.add(infoRequests);
// 设置常规可约时间
reserveTools.createNormalDate(xmAppApi.getLoginInfo().getAdminId(),normalTimeInfoRequests);
JSONArray personalCoachTime = reserveTools.getPersonalCoachTime(xmAppApi.getLoginInfo().getAdminId(),"normalTimeVOS");
// 校验每周重复的可约时间
Assert.assertEquals(timePeriodInfos.toString(),personalCoachTime.getJSONObject(0).getJSONArray("timePeriodInfos").toString(),"每周重复的可约时间请求结果与实际结果不一样");
JSONArray weekDays = new JSONArray(Arrays.asList(weekdays));
Assert.assertEquals(weekDays.toString(),personalCoachTime.getJSONObject(0).getJSONArray("weekdays").toString(),"每周重复的周请求结果与实际结果不一样");
}
@Test(description = "周一至周日分开设置 ")
public void testCreateNormalDate1(){
// 设置可约时间
JSONArray normalTimeInfoRequests = new JSONArray();
String[] weekdays = {"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"};
for (int j = 0; j <weekdays.length;j++){
JSONObject infoRequests = new JSONObject();
JSONArray timePeriodInfos = new JSONArray();
// 三个时段 5:00-12:00 12:00-18:00 18:00-23:00
int[] minuteOffset = {300,720,1080};
int[] spanMinutes = {420,360,300};
for (int i = 0; i < 3; i++){
JSONObject timeInfo = new JSONObject();
timeInfo.put("minuteOffset",minuteOffset[i]);
timeInfo.put("spanMinutes",spanMinutes[i]);
timePeriodInfos.add(timeInfo);
}
infoRequests.put("timePeriodInfos",timePeriodInfos);
JSONArray arr = new JSONArray();
arr.add(weekdays[j]);
// 每星期
infoRequests.put("weekdays",arr);
normalTimeInfoRequests.add(infoRequests);
}
// 设置常规可约时间
reserveTools.createNormalDate(xmAppApi.getLoginInfo().getAdminId(),normalTimeInfoRequests);
JSONArray personalCoachTime = reserveTools.getPersonalCoachTime(xmAppApi.getLoginInfo().getAdminId(),"normalTimeVOS");
for (int i = 0; i < personalCoachTime.size(); i++){
// 校验每周重复的可约时间
Assert.assertEquals(normalTimeInfoRequests.getJSONObject(i).getJSONArray("timePeriodInfos").toString(),personalCoachTime.getJSONObject(i).getJSONArray("timePeriodInfos").toString(),"每周重复的可约时间请求结果与实际结果不一样");
Assert.assertEquals(normalTimeInfoRequests.getJSONObject(i).getJSONArray("weekdays").toString(),personalCoachTime.getJSONObject(i).getJSONArray("weekdays").toString(),"每周重复的周请求结果与实际结果不一样");
}
}
}
package com.xiaomai.cases.polar.reserve.personal;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.cases.polar.reserve.ReserveTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.TimeUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.course
* @Author: xuyamei
* @CreateTime: 2024-04-25 11:43
* @Description: 创建特定日期可约
* @Version: 1.0
*/
public class TestCreateSpecialDate extends BaseTestImpl {
@Resource(name = "reserveTools")
ReserveTools reserveTools;
@BeforeClass
public void beforeTest() {
setTestInfo(ApiModule.Polar_Reserve, "API_createSpecialDate", LoginAccount.GYM_PROD, Terminal.B, "xym");
super.beforeTest();
}
@Test(description = "设置全天休息")
public void testCreateSpecialDate_OFF() {
JSONObject body = new JSONObject();
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("coachId", xmAppApi.getLoginInfo().getAdminId());
// 可约时间类型
JSONObject specialTimeInfoRequest = new JSONObject();
specialTimeInfoRequest.put("dutyType", "OFF_DUTY"); // 全天休息
// 设置特定日期
JSONArray specialTimeInfoRequestArray = new JSONArray();
specialTimeInfoRequestArray.add(TimeUtils.getTodayTime());
specialTimeInfoRequest.put("selectedDates", specialTimeInfoRequestArray);
body.put("specialTimeInfoRequest", specialTimeInfoRequest);
xmAppApi.doRequest(RequestType.JSON,params,body.toString(),headers).assetsSuccess(true);
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// 设置全天休息完成后检查个人时间是否有这条数据
JSONArray specialTimeVOS = reserveTools.getPersonalCoachTime(xmAppApi.getLoginInfo().getAdminId(),"specialTimeVOS");
boolean flag = false;
for (int i = 0; i < specialTimeVOS.size(); i++){
JSONObject specialTimeVO = specialTimeVOS.getJSONObject(i);
if (specialTimeInfoRequestArray.getString(0).equals(specialTimeVO.getString("dutyDate"))){
flag = true;
Assert.assertEquals(specialTimeVO.getString("dutyType"),"-1","特殊日期类型错误");
}
}
Assert.assertTrue(flag,"设置特殊日期全天休息后没有找到相关数据");
}
@Test(description = "设置特定日期可约",priority = 1)
public void testCreateSpecialDate_ON() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
JSONObject specialTimeInfoRequest = new JSONObject();
// 可约时间类型
specialTimeInfoRequest.put("dutyType", "ON_DUTY");
// 设置特定日期
JSONArray selectedDates = new JSONArray();
selectedDates.add(TimeUtils.getTodayTime());
specialTimeInfoRequest.put("selectedDates", selectedDates);
// 如果是可约时间非全天休息,则传可约时间段
// 时间段 00:00 ~ 23:59
JSONArray timePeriodInfos = new JSONArray();
JSONObject timeInfo = new JSONObject();
timeInfo.put("minuteOffset", 0);
timeInfo.put("spanMinutes", 1380);
timePeriodInfos.add(timeInfo);
specialTimeInfoRequest.put("timePeriodInfos", timePeriodInfos);
reserveTools.createSpecialDate(xmAppApi.getLoginInfo().getAdminId(),"ON_DUTY",specialTimeInfoRequest);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// 设置特殊可约时间后检查个人私教时间是否有这条数据
JSONArray specialTimeVOS = reserveTools.getPersonalCoachTime(xmAppApi.getLoginInfo().getAdminId(),"specialTimeVOS");
boolean flag = false;
for (int i = 0; i < specialTimeVOS.size(); i++){
JSONObject specialTimeVO = specialTimeVOS.getJSONObject(i);
if (selectedDates.getString(0).equals(specialTimeVO.getString("dutyDate"))){
flag = true;
Assert.assertEquals(specialTimeVO.getString("dutyType"),"1","特殊日期类型错误");
Assert.assertTrue(specialTimeVO.getString("timePeriodInfos").equals(timePeriodInfos.toString()),"特殊日期可约时间段");
}
}
Assert.assertTrue(flag,"设置特殊日期全天休息后没有找到相关数据");
}
@Test(description = "删除特殊日期",priority = 2)
public void testDeleteSpecialDate() {
// 查询特殊可约时间列表
JSONArray specialTimeVOS = reserveTools.getPersonalCoachTime(xmAppApi.getLoginInfo().getAdminId(),"specialTimeVOS");
for (int i = 0; i < specialTimeVOS.size(); i++){
String id = specialTimeVOS.getJSONObject(i).getJSONArray("recordIds").getString(0);
// 删除查询到的特殊可约时间
reserveTools.deleteSpecialDate(id);
}
specialTimeVOS = reserveTools.getPersonalCoachTime(xmAppApi.getLoginInfo().getAdminId(),"specialTimeVOS");
Assert.assertEquals(specialTimeVOS.size(),0,"删除特殊日期后,特殊日期列表不为空");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment