wuyifan_branch
wyf 1 year ago
parent 74038d062a
commit 4bd9229d2c

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

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

@ -2,6 +2,7 @@ package com.softegg.freetogo.Demand.controller;
import com.softegg.freetogo.Demand.bean.Demands; import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService; import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -35,9 +36,10 @@ public class DemandsController {
String eDate, String eDate,
String sDay, String sDay,
String city, String city,
String message) { String message,
Integer status) {
Demands demand = new Demands(); 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); demandsService.add(demand);
return "添加成功"; return "添加成功";
} }
@ -63,14 +65,21 @@ public class DemandsController {
String eDate, String eDate,
String sDay, String sDay,
String city, String city,
String message) { String message,
Integer status) {
Demands demand = demandsService.getDemandById(id); 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); demandsService.update(demand);
return "更新成功"; 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.setPhone(phone);
demand.setTouristGender(tGender); demand.setTouristGender(tGender);
demand.setNickname(nkn); demand.setNickname(nkn);
@ -80,6 +89,7 @@ public class DemandsController {
demand.setSumDay(sDay); demand.setSumDay(sDay);
demand.setCity(city); demand.setCity(city);
demand.setMessage(message); demand.setMessage(message);
demand.setStatus(status);
// demand.setGuideGender(gGender); // demand.setGuideGender(gGender);
} }
} }

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

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

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

@ -1,13 +1,8 @@
package com.softegg.freetogo.SendDemand.controller; package com.softegg.freetogo.SendDemand.controller;
import com.softegg.freetogo.SendDemand.service.SendDemandService; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
/** /**
@ -28,14 +23,22 @@ public class SendDemandController {
* @description: * @description:
* @param: map * @param: map
* @return: java.lang.String * @return: java.lang.String
* @author: zhanglinhao * @author: wuyifan
* @date: 2024/5/9 22:45 * @date: 2024/5/10 22:45
*/ */
@PostMapping("register") @PostMapping("register")
public int SendDemand(@RequestBody Map<String, Object> map) { public String SendDemand(@RequestBody Map<String, Object> map) {
return switch (sendDemandService.sendnewDemandAccount(map.get("city").toString(), map.get("phone").toString())){ return switch (sendDemandService.sendnewDemandAccount(map.get("city").toString(), map.get("phone").toString(), map.get("time").toString(), (String) map.get("remark"))){
case 1005 -> 1;//需求发送成功 case 1005 -> "1";//需求发送成功
default -> 0; 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 @Service
public interface SendDemandService { 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; 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: * @description:
* @author:wuyifan * @author:wuyifan
@ -16,6 +22,7 @@ import org.springframework.stereotype.Component;
public class SendDemandServiceImpl implements SendDemandService { public class SendDemandServiceImpl implements SendDemandService {
@Autowired @Autowired
DemandsService demandsService; DemandsService demandsService;
@Autowired
UsersService usersService; UsersService usersService;
/** /**
* @description: * @description:
@ -26,14 +33,42 @@ public class SendDemandServiceImpl implements SendDemandService {
*/ */
@Override @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(); Demands demand = new Demands();
Users user = usersService.getUserByPhone(phone); Users user = usersService.getUserByPhone(phone);
demand.setPhone(phone); demand.setPhone(phone);
demand.setCity(city); demand.setCity(city);
demand.setTouristGender(user.isGender()); demand.setTouristGender(user.isGender());
demand.setNickname(user.getNickname()); 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); 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 com.softegg.freetogo.SendGuideService.service.SendGuideServiceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody; import com.softegg.freetogo.User.service.UsersService;
import org.springframework.web.bind.annotation.RequestMapping; import com.softegg.freetogo.User.bean.Users;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
@ -18,9 +17,10 @@ import java.util.Map;
//@CrossOrigin(origins = "*") //@CrossOrigin(origins = "*")
@RequestMapping("/SendGuideService") @RequestMapping("/SendGuideService")
public class SendGuideServiceController { public class SendGuideServiceController {
@Autowired @Autowired
SendGuideServiceService sendGuideServiceService; SendGuideServiceService sendGuideServiceService;
@Autowired
UsersService usersService;
/** /**
* @description: * @description:
@ -31,9 +31,24 @@ public class SendGuideServiceController {
*/ */
@PostMapping("register") @PostMapping("register")
public int SendDemand(@RequestBody Map<String, Object> map) { public int SendDemand(@RequestBody Map<String, Object> map) {
return switch (sendGuideServiceService.sendnewGuideServiceAccount(map.get("city").toString(), map.get("phone").toString())){ String phone = map.get("phone").toString();
case 1005 -> 1;//需求发送成功 Users user = usersService.getUserByPhone(phone);
default -> 0; 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 @Service
public interface SendGuideServiceService { 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; 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: * @description:
* @author:wuyifan * @author:wuyifan
@ -16,6 +22,7 @@ import org.springframework.stereotype.Component;
public class SendGuideServiceServiceImpl implements SendGuideServiceService { public class SendGuideServiceServiceImpl implements SendGuideServiceService {
@Autowired @Autowired
GuideServiceService guideServiceService; GuideServiceService guideServiceService;
@Autowired
UsersService usersService; UsersService usersService;
/** /**
* @description: * @description:
@ -24,15 +31,47 @@ public class SendGuideServiceServiceImpl implements SendGuideServiceService {
* @author: wuyifan * @author: wuyifan
* @date: 2024/5/10 23:25 * @date: 2024/5/10 23:25
*/ */
@Override @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(); GuideService guideService = new GuideService();
Users user = usersService.getUserByPhone(phone); Users user = usersService.getUserByPhone(phone);
guideService.setPhone(phone); guideService.setPhone(phone);
guideService.setCity(city); guideService.setCity(city);
guideService.setGuideGender(user.isGender()); guideService.setGuideGender(user.isGender());
guideService.setNickname(user.getNickname()); 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); guideServiceService.add(guideService);
return 1006;//添加导游服务成功 return 1006;//添加导游服务成功
} }

Loading…
Cancel
Save