Commit 2ef6ce38 by jianan

日程接口统一请求和响应格式

parent 22f3f6a2
......@@ -22,11 +22,16 @@ import com.yd.api.practitioner.vo.rank.PractitionerRankRequestVO;
import com.yd.api.practitioner.vo.rank.PractitionerRankResponseVO;
import com.yd.api.practitioner.vo.recruit.*;
import com.yd.api.practitioner.vo.salestarget.*;
import com.yd.api.practitioner.vo.sechedule.AddScheduleTrackRequestVO;
import com.yd.api.practitioner.vo.sechedule.AddScheduleTrackResponseVO;
import com.yd.api.practitioner.vo.sechedule.QueryScheduleTrackListRequestVO;
import com.yd.api.practitioner.vo.sechedule.QueryScheduleTrackListResponseVO;
import com.yd.api.practitioner.vo.setting.*;
import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryRequestVO;
import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryResponseVO;
import com.yd.api.result.JsonResult;
import com.yd.dal.entity.practitioner.ScheduleTrack;
import org.apache.commons.codec.net.QCodec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
......@@ -506,27 +511,32 @@ public class PractitionerController {
result.setData(responseVO);
return result;
}
/**
* 新建日程
* @param schedule
* @param requestVO
* @return
*/
@RequestMapping("/addScheduleTrack")
public Object addScheduleTrack(@RequestBody ScheduleTrack schedule){
JsonResult result = scheduleTrackService.insert(schedule);
public Object addScheduleTrack(@RequestBody AddScheduleTrackRequestVO requestVO){
JsonResult result = new JsonResult();
AddScheduleTrackResponseVO responseVO = scheduleTrackService.insert(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
/**
* 根据经纪人id查询日程列表
* @param params
* @param requestVO
* @return
*/
@RequestMapping("/queryScheduleTrackList")
public Object queryScheduleTrackList(@RequestBody Map<String, String> params){
Long practitionerId = Long.parseLong(params.get("practitionerId")) ;
String trackDate = (String) params.get("trackDate");
JsonResult result = scheduleTrackService.queryScheduleTrackList(practitionerId, trackDate);
public Object queryScheduleTrackList(@RequestBody QueryScheduleTrackListRequestVO requestVO){
JsonResult result = new JsonResult();
QueryScheduleTrackListResponseVO responseVO = scheduleTrackService.queryScheduleTrackList(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
......
package com.yd.api.practitioner.service;
import com.yd.api.result.JsonResult;
import com.yd.dal.entity.practitioner.ScheduleTrack;
import com.yd.api.practitioner.vo.sechedule.AddScheduleTrackRequestVO;
import com.yd.api.practitioner.vo.sechedule.AddScheduleTrackResponseVO;
import com.yd.api.practitioner.vo.sechedule.QueryScheduleTrackListRequestVO;
import com.yd.api.practitioner.vo.sechedule.QueryScheduleTrackListResponseVO;
public interface ScheduleTrackService {
JsonResult insert(ScheduleTrack schedule);
AddScheduleTrackResponseVO insert(AddScheduleTrackRequestVO requestVO);
JsonResult queryScheduleTrackList(Long practitionerId, String trackDate);
QueryScheduleTrackListResponseVO queryScheduleTrackList(QueryScheduleTrackListRequestVO requestVO);
}
package com.yd.api.practitioner.service.impl;
import com.yd.api.practitioner.service.ScheduleTrackService;
import com.yd.api.practitioner.vo.organization.OrganizationQueryResponseVO;
import com.yd.api.practitioner.vo.opportunity.OwnOpportunityRecordSaveResponseVO;
import com.yd.api.practitioner.vo.sechedule.*;
import com.yd.api.result.CommonResult;
import com.yd.api.result.JsonResult;
import com.yd.dal.entity.customer.AclPractitionerPotentialAssignedTrack;
......@@ -10,12 +11,12 @@ import com.yd.dal.entity.meta.MdDropOptions;
import com.yd.dal.entity.practitioner.ScheduleTrack;
import com.yd.dal.mapper.marketing.ScheduleTrackMapper;
import com.yd.dal.service.customer.AclPractitionerPotentialAssignedTrackDALService;
import com.yd.dal.service.customer.AclPractitionerSubordinateSystemDALService;
import com.yd.dal.service.marketing.MktLeadsAssignedTrackDALService;
import com.yd.dal.service.meta.MdDropOptionsDALService;
import com.yd.util.CommonUtil;
import com.yd.util.config.ZHBErrorConfig;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -33,9 +34,12 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
private MktLeadsAssignedTrackDALService mktLeadsAssignedTrackDALService;
@Override
public JsonResult insert(ScheduleTrack schedule) {
JsonResult result = new JsonResult();
result.setSuccess(false);
public AddScheduleTrackResponseVO insert(AddScheduleTrackRequestVO requestVO) {
// 响应实体
AddScheduleTrackResponseVO resp = new AddScheduleTrackResponseVO();
// 数据库实体
ScheduleTrack schedule = new ScheduleTrack();
BeanUtils.copyProperties(requestVO, schedule);
try {
String taskTimeFrom = schedule.getTaskTimeFrom();
String taskTimeEnd = schedule.getTaskTimeEnd();
......@@ -45,12 +49,12 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
if (!CommonUtil.isNullOrBlank(taskTimeFrom) && !CommonUtil.isNullOrBlank(taskTimeEnd)) {
int count = scheduleTrackMapper.checkTimePeriodConflict(taskTimeFrom, taskTimeEnd, practitionerId);
if (count > 0) {
result.setMessage(ZHBErrorConfig.getErrorInfo("830020"));
return result;
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("830020")));
return resp;
}
} else {
result.setMessage("taskTimeFrom,taskTimeEnd不能为空");
return result;
resp.setCommonResult(new CommonResult(true, "taskTimeFrom,taskTimeEnd不能为空"));
return resp;
}
Map<Long, MdDropOptions> taskTypeMap = this.getScheduleTaskTypeMap();
......@@ -74,13 +78,12 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
if (2 == taskType && null != referPotentialId) {
this.insertPotentialAssignedTrack(schedule);
}
result.setSuccess(true);
result.setMessage(ZHBErrorConfig.getErrorInfo("800000"));
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
} catch (Exception e) {
e.printStackTrace();
result.setMessage(e.getMessage());
resp.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("800001")));
}
return result;
return resp;
}
private void insertOpportunityRecord(ScheduleTrack schedule) {
......@@ -136,33 +139,36 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
}
@Override
public JsonResult queryScheduleTrackList(Long practitionerId, String trackDate) {
JsonResult result = new JsonResult();
result.setSuccess(false);
public QueryScheduleTrackListResponseVO queryScheduleTrackList(QueryScheduleTrackListRequestVO requestVO) {
QueryScheduleTrackListResponseVO resp = new QueryScheduleTrackListResponseVO();
Long practitionerId = requestVO.getPractitionerId();
String trackDate = requestVO.getTrackDate();
if (StringUtils.isEmpty(trackDate) || null == practitionerId) {
result.setMessage("经纪人id和查询时间不能为空");
return result;
resp.setCommonResult(new CommonResult(true, "经纪人id和查询时间不能为空"));
return resp;
}
List<ScheduleTrack> showList = new ArrayList<>();
List<ScheduleTrackVO> showList = new ArrayList<>();
try {
List<ScheduleTrack> dataList = scheduleTrackMapper.queryScheduleTrackList(practitionerId);
Map<Long, MdDropOptions> taskTypeMap = this.getScheduleTaskTypeMap();
String optionName = null;
for (ScheduleTrack schedule: dataList) {
if (this.checkFixedDay(trackDate, schedule)) {
ScheduleTrackVO scheduleTrackVO = new ScheduleTrackVO();
BeanUtils.copyProperties(schedule, scheduleTrackVO);
optionName = taskTypeMap.get(schedule.getMdDropOptionId()).getDropOptionName();
schedule.setMdDropOptionName(optionName);
showList.add(schedule);
scheduleTrackVO.setMdDropOptionName(optionName);
showList.add(scheduleTrackVO);
}
}
result.setData(showList);
result.setSuccess(true);
result.setMessage(ZHBErrorConfig.getErrorInfo("800000"));
resp.setDataList(showList);
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
} catch (Exception e) {
e.printStackTrace();
result.setMessage(e.getMessage());
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800001")));
}
return result;
return resp;
}
private Map<Long, MdDropOptions> getScheduleTaskTypeMap() {
......
package com.yd.api.practitioner.vo.sechedule;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class AddScheduleTrackRequestVO {
private Long practitionerId;
private String notice;
private Integer taskType;
private Long referLeadsId;
private Long referPotentialId;
private Integer taskImportantTag;
private Integer isActive;
private String taskTimeFrom;
private String taskTimeEnd;
private Integer taskRoutineAtweek7;
private Integer taskRoutineAtweek6;
private Integer taskRoutineAtweek5;
private Integer taskRoutineAtweek4;
private Integer taskRoutineAtweek3;
private Integer taskRoutineAtweek2;
private Integer taskRoutineAtweek1;
private Long customerId;
private Long mdDropOptionId;
private String mdDropOptionName;
private Integer trackScore;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date trackTime;
}
package com.yd.api.practitioner.vo.sechedule;
import com.yd.api.result.CommonResult;
import lombok.Data;
@Data
public class AddScheduleTrackResponseVO {
private CommonResult commonResult;
}
package com.yd.api.practitioner.vo.sechedule;
import lombok.Data;
@Data
public class QueryScheduleTrackListRequestVO {
private Long practitionerId;
private String trackDate;
}
package com.yd.api.practitioner.vo.sechedule;
import com.yd.api.result.CommonResult;
import lombok.Data;
import java.util.List;
@Data
public class QueryScheduleTrackListResponseVO {
private List<ScheduleTrackVO> dataList;
private CommonResult commonResult;
}
package com.yd.api.practitioner.vo.sechedule;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class ScheduleTrackVO {
private Long id;
private Long practitionerId;
private String notice;
private Integer taskType;
private Long referLeadsId;
private Long referPotentialId;
private Integer taskImportantTag;
private Integer isActive;
private String taskTimeFrom;
private String taskTimeEnd;
private Integer taskRoutineAtweek7;
private Integer taskRoutineAtweek6;
private Integer taskRoutineAtweek5;
private Integer taskRoutineAtweek4;
private Integer taskRoutineAtweek3;
private Integer taskRoutineAtweek2;
private Integer taskRoutineAtweek1;
private Long customerId;
private String mdDropOptionName;
private Integer trackScore;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date trackTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createdAt;
private Long createdBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updatedAt;
private Long updatedBy;
private Integer creatorType;
private Integer updatorType;
}
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