package com.kidgrow.oprationcenter.service.impl;
|
|
import com.kidgrow.common.service.impl.SuperServiceImpl;
|
import com.kidgrow.oprationcenter.mapper.AppointmentTimeMapper;
|
import com.kidgrow.oprationcenter.model.AppointmentTime;
|
import com.kidgrow.oprationcenter.service.IAppointmentTimeService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.collections4.MapUtils;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
|
*
|
* @Description: <br>
|
* @Project: <br>
|
* @CreateDate: Created in 2021/3/1 14:33 <br>
|
* @Author: <a href="78125310@kidgrow.com">dougang</a>
|
*/
|
@Slf4j
|
@Service
|
public class AppointmentTimeServiceImpl extends SuperServiceImpl<AppointmentTimeMapper, AppointmentTime> implements IAppointmentTimeService {
|
|
/**
|
* 保存
|
*
|
* @param map
|
* @return
|
*/
|
@Override
|
public boolean save(Map<String, Object> map) {
|
AppointmentTime time = null;
|
boolean flag = false;
|
|
String[] items = (String[]) MapUtils.getObject(map, "list");
|
String id = MapUtils.getString(map, "id");
|
|
baseMapper.delByAdvisoryId(Long.parseLong(id));
|
|
for (String item : items) {
|
String[] tmp = item.split("_");
|
|
time = new AppointmentTime();
|
time.setAdvisoryId(Long.parseLong(id));
|
time.setName(tmp[0]);
|
if ("1".equals(tmp[1])) {
|
time.setMorning(1);
|
} else if ("2".equals(tmp[1])) {
|
time.setAfternoon(1);
|
} else if ("3".equals(tmp[1])) {
|
time.setEvening(1);
|
}
|
int insert = baseMapper.insert(time);
|
if (insert == 0) {
|
flag = true;
|
break;
|
}
|
}
|
|
return flag ? false : true;
|
}
|
|
/**
|
* 查询
|
* @param id
|
* @return
|
*/
|
@Override
|
public String queryByAdvisoryId(Long id) {
|
StringBuffer result = new StringBuffer();
|
List<AppointmentTime> appointmentTimes = baseMapper.queryByAdvisoryId(id);
|
|
if (appointmentTimes.size() > 0) {
|
for (AppointmentTime app : appointmentTimes) {
|
if (app.getMorning() == 1) {
|
result.append(app.getName() + "_1");
|
result.append(",");
|
} else if (app.getAfternoon() == 1) {
|
result.append(app.getName() + "_2");
|
result.append(",");
|
} else if (app.getEvening() == 1) {
|
result.append(app.getName() + "_3");
|
result.append(",");
|
}
|
}
|
|
if (result.length() > 0) {
|
result.substring(0, result.length() - 1);
|
}
|
}
|
return result.toString();
|
}
|
|
@Override
|
public List<AppointmentTime> findByAdvisoryId(Long id) {
|
return baseMapper.queryByAdvisoryId(id);
|
}
|
|
@Override
|
public int delByAdvisoryId(Long id) {
|
return baseMapper.delByAdvisoryId(id);
|
}
|
}
|