wuyifan_branch
wyf 1 year ago
parent 74038d062a
commit 4bd9229d2c

@ -1,6 +1,7 @@
package com.softegg.freetogo.Demand.Dao;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.data.jpa.repository.JpaRepository;
/**
@ -9,5 +10,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
* @date:2024/5/10 19:50
*/
public interface DemandsRepository extends JpaRepository<Demands, Integer> {
Demands findByPhone(String phone);
}

@ -23,25 +23,23 @@ public class Demands {
private Integer uid;
@Column
private String phone;//游客手机号码
@Column
@Column(name="tourist_gender")
private boolean touristGender;//游客性别 ture:male, false:female
@Column
private String nickname;//发布需求的游客昵称信息
@Column
@Column(name="create_time")
private String createTime;//需求发布时间
@Column
@Column(name="departure_date")
private String departureDate;//游客需求起始日期
@Column
@Column(name="end_date")
private String endDate;//游客需求结束日期
@Column
@Column(name="sum_day")
private String sumDay;//游客旅游总天数
@Column
private String city;//发布需求的目的城市
@Column
private String message;//需求备注内容
// @Column
// private boolean guideGender;//希望导游性别
// @Column
// private int status;
@Column
private Integer status;//游客需求状态 0未匹配 1已匹配 2已完成
}

@ -2,6 +2,7 @@ package com.softegg.freetogo.Demand.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -35,9 +36,10 @@ public class DemandsController {
String eDate,
String sDay,
String city,
String message) {
String message,
Integer status) {
Demands demand = new Demands();
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, city, message, demand);
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, city, message,status , demand);
demandsService.add(demand);
return "添加成功";
}
@ -63,14 +65,21 @@ public class DemandsController {
String eDate,
String sDay,
String city,
String message) {
String message,
Integer status) {
Demands demand = demandsService.getDemandById(id);
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, city, message, demand);
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, city, message, status, demand);
demandsService.update(demand);
return "更新成功";
}
private void setDemands(String phone, boolean tGender, String nkn, String ct, String dDate, String eDate, String sDay, String city, String message, Demands demand) {
@GetMapping("getByPhone")
public Demands getByPhone(String phone) {
System.out.println("根据手机号获取游客需求信息:" + phone);
return demandsService.getDemandsByPhone(phone);
}
private void setDemands(String phone, boolean tGender, String nkn, String ct, String dDate, String eDate, String sDay, String city, String message, Integer status, Demands demand) {
demand.setPhone(phone);
demand.setTouristGender(tGender);
demand.setNickname(nkn);
@ -80,6 +89,7 @@ public class DemandsController {
demand.setSumDay(sDay);
demand.setCity(city);
demand.setMessage(message);
demand.setStatus(status);
// demand.setGuideGender(gGender);
}
}

@ -1,6 +1,7 @@
package com.softegg.freetogo.Demand.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.User.bean.Users;
import java.util.List;
@ -20,4 +21,5 @@ public interface DemandsService {
void update(Demands demand);//更新需求信息
Demands getDemandsByPhone(String phone);//根据手机号获得对应游客用户的服务
}

@ -2,6 +2,7 @@ package com.softegg.freetogo.Demand.service;
import com.softegg.freetogo.Demand.Dao.DemandsRepository;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -54,7 +55,7 @@ public class DemandsServiceImpl implements DemandsService {
}
/**
* @description: id
* @description:
* @param: id
* @return: com.softegg.freetogo.Demand.Bean.Demands
* @author: wuyifan
@ -76,17 +77,16 @@ public class DemandsServiceImpl implements DemandsService {
System.out.println("更新成功");
}
// /**
// * @description: 判断相同需求是否已经入库
// * @param: id
// * @return: boolean
// * @author: wuyifan
// * @date: 2024/5/10 20:05
// */
// public boolean isRegister(int id) {
// Demands demand = DemandsRepository.findById(id);
// System.out.println(demand);
// return users != null;
// }
/**
* @description:
* @param: phone
* @return: com.softegg.freetogo.Demand.Bean.Demands
* @author: wuyifan
* @date: 2024/5/15 20:18
*/
public Demands getDemandsByPhone(String phone) {
return DemandsRepository.findByPhone(phone);
}
}

@ -23,26 +23,22 @@ public class GuideService {
private Integer uid;
@Column
private String phone;//导游手机号码
@Column
@Column(name="guide_gender")
private boolean guideGender;//导游性别 ture:male, false:female
@Column
private String nickname;//发布需求的导游昵称信息
@Column
@Column(name="create_time")
private String createTime;//服务发布时间
@Column
@Column(name="departure_date")
private String departureDate;//导游服务起始日期
@Column
@Column(name="end_date")
private String endDate;//导游服务结束日期
@Column
@Column(name="sum_day")
private String sumDay;//导游服务总天数
@Column
private String city;//导游服务的目的城市
@Column
private String message;//导游服务备注内容
// @Column
// private boolean guideGender;//希望导游性别
// @Column
// private int status;
}
@Column
private Integer status;//导游服务状态 0未匹配 1已匹配 2已完成
}

@ -33,9 +33,10 @@ public class GuideServiceController {
String eDate,
String sDay,
String city,
String message) {
String message,
Integer status) {
GuideService guideService = new GuideService();
setDemands(phone, gGender, nkn, ct, dDate, eDate, sDay, city, message, guideService);
setDemands(phone, gGender, nkn, ct, dDate, eDate, sDay, city, message, status, guideService);
guideServiceService.add(guideService);
return "添加成功";
}
@ -61,23 +62,25 @@ public class GuideServiceController {
String eDate,
String sDay,
String city,
String message) {
String message,
Integer status) {
GuideService guideService = guideServiceService.getGuideServiceById(id);
setDemands(phone, gGender, nkn, ct, dDate, eDate, sDay, city, message, guideService);
setDemands(phone, gGender, nkn, ct, dDate, eDate, sDay, city, message, status, guideService);
guideServiceService.update(guideService);
return "更新成功";
}
private void setDemands(String phone, boolean gGender, String nkn, String ct, String dDate, String eDate, String sDay, String city, String message, GuideService demand) {
demand.setPhone(phone);
demand.setGuideGender(gGender);
demand.setNickname(nkn);
demand.setCreateTime(ct);
demand.setDepartureDate(dDate);
demand.setEndDate(eDate);
demand.setSumDay(sDay);
demand.setCity(city);
demand.setMessage(message);
private void setDemands(String phone, boolean gGender, String nkn, String ct, String dDate, String eDate, String sDay, String city, String message,Integer status, GuideService guideservice) {
guideservice.setPhone(phone);
guideservice.setGuideGender(gGender);
guideservice.setNickname(nkn);
guideservice.setCreateTime(ct);
guideservice.setDepartureDate(dDate);
guideservice.setEndDate(eDate);
guideservice.setSumDay(sDay);
guideservice.setCity(city);
guideservice.setMessage(message);
guideservice.setStatus(status);
// demand.setGuideGender(gGender);
}
}

@ -1,13 +1,8 @@
package com.softegg.freetogo.SendDemand.controller;
import com.softegg.freetogo.SendDemand.service.SendDemandService;
import com.softegg.freetogo.Demand.Dao.DemandsRepository;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
@ -28,14 +23,22 @@ public class SendDemandController {
* @description:
* @param: map
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/9 22:45
* @author: wuyifan
* @date: 2024/5/10 22:45
*/
@PostMapping("register")
public int SendDemand(@RequestBody Map<String, Object> map) {
return switch (sendDemandService.sendnewDemandAccount(map.get("city").toString(), map.get("phone").toString())){
case 1005 -> 1;//需求发送成功
default -> 0;
public String SendDemand(@RequestBody Map<String, Object> map) {
return switch (sendDemandService.sendnewDemandAccount(map.get("city").toString(), map.get("phone").toString(), map.get("time").toString(), (String) map.get("remark"))){
case 1005 -> "1";//需求发送成功
default -> "0";
};
}
// @GetMapping("register")
// public String SendDemand(String city,String phone) {
// return switch (sendDemandService.sendnewDemandAccount(city,phone)){
// case 1005 -> "1";//需求发送成功
// default -> "0";
// };
// }
}

@ -9,5 +9,5 @@ import org.springframework.stereotype.Service;
*/
@Service
public interface SendDemandService {
int sendnewDemandAccount(String city, String phone);
int sendnewDemandAccount(String city, String phone, String date,String message);
}

@ -7,6 +7,12 @@ import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
/**
* @description:
* @author:wuyifan
@ -16,6 +22,7 @@ import org.springframework.stereotype.Component;
public class SendDemandServiceImpl implements SendDemandService {
@Autowired
DemandsService demandsService;
@Autowired
UsersService usersService;
/**
* @description:
@ -26,14 +33,42 @@ public class SendDemandServiceImpl implements SendDemandService {
*/
@Override
public int sendnewDemandAccount(String city, String phone) {
public int sendnewDemandAccount(String city, String phone ,String date,String message) {
LocalDateTime currentDateTime = LocalDateTime.now();
//对获取的date信息进行处理
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDateTime = currentDateTime.format(formatter1);
date = date.replace("[", "");
date = date.replace("]", "");
String[] parts = date.split(",");
String dDate = parts[0];
String eDate = parts[1];
//获取整个导游服务的总天数
eDate = eDate.trim();
// ZonedDateTime zoneddDate = ZonedDateTime.parse(dDate);
// ZonedDateTime zonedeDate = ZonedDateTime.parse(eDate);
// LocalDate startDate = zoneddDate.toLocalDate();
// LocalDate endDate = zonedeDate.toLocalDate();
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(dDate, formatter2);
LocalDate endDate = LocalDate.parse(eDate, formatter2);
String departureTime = startDate.format(formatter2);
String endTime = endDate.format(formatter2);
long daysBetween = ChronoUnit.DAYS.between(startDate, endDate) + 1;
//根据收到的消息,初始化游客需求内容
Demands demand = new Demands();
Users user = usersService.getUserByPhone(phone);
demand.setPhone(phone);
demand.setCity(city);
demand.setTouristGender(user.isGender());
demand.setNickname(user.getNickname());
demand.setCreateTime(formattedDateTime);
demand.setDepartureDate(departureTime);
demand.setEndDate(endTime);
demand.setSumDay(String.valueOf(daysBetween));
demand.setMessage(message);
demand.setStatus(0);
demandsService.add(demand);
return 1005;//添加需求成功
return 1005;//添加游客需求成功
}
}

@ -2,10 +2,9 @@ package com.softegg.freetogo.SendGuideService.controller;
import com.softegg.freetogo.SendGuideService.service.SendGuideServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.softegg.freetogo.User.service.UsersService;
import com.softegg.freetogo.User.bean.Users;
import java.util.Map;
@ -18,9 +17,10 @@ import java.util.Map;
//@CrossOrigin(origins = "*")
@RequestMapping("/SendGuideService")
public class SendGuideServiceController {
@Autowired
SendGuideServiceService sendGuideServiceService;
@Autowired
UsersService usersService;
/**
* @description:
@ -31,9 +31,24 @@ public class SendGuideServiceController {
*/
@PostMapping("register")
public int SendDemand(@RequestBody Map<String, Object> map) {
return switch (sendGuideServiceService.sendnewGuideServiceAccount(map.get("city").toString(), map.get("phone").toString())){
case 1005 -> 1;//需求发送成功
default -> 0;
};
String phone = map.get("phone").toString();
Users user = usersService.getUserByPhone(phone);
if (user.isMembertype()) {
return switch (sendGuideServiceService.sendnewGuideServiceAccount(map.get("city").toString(), map.get("phone").toString(), map.get("time").toString(), (String) map.get("remark"))) {
case 1005 -> 1;//服务发送成功
default -> 0;
};
}
else{
return 2;//用户非导游
}
}
// @GetMapping("register")
// public String SendDemand(String city,String phone) {
// return switch (sendGuideServiceService.sendnewGuideServiceAccount(city,phone)){
// case 1006 -> "1";//需求发送成功
// default -> "0";
// };
// }
}

@ -10,5 +10,5 @@ import org.springframework.stereotype.Service;
@Service
public interface SendGuideServiceService {
int sendnewGuideServiceAccount(String city, String phone);
int sendnewGuideServiceAccount(String city, String phone, String date, String message);
}

@ -7,6 +7,12 @@ import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
//import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
/**
* @description:
* @author:wuyifan
@ -16,6 +22,7 @@ import org.springframework.stereotype.Component;
public class SendGuideServiceServiceImpl implements SendGuideServiceService {
@Autowired
GuideServiceService guideServiceService;
@Autowired
UsersService usersService;
/**
* @description:
@ -24,15 +31,47 @@ public class SendGuideServiceServiceImpl implements SendGuideServiceService {
* @author: wuyifan
* @date: 2024/5/10 23:25
*/
@Override
public int sendnewGuideServiceAccount(String city, String phone) {
public int sendnewGuideServiceAccount(String city, String phone, String date,String message) {
LocalDateTime currentDateTime = LocalDateTime.now();
//对获取的date信息进行处理
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDateTime = currentDateTime.format(formatter1);
date = date.replace("[", "");
date = date.replace("]", "");
String[] parts = date.split(",");
String dDate = parts[0];
String eDate = parts[1];
//获取整个导游服务的总天数
System.out.println(dDate);
System.out.println(eDate);
dDate = dDate.trim();
eDate = eDate.trim();
System.out.println(dDate);
System.out.println(eDate);
// ZonedDateTime zoneddDate = ZonedDateTime.parse(dDate);
// ZonedDateTime zonedeDate = ZonedDateTime.parse(eDate);
// LocalDate startDate = zoneddDate.toLocalDate();
// LocalDate endDate = zonedeDate.toLocalDate();
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(dDate, formatter2);
LocalDate endDate = LocalDate.parse(eDate, formatter2);
String departureTime = startDate.format(formatter2);
String endTime = endDate.format(formatter2);
long daysBetween = ChronoUnit.DAYS.between(startDate, endDate) + 1;
//根据收到的消息,初始化导游服务内容
GuideService guideService = new GuideService();
Users user = usersService.getUserByPhone(phone);
guideService.setPhone(phone);
guideService.setCity(city);
guideService.setGuideGender(user.isGender());
guideService.setNickname(user.getNickname());
guideService.setCreateTime(formattedDateTime);
guideService.setDepartureDate(departureTime);
guideService.setEndDate(endTime);
guideService.setSumDay(String.valueOf(daysBetween));
guideService.setMessage(message);
guideService.setStatus(0);
guideServiceService.add(guideService);
return 1006;//添加导游服务成功
}

Loading…
Cancel
Save