新增发送导游服务 #13

Open
p4hc6qtoi wants to merge 7 commits from wuyifan_branch into develop

@ -1,5 +1,6 @@
package com.softegg.freetogo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -21,5 +22,6 @@ public class Configurer implements WebMvcConfigurer {
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.exposedHeaders("*");
// registry.addMapping("/**").allowedOrigins("http://106.52.218.118:8090");
}
}

@ -3,11 +3,17 @@ package com.softegg.freetogo.Demand.Dao;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @description:Jpa
* @author:wuyifan
* @date:2024/5/10 19:50
*/
public interface DemandsRepository extends JpaRepository<Demands, Integer> {
List<Demands> findByPhone(String phone);
List<Demands> findByCity(String city);
List<Demands> findByProvince(String province);
}

@ -6,13 +6,15 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
/**
* @description:demand
* @author:wuyifan
* @date:2024/5/10 11:36
*/
@Entity
@Table(name="demands")
@Table(name = "demands")
@Setter
@Getter
@NoArgsConstructor
@ -20,28 +22,32 @@ import lombok.Setter;
public class Demands {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer uid;
private Integer did;
@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 province;//发布需求的目的省份
@Column
private String city;//发布需求的目的城市
@Column
private String message;//需求备注内容
// @Column
// private boolean guideGender;//希望导游性别
// @Column
// private int status;
@Column
private Integer status;//游客需求状态 0未匹配 1请求匹配 2已完成匹配 3已完成所有服务
@Column
private Integer guideServiceId;//游客需求最终匹配到的导游服务id
@ElementCollection
@Column(name = "guide_service_id_list")
private List<Integer> guideServiceIdList;//游客需求申请匹配到的导游服务id
}

@ -3,11 +3,11 @@ package com.softegg.freetogo.Demand.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* @description:Demand
@ -21,9 +21,11 @@ public class DemandsController {
@Autowired
private DemandsService demandsService;
@GetMapping("findAll")
public List<Demands> findAll() {
return demandsService.findAll();
@GetMapping("findAllRandom")
public List<Demands> findAllRandom() {
List<Demands> dlist = demandsService.findAll();
Collections.shuffle(dlist);
return dlist;
}
@GetMapping("add")
@ -34,18 +36,23 @@ public class DemandsController {
String dDate,
String eDate,
String sDay,
String province,
String city,
String message) {
String message,
Integer status,
Integer guideServiceId,
List<Integer> guideServiceIdList) {
Demands demand = new Demands();
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, city, message, demand);
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, province, city, message, status, demand, guideServiceId, guideServiceIdList);
demandsService.add(demand);
return "添加成功";
}
@GetMapping("delbyid")
public String delById(int id) {
demandsService.deleteById(id);
return "删除成功";
@PostMapping("delbyid")
public int delById(@RequestBody Map<String, Object> map) {
int did = Integer.parseInt(map.get("did").toString());
demandsService.deleteById(did);
return 1;
}
@GetMapping("findbyid")
@ -62,15 +69,25 @@ public class DemandsController {
String dDate,
String eDate,
String sDay,
String province,
String city,
String message) {
String message,
Integer status,
Integer guideServiceId,
List<Integer> guideServiceIdList) {
Demands demand = demandsService.getDemandById(id);
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, city, message, demand);
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, province, city, message, status, demand, guideServiceId, guideServiceIdList);
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 List<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 province, String city, String message, Integer status, Demands demand,Integer guideServiceId,List<Integer> guideServiceIdList) {
demand.setPhone(phone);
demand.setTouristGender(tGender);
demand.setNickname(nkn);
@ -78,8 +95,13 @@ public class DemandsController {
demand.setDepartureDate(dDate);
demand.setEndDate(eDate);
demand.setSumDay(sDay);
demand.setProvince(province);
demand.setCity(city);
demand.setMessage(message);
// demand.setGuideGender(gGender);
demand.setStatus(status);
demand.setGuideServiceId(guideServiceId);
demand.setGuideServiceIdList(guideServiceIdList);
}
}

@ -20,4 +20,9 @@ public interface DemandsService {
void update(Demands demand);//更新需求信息
List<Demands> getDemandsByPhone(String phone);//根据手机号获得对应游客用户的服务
List<Demands> getDemandsByCity(String city);//根据手机号获得对应游客用户的服务
List<Demands> getDemandsByProvince(String province);//根据手机号获得对应游客用户的服务
}

@ -5,6 +5,7 @@ import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Iterator;
import java.util.List;
/**
@ -48,13 +49,13 @@ public class DemandsServiceImpl implements DemandsService {
* @author: wuyifan
* @date: 2024/5/10 19:59
*/
public void deleteById(int id) {
DemandsRepository.deleteById(id);
System.out.println("删除成功");
public void deleteById(int did) {
DemandsRepository.deleteById(did);
System.out.println("删除成功对应did:");
}
/**
* @description: id
* @description:
* @param: id
* @return: com.softegg.freetogo.Demand.Bean.Demands
* @author: wuyifan
@ -73,20 +74,51 @@ public class DemandsServiceImpl implements DemandsService {
*/
public void update(Demands demand) {
DemandsRepository.save(demand);
System.out.println("更新成功");
System.out.println("需求更新成功");
}
/**
* @description:
* @param: phone
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/15 20:18
*/
public List<Demands> getDemandsByPhone(String phone) {
List<Demands> demandsList = DemandsRepository.findByPhone(phone);
Iterator<Demands> iterator = demandsList.iterator();
while (iterator.hasNext()) {
Demands demand = iterator.next();
if (demand.getStatus() == 4) {
iterator.remove(); // 使用迭代器的 remove 方法
}
}
return demandsList;
}
/**
* @description:
* @param: city
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/15 20:18
*/
public List<Demands> getDemandsByCity(String city) {
return DemandsRepository.findByCity(city);
}
/**
* @description:
* @param: city
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/15 20:18
*/
public List<Demands> getDemandsByProvince(String province) {
return DemandsRepository.findByProvince(province);
}
// /**
// * @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;
// }
}

@ -0,0 +1,140 @@
package com.softegg.freetogo.DemandMatch.controller;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.DemandMatch.service.DemandMatchService;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/6/4 14:47
*/
@RestController
@RequestMapping("/DemandMatch")
public class DemandMatchController {
@Autowired
DemandMatchService demandMatchService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/4 14:48
*/
@GetMapping("register")
public List<GuideService> GuideMatch(int did) {
System.out.println("接收的did:"+did);
return demandMatchService.guideMatchAccount(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/4 14:48
*/
@GetMapping("specific")
public List<GuideService> specific(int did, int gid) {
System.out.println("接收的did:"+did);
return demandMatchService.guideMatchAccount(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("match")
public int Match(@RequestBody Map<String, Object> map) {
int did = (int) map.get("did");
System.out.println("接收的did:"+did);
int gid = (int) map.get("gid");
System.out.println("接收的did:"+did);
return demandMatchService.match(did, gid);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@GetMapping("confirmedPage")
public List<GuideService> confirmedpage(int did) {
System.out.println("接收的did:"+did);
return demandMatchService.confirmedPage(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("confirmed")
public int confirmed(@RequestBody Map<String, Object> map) {
int did = Integer.parseInt(map.get("did").toString());
System.out.println("接收的did:"+did);
int gid = Integer.parseInt(map.get("gid").toString());
System.out.println("接收的did:"+gid);
return demandMatchService.confirmed(did, gid);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("refuse")
public int refuse(@RequestBody Map<String, Object> map) {
int did = (int) map.get("did");
System.out.println("接收的did:"+did);
return demandMatchService.refuse(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("finish")
public int finish(@RequestBody Map<String, Object> map) {
int did = (int) map.get("did");
System.out.println("接收的did:"+did);
return demandMatchService.finish(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("delete")
public int delete(@RequestBody Map<String, Object> map) {
int did = (int) map.get("did");
System.out.println("接收的did:"+did);
return demandMatchService.delete(did);
}
}

@ -0,0 +1,26 @@
package com.softegg.freetogo.DemandMatch.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import java.util.List;
public interface DemandMatchService {
List<GuideService> guideMatchAccount(int did);
int match(int did, int gid);
int confirmed(int did, int gid);
List<GuideService> confirmedPage(int did);
int refuse(int did);
int finish(int did);
int delete(int did);
double timeScore(int gsum, String gddate, String gedate, int dsum, String dddate, String dedate);
double messageScore(String gmessage, String dmessage);
}

@ -0,0 +1,421 @@
package com.softegg.freetogo.DemandMatch.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.User.service.UsersService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static java.lang.Math.abs;
import java.time.LocalDate;
/**
* description:
* @author:wuyifan
* date:2024/5/28 19:51
*/
@Component
public class DemandMatchServiceImpl implements DemandMatchService{
@Autowired
DemandsService demandsService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: city
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public List<GuideService> guideMatchAccount(int did){
Demands demand = demandsService.getDemandById(did);
int demandSumDay = Integer.parseInt(demand.getSumDay());
String demandDepartureDate = demand.getDepartureDate();
String demandEndDate = demand.getEndDate();
String demandMessage = demand.getMessage();
List<GuideService> guideServiceList = guideServiceService.getGuideServiceByCity(demand.getCity());
Iterator<GuideService> iterator = guideServiceList.iterator();
while (iterator.hasNext()) {
GuideService guideService = iterator.next();
if (guideService.getStatus() > 1) {
iterator.remove(); // 使用迭代器的 remove 方法
}
}
int length = guideServiceList.size();
double[] sumScores = new double[length];
int i = 0;
for (GuideService guideService : guideServiceList) {
double sumScore = 0;
int guideServiceSumDay = Integer.parseInt(guideService.getSumDay());
String guideServiceDepartureDate = guideService.getDepartureDate();
String guideServiceEndDate = guideService.getEndDate();
String guideServiceMessage = guideService.getMessage();
double timeScore = timeScore(guideServiceSumDay, guideServiceDepartureDate, guideServiceEndDate, demandSumDay, demandDepartureDate, demandEndDate);
double messageScore = messageScore(guideServiceMessage, demandMessage);
sumScore += timeScore + messageScore;
sumScores[i] = sumScore;
i++;
}
// 创建一个包含索引和值的列表
List<Map.Entry<Double, GuideService>> list = new ArrayList<>();
for (int j = 0; j < sumScores.length; j++) {
list.add(new AbstractMap.SimpleEntry<>(sumScores[j], guideServiceList.get(j)));
}
// 根据sumScores的元素大小对 list 进行排序
list.sort(new Comparator<Map.Entry<Double, GuideService>>() {
@Override
public int compare(Map.Entry<Double, GuideService> o1, Map.Entry<Double, GuideService> o2) {
return o2.getKey().compareTo(o1.getKey());
}
});
List<GuideService> newgList = new ArrayList<>();
for (Map.Entry<Double, GuideService> entry : list) {
newgList.add(entry.getValue());
}
return newgList;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int match(int did, int gid){
Demands demand = demandsService.getDemandById(did);
GuideService guideService = guideServiceService.getGuideServiceById(gid);
// List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
// if (guideServiceIdList == null) {
// guideServiceIdList = new ArrayList<>();
// }
// guideServiceIdList.add(gid);
// demand.setGuideServiceIdList(guideServiceIdList);
List<Integer> demandIdList = guideService.getDemandIdList();
if (demandIdList == null) {
demandIdList = new ArrayList<>();
}
if(!demandIdList.contains(did)) {
demandIdList.add(did);
}
guideService.setStatus(1);
guideService.setDemandIdList(demandIdList);
demandsService.update(demand);
guideServiceService.update(guideService);
System.out.println(guideService.getDemandIdList());
return 1006;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int confirmed(int did, int gid){
Demands demand = demandsService.getDemandById(did);
GuideService guideService = guideServiceService.getGuideServiceById(gid);
demand.setStatus(2);
demand.setGuideServiceId(gid);
guideService.setStatus(2);
guideService.setDemandId(did);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1007;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public List<GuideService> confirmedPage(int did){
Demands demand = demandsService.getDemandById(did);
List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
List<GuideService> guideServiceList = new ArrayList<>();
for(int number : guideServiceIdList) {
GuideService guideService = guideServiceService.getGuideServiceById(number);
guideServiceList.add(guideService);
}
return guideServiceList;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int refuse(int did){
Demands demand = demandsService.getDemandById(did);
int gid = demand.getGuideServiceId();
GuideService guideService = guideServiceService.getGuideServiceById(gid);
List<Integer> demandIdList = guideService.getDemandIdList();
if (demandIdList == null) {
guideService.setStatus(0);
}else {
guideService.setStatus(1);
}
List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
if(guideServiceIdList == null){
demand.setStatus(0);
}else {
demand.setStatus(1);
}
demand.setGuideServiceId(null);
guideService.setDemandId(null);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int finish(int did){
Demands demand = demandsService.getDemandById(did);
int gid = demand.getGuideServiceId();
GuideService guideService = guideServiceService.getGuideServiceById(gid);
demand.setStatus(3);
demand.setGuideServiceIdList(null);
guideService.setStatus(3);
guideService.setDemandIdList(null);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int delete(int did){
Demands demand = demandsService.getDemandById(did);
demand.setStatus(4);
demandsService.update(demand);
return 1;
}
public static boolean isRangeWithinRange(LocalDate startDate1, LocalDate endDate1, LocalDate startDate2, LocalDate endDate2) {
// 第一个范围的起始日期必须在第二个范围内或与其起始日期相同
return !startDate1.isBefore(startDate2) && !endDate1.isAfter(endDate2);
}
/**
* @description:
* @param: gsumdsumddateedate
* @return: float
* @author: wuyifan
* @date: 2024/5/28 20:35
*/
@Override
public double timeScore(int gsum, String gddate, String gedate, int dsum, String dddate, String dedate){
double score = 0;
int difference = gsum - dsum;
if (abs(difference) < 15 ){
score += 10 / (float)(abs(difference) + 1);
}
// 使用DateTimeFormatter将字符串转换为LocalDate对象
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate1 = LocalDate.parse(dddate, formatter);
LocalDate endDate1 = LocalDate.parse(dedate, formatter);
LocalDate startDate2 = LocalDate.parse(gddate, formatter);
LocalDate endDate2 = LocalDate.parse(gedate, formatter);
// 判断第一个范围是否在第二个范围内
boolean isRange1WithinRange2 = isRangeWithinRange(startDate1, endDate1, startDate2, endDate2);
if (isRange1WithinRange2){
score += 100;
}
return score;
}
/**
* @description: Jaccard
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:35
*/
public static double jaccardSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Set<Character> set1 = new HashSet<>();
Set<Character> set2 = new HashSet<>();
for (char c : s1.toCharArray()) {
set1.add(c);
}
for (char c : s2.toCharArray()) {
set2.add(c);
}
Set<Character> intersection = new HashSet<>(set1);
intersection.retainAll(set2);
Set<Character> union = new HashSet<>(set1);
union.addAll(set2);
return (double) intersection.size() / union.size();
}
/**
* @description:
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:35
*/
private static Map<Character, Integer> getCharacterFrequency(String s) {
Map<Character, Integer> frequencyMap = new HashMap<>();
for (char c : s.toCharArray()) {
frequencyMap.put(c, frequencyMap.getOrDefault(c, 0) + 1);
}
return frequencyMap;
}
public static double cosineSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Map<Character, Integer> freq1 = getCharacterFrequency(s1);
Map<Character, Integer> freq2 = getCharacterFrequency(s2);
double dotProduct = 0.0;
double mag1 = 0.0;
double mag2 = 0.0;
for (char c : freq1.keySet()) {
if (freq2.containsKey(c)) {
dotProduct += freq1.get(c) * freq2.get(c);
}
mag1 += Math.pow(freq1.get(c), 2);
}
for (char c : freq2.keySet()) {
mag2 += Math.pow(freq2.get(c), 2);
}
mag1 = Math.sqrt(mag1);
mag2 = Math.sqrt(mag2);
return dotProduct / (mag1 * mag2);
}
/**
* @description: Dice
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:25
*/
public static double diceCoefficient(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
int intersection = 0;
for (int i = 0; i < s1.length() - 1; i++) {
String bigram = s1.substring(i, i + 2);
if (s2.contains(bigram)) {
intersection++;
}
}
int union = s1.length() + s2.length() - intersection;
return (double) (2 * intersection) / union;
}
/**
* @description: N-gram
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:22
*/
private static Set<String> generateNGrams(String s, int n) {
if (s == null || s.length() < n || n <= 0) {
throw new IllegalArgumentException("Invalid input string or n-gram size");
}
if (s.isEmpty()) {
return new HashSet<>(); // 返回空集合
}
Set<String> nGrams = new HashSet<>();
for (int i = 0; i <= s.length() - n; i++) {
nGrams.add(s.substring(i, i + n));
}
return nGrams;
}
public static double bigramSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Set<String> bigrams1 = generateNGrams(s1, 2);
Set<String> bigrams2 = generateNGrams(s2, 2);
Set<String> commonBigrams = new HashSet<>(bigrams1);
commonBigrams.retainAll(bigrams2);
Set<String> allBigrams = new HashSet<>(bigrams1);
allBigrams.addAll(bigrams2);
return (double) commonBigrams.size() / allBigrams.size();
}
/**
* @description:
* @param: gmessagedmessage
* @return: float
* @author: wuyifan
* @date: 2024/5/28 20:35
*/
@Override
public double messageScore(String gmessage, String dmessage){
double score = 0;
double similarity1 = jaccardSimilarity(gmessage, dmessage);
double similarity2 = cosineSimilarity(gmessage, dmessage);
double similarity3 = diceCoefficient(gmessage, dmessage);
double similarity4 = bigramSimilarity(gmessage, dmessage);
score = similarity1 + similarity2 + similarity3 + similarity4;
return score;
}
}

@ -3,15 +3,13 @@ package com.softegg.freetogo.Evaluate.Dao;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @description: Jpa
* @author: zhanglinhao
* @date: 2024/5/10 9:27
*/
public interface EvaluateRepository extends JpaRepository<Evaluations, Integer> {
List<Evaluations> findByEditorPhone(String phone);
// List<Evaluations> findByEditorPhone(String phone);
List<Evaluations> findByEditedPhone(String phone);
// List<Evaluations> findByEditedPhone(String phone);
}

@ -21,14 +21,6 @@ public class Evaluations {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int eid;//评价id
@Column(name = "etorname")
private String editorName;//评价者姓名
@Column(name = "etorphone")
private String editorPhone;//评价者电话
@Column(name = "etedname")
private String editedName;//被评价者姓名
@Column(name = "etedphone")
private String editedPhone;//被评价者电话
@Column(name = "createtime")
private String ct;//创建日期
@Column(name = "modifytime")

@ -5,6 +5,7 @@ import com.softegg.freetogo.Evaluate.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@ -39,8 +40,14 @@ public class EvaluationController {
* @date: 2024/5/12 0:28
*/
@PostMapping("addEvaluation")
public void addEvaluation(@RequestBody Map<String, Evaluations> ebody) {
Evaluations evaluation = ebody.get("evaluation");
public void addEvaluation(@RequestBody Map<String, String> ebody) {
LocalDateTime currentTime = LocalDateTime.now();
Evaluations evaluation = new Evaluations();
evaluation.setEid(Integer.parseInt(ebody.get("eid")));
evaluation.setEbody(ebody.get("ebody"));
evaluation.setSatisfaction(Integer.parseInt(ebody.get("satisfaction")));
evaluation.setCt(currentTime.toString());
evaluation.setMt(currentTime.toString());
evaluateService.addEvaluation(evaluation);
}
@ -51,9 +58,13 @@ public class EvaluationController {
* @author: zhanglinhao
* @date: 2024/5/12 0:30
*/
@GetMapping("evaluationByPhone")
public List<Evaluations> evaluationByPhone(String phone) {
return evaluateService.getEListByPhone(phone);
// @GetMapping("evaluationByPhone")
// public List<Evaluations> evaluationByPhone(String phone) {
// return evaluateService.getEListByPhone(phone);
// }
@GetMapping("getEvaluation")
public Evaluations getEvaluation(int eid) {
return evaluateService.getEvaluationById(eid);
}
/**
@ -64,9 +75,12 @@ public class EvaluationController {
* @author: zhanglinhao
* @date: 2024/5/12 13:31
*/
@GetMapping("editEvaluation")
public void editEvaluation(int eid, String ebody) {
evaluateService.editEvaluation(eid, ebody);
@PostMapping("editEvaluation")
public void editEvaluation(@RequestBody Map<String, String> ebody) {
System.out.println("接收的json:" + ebody);
LocalDateTime currentTime = LocalDateTime.now();
Evaluations evaluation = new Evaluations(Integer.parseInt(ebody.get("eid")), ebody.get("ct"), currentTime.toString(), ebody.get("ebody"), Integer.parseInt(ebody.get("satisfaction")));
evaluateService.editEvaluation(evaluation);
}
/**
@ -88,14 +102,14 @@ public class EvaluationController {
* @author: zhanglinhao
* @date: 2024/5/12 13:39
*/
@GetMapping("getSatisfaction")
public String getSatisfaction(String phone) {
List<Evaluations> elist = evaluateService.getEvaluatedByPhone(phone);
float sumOfSatisfaction = 0;
for (Evaluations evaluation : elist) {
sumOfSatisfaction += evaluation.getSatisfaction();
}
System.out.println("查询满意度:"+ sumOfSatisfaction);
return Float.toString(sumOfSatisfaction /elist.size());
}
// @GetMapping("getSatisfaction")
// public String getSatisfaction(String phone) {
// List<Evaluations> elist = evaluateService.getEvaluatedByPhone(phone);
// float sumOfSatisfaction = 0;
// for (Evaluations evaluation : elist) {
// sumOfSatisfaction += evaluation.getSatisfaction();
// }
// System.out.println("查询满意度:"+ sumOfSatisfaction);
// return Float.toString(sumOfSatisfaction /elist.size());
// }
}

@ -14,13 +14,14 @@ import java.util.List;
public interface EvaluateService {
List<Evaluations> evaluationList();//获取所有评论
List<Evaluations> getEListByPhone(String phone);//根据电话筛选评价
// List<Evaluations> getEListByPhone(String phone);//根据电话筛选评价
List<Evaluations> getEvaluatedByPhone(String phone);
// List<Evaluations> getEvaluatedByPhone(String phone);
Evaluations getEvaluationById(int eid);//根据id获取评论
void addEvaluation(Evaluations evaluation);//添加评论
void editEvaluation(int eid, String ebody);//编辑评论
void editEvaluation(Evaluations evaluation);//编辑评论
void deleteEvaluation(int eid);//删除评论
}

@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
/**
* @description:
@ -31,19 +30,20 @@ public class EvaluateServiceImpl implements EvaluateService {
System.out.println("查询评论");
return evaluateRepository.findAll();
}
/**
* @description:
* @param: phone
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @description: id
* @param: eid
* @return: com.softegg.freetogo.Evaluate.bean.Evaluations
* @author: zhanglinhao
* @date: 2024/5/11 16:28
* @date: 2024/5/15 8:13
*/
@Override
public List<Evaluations> getEListByPhone(String phone) {
System.out.println("查询"+phone+"的评论");
return evaluateRepository.findByEditorPhone(phone);
public Evaluations getEvaluationById(int eid) {
return evaluateRepository.findById(eid).get();
}
/**
* @description:
* @param: phone
@ -51,11 +51,11 @@ public class EvaluateServiceImpl implements EvaluateService {
* @author: zhanglinhao
* @date: 2024/5/11 16:28
*/
@Override
public List<Evaluations> getEListByPhone(String phone) {
System.out.println("查询" + phone + "的评论");
return evaluateRepository.findByEditorPhone(phone);
}
// @Override
// public List<Evaluations> getEListByPhone(String phone) {
// System.out.println("查询" + phone + "的评论");
// return evaluateRepository.findByEditorPhone(phone);
// }
/**
* @description:
@ -64,10 +64,10 @@ public class EvaluateServiceImpl implements EvaluateService {
* @author: zhanglinhao
* @date: 2024/5/12 21:21
*/
@Override
public List<Evaluations> getEvaluatedByPhone(String phone) {
return evaluateRepository.findByEditedPhone(phone);
}
// @Override
// public List<Evaluations> getEvaluatedByPhone(String phone) {
// return evaluateRepository.findByEditedPhone(phone);
// }
/**
* @description:
@ -79,7 +79,7 @@ public class EvaluateServiceImpl implements EvaluateService {
@Override
public void addEvaluation(Evaluations evaluation) {
evaluateRepository.save(evaluation);
System.out.println("添加评论" + evaluation.getEbody());
System.out.println("添加评论:" + evaluation.getEbody());
}
/**
@ -90,15 +90,11 @@ public class EvaluateServiceImpl implements EvaluateService {
* @date: 2024/5/11 17:10
*/
@Override
public void editEvaluation(int eid, String ebody) {
public void editEvaluation(Evaluations evaluation) {
int eid = evaluation.getEid();
System.out.println("编辑评论:" + eid);
Optional<Evaluations> opt = evaluateRepository.findById(eid);
if (opt.isPresent()) {
Evaluations evaluation = opt.get();
evaluation.setEbody(ebody);
evaluateRepository.save(evaluation);
System.out.println("编辑成功:" + eid);
}
evaluateRepository.save(evaluation);
System.out.println("编辑成功:" + eid);
}
/**

@ -0,0 +1,9 @@
package com.softegg.freetogo.FeedBack;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/20 11:14
*/
public class bean {
}

@ -0,0 +1,119 @@
package com.softegg.freetogo.GuideMatch.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.GuideMatch.service.GuideMatchService;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/5/30 10:47
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/GuideMatch")
public class GuideMatchController {
@Autowired
GuideMatchService guideMatchService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/30 20:48
*/
@GetMapping("register")
public List<Demands> GuideMatch(int gid) {
System.out.println("需匹配的gid:" + gid);
return guideMatchService.guideMatchAccount(gid);
}
/**
* @description:
* @param: map
* @return: java.lang.int
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("match")
public int Match(@RequestBody Map<String, Object> map) {
int gid = Integer.parseInt(map.get("gid").toString());
System.out.println("接收的gid:"+gid);
int did = Integer.parseInt(map.get("did").toString());
System.out.println("接收的did:"+did);
return guideMatchService.match(gid, did);
}
/**
* @description:
* @param: gid
* @return: java.lang.Demands
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@GetMapping("confirmedPage")
public List<Demands> confirmedpage(int gid) {
System.out.println("接收的gid:"+gid);
return guideMatchService.confirmedPage(gid);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("confirmed")
public int confirmed(@RequestBody Map<String, Object> map) {
int gid = Integer.parseInt(map.get("gid").toString());
System.out.println("接收的did:"+gid);
int did = Integer.parseInt(map.get("did").toString());
System.out.println("接收的did:"+did);
return guideMatchService.confirmed(gid, did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("refuse")
public int refuse(@RequestBody Map<String, Object> map) {
int gid = (int) map.get("gid");
System.out.println("接收的gid:"+gid);
return guideMatchService.refuse(gid);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("delete")
public int delete(@RequestBody Map<String, Object> map) {
int gid = (int) map.get("gid");
System.out.println("接收的gid:"+gid);
return guideMatchService.delete(gid);
}
}

@ -0,0 +1,31 @@
package com.softegg.freetogo.GuideMatch.service;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/28 19:45
*/
@Service
public interface GuideMatchService {
List<Demands> guideMatchAccount(int gid);
int match(int gid, int did);
List<Demands> confirmedPage(int gid);
int confirmed(int did, int gid);
int refuse(int gid);
int delete(int gid);
double timeScore(int gsum, String gddate, String gedate, int dsum, String dddate, String dedate);
double messageScore(String gmessage, String dmessage);
}

@ -0,0 +1,397 @@
package com.softegg.freetogo.GuideMatch.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.User.service.UsersService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static java.lang.Math.abs;
/**
* description:
* @author:wuyifan
* date:2024/5/28 19:51
*/
@Component
public class GuideMatchServiceImpl implements GuideMatchService {
@Autowired
DemandsService demandsService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: city
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public List<Demands> guideMatchAccount(int gid){
GuideService guideService = guideServiceService.getGuideServiceById(gid);
int guideServiceSumDay = Integer.parseInt(guideService.getSumDay());
String guideServiceDepartureDate = guideService.getDepartureDate();
String guideServiceEndDate = guideService.getEndDate();
String guideServiceMessage = guideService.getMessage();
List<Demands> dlist = demandsService.getDemandsByCity(guideService.getCity());
Iterator<Demands> iterator = dlist.iterator();
while (iterator.hasNext()) {
Demands demand = iterator.next();
if (demand.getStatus() > 1) {
iterator.remove(); // 使用迭代器的 remove 方法
}
}
int length = dlist.size();
double[] sumScores = new double[length];
int i = 0;
for (Demands demands : dlist) {
double sumScore = 0;
int demandsSumDay = Integer.parseInt(demands.getSumDay());
String demandsDepartureDate = demands.getDepartureDate();
String demandsEndDate = demands.getEndDate();
String demandsMessage = demands.getMessage();
double timeScore = timeScore(guideServiceSumDay,guideServiceDepartureDate,guideServiceEndDate,demandsSumDay,demandsDepartureDate,demandsEndDate);
double messageScore = messageScore(guideServiceMessage, demandsMessage);
sumScore += timeScore + messageScore;
sumScores[i] = sumScore;
i++;
}
// 创建一个包含索引和值的列表
List<Map.Entry<Double, Demands>> list = new ArrayList<>();
for (int j = 0; j < sumScores.length; j++) {
list.add(new AbstractMap.SimpleEntry<>(sumScores[j], dlist.get(j)));
}
// 根据sumScores的元素大小对 list 进行排序
list.sort(new Comparator<Map.Entry<Double, Demands>>() {
@Override
public int compare(Map.Entry<Double, Demands> o1, Map.Entry<Double, Demands> o2) {
return o2.getKey().compareTo(o1.getKey());
}
});
List<Demands> newdList = new ArrayList<>();
for (Map.Entry<Double, Demands> entry : list) {
newdList.add(entry.getValue());
}
return newdList;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int match(int gid, int did){
Demands demand = demandsService.getDemandById(did);
GuideService guideService = guideServiceService.getGuideServiceById(gid);
demand.setStatus(1);
List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
if (guideServiceIdList == null) {
guideServiceIdList = new ArrayList<>();
}
if(!guideServiceIdList.contains(gid)){
guideServiceIdList.add(gid);
}
demand.setGuideServiceIdList(guideServiceIdList);
// List<Integer> demandIdList = guideService.getDemandIdList();
// if (demandIdList == null) {
// demandIdList = new ArrayList<>();
// }
// demandIdList.add(did);
// guideService.setDemandIdList(demandIdList);
demandsService.update(demand);
guideServiceService.update(guideService);
System.out.println(demand.getGuideServiceIdList());
return 1006;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public List<Demands> confirmedPage(int gid){
GuideService guideService = guideServiceService.getGuideServiceById(gid);
List<Integer> demandIdList = guideService.getDemandIdList();
List<Demands> demandsList = new ArrayList<>();
for(int number : demandIdList) {
Demands demand = demandsService.getDemandById(number);
demandsList.add(demand);
}
return demandsList;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int confirmed(int gid, int did){
Demands demand = demandsService.getDemandById(did);
GuideService guideService = guideServiceService.getGuideServiceById(gid);
demand.setStatus(2);
demand.setGuideServiceId(gid);
guideService.setStatus(2);
guideService.setDemandId(did);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1007;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int refuse(int gid){
GuideService guideService = guideServiceService.getGuideServiceById(gid);
int did = guideService.getDemandId();
Demands demand = demandsService.getDemandById(gid);
List<Integer> demandIdList = guideService.getDemandIdList();
if (demandIdList == null) {
guideService.setStatus(0);
}else {
guideService.setStatus(1);
}
List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
if(guideServiceIdList == null){
demand.setStatus(0);
}else {
demand.setStatus(1);
}
guideService.setDemandId(null);
demand.setGuideServiceId(null);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1;
}
@Override
public int delete(int gid){
GuideService guideService = guideServiceService.getGuideServiceById(gid);
guideService.setStatus(4);
guideServiceService.update(guideService);
return 1;
}
public static boolean isRangeWithinRange(LocalDate startDate1, LocalDate endDate1, LocalDate startDate2, LocalDate endDate2) {
return !startDate1.isBefore(startDate2) && !endDate1.isAfter(endDate2);
}
/**
* @description:
* @param: gsumdsumddateedate
* @return: float
* @author: wuyifan
* @date: 2024/5/28 20:35
*/
@Override
public double timeScore(int gsum, String gddate, String gedate, int dsum, String dddate, String dedate){
double score = 0;
int difference = gsum - dsum;
if (abs(difference) < 15 ){
score += 10 / (float)(abs(difference) + 1);
}
// 使用DateTimeFormatter将字符串转换为LocalDate对象
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate1 = LocalDate.parse(dddate, formatter);
LocalDate endDate1 = LocalDate.parse(dedate, formatter);
System.out.println(startDate1);
System.out.println(endDate1);
LocalDate startDate2 = LocalDate.parse(gddate, formatter);
LocalDate endDate2 = LocalDate.parse(gedate, formatter);
System.out.println(startDate2);
System.out.println(endDate2);
// 判断第一个范围是否在第二个范围内
boolean isRange1WithinRange2 = isRangeWithinRange(startDate1, endDate1, startDate2, endDate2);
if (isRange1WithinRange2){
score += 100;
}
return score;
}
/**
* @description: Jaccard
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:35
*/
public static double jaccardSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Set<Character> set1 = new HashSet<>();
Set<Character> set2 = new HashSet<>();
for (char c : s1.toCharArray()) {
set1.add(c);
}
for (char c : s2.toCharArray()) {
set2.add(c);
}
Set<Character> intersection = new HashSet<>(set1);
intersection.retainAll(set2);
Set<Character> union = new HashSet<>(set1);
union.addAll(set2);
return (double) intersection.size() / union.size();
}
/**
* @description:
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:35
*/
private static Map<Character, Integer> getCharacterFrequency(String s) {
Map<Character, Integer> frequencyMap = new HashMap<>();
for (char c : s.toCharArray()) {
frequencyMap.put(c, frequencyMap.getOrDefault(c, 0) + 1);
}
return frequencyMap;
}
public static double cosineSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Map<Character, Integer> freq1 = getCharacterFrequency(s1);
Map<Character, Integer> freq2 = getCharacterFrequency(s2);
double dotProduct = 0.0;
double mag1 = 0.0;
double mag2 = 0.0;
for (char c : freq1.keySet()) {
if (freq2.containsKey(c)) {
dotProduct += freq1.get(c) * freq2.get(c);
}
mag1 += Math.pow(freq1.get(c), 2);
}
for (char c : freq2.keySet()) {
mag2 += Math.pow(freq2.get(c), 2);
}
mag1 = Math.sqrt(mag1);
mag2 = Math.sqrt(mag2);
return dotProduct / (mag1 * mag2);
}
/**
* @description: Dice
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:25
*/
public static double diceCoefficient(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
int intersection = 0;
for (int i = 0; i < s1.length() - 1; i++) {
String bigram = s1.substring(i, i + 2);
if (s2.contains(bigram)) {
intersection++;
}
}
int union = s1.length() + s2.length() - intersection;
return (double) (2 * intersection) / union;
}
/**
* @description: N-gram
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:22
*/
private static Set<String> generateNGrams(String s, int n) {
if (s == null || s.length() < n || n <= 0) {
throw new IllegalArgumentException("Invalid input string or n-gram size");
}
if (s.isEmpty()) {
return new HashSet<>(); // 返回空集合
}
Set<String> nGrams = new HashSet<>();
for (int i = 0; i <= s.length() - n; i++) {
nGrams.add(s.substring(i, i + n));
}
return nGrams;
}
public static double bigramSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Set<String> bigrams1 = generateNGrams(s1, 2);
Set<String> bigrams2 = generateNGrams(s2, 2);
Set<String> commonBigrams = new HashSet<>(bigrams1);
commonBigrams.retainAll(bigrams2);
Set<String> allBigrams = new HashSet<>(bigrams1);
allBigrams.addAll(bigrams2);
return (double) commonBigrams.size() / allBigrams.size();
}
/**
* @description:
* @param: gmessagedmessage
* @return: float
* @author: wuyifan
* @date: 2024/5/28 20:35
*/
@Override
public double messageScore(String gmessage, String dmessage){
double score = 0;
double similarity1 = jaccardSimilarity(gmessage, dmessage);
double similarity2 = cosineSimilarity(gmessage, dmessage);
double similarity3 = diceCoefficient(gmessage, dmessage);
double similarity4 = bigramSimilarity(gmessage, dmessage);
score = similarity1 + similarity2 + similarity3 + similarity4;
return score;
}
}

@ -0,0 +1,20 @@
package com.softegg.freetogo.GuideService.Dao;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @description:Jpa
* @author:wuyifan
* @date:2024/5/13 9:17
*/
public interface GuideServiceRepository extends JpaRepository<GuideService, Integer> {
List<GuideService> findByPhone(String phone);
List<GuideService> findByCity(String city);
List<GuideService> findByProvince(String province);
}

@ -0,0 +1,53 @@
package com.softegg.freetogo.GuideService.bean;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
/**
* @description:guideService
* @author:wuyifan
* @date:2024/5/13 9:14
*/
@Entity
@Table(name = "guideService")
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class GuideService {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer gid;
@Column
private String phone;//导游手机号码
@Column(name = "guide_gender")
private boolean guideGender;//导游性别 ture:male, false:female
@Column
private String nickname;//发布需求的导游昵称信息
@Column(name = "create_time")
private String createTime;//服务发布时间
@Column(name = "departure_date")
private String departureDate;//导游服务起始日期
@Column(name = "end_date")
private String endDate;//导游服务结束日期
@Column(name = "sum_day")
private String sumDay;//导游服务总天数
@Column
private String province;//导游服务的目的省份
@Column
private String city;//导游服务的目的城市
@Column
private String message;//导游服务备注内容
@Column
private Integer status;//导游服务状态 0未匹配 1请求匹配 2已完成匹配 3已完成所有服务
@Column
private Integer demandId;//导游服务最终匹配到的游客需求id
@ElementCollection
@Column
private List<Integer> demandIdList;//游客需求申请匹配到的导游服务id
}

@ -0,0 +1,103 @@
package com.softegg.freetogo.GuideService.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:Guide
* @author:wuyifan
* @date:2024/5/13 9:26
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/guideService")
public class GuideServiceController {
@Autowired
private GuideServiceService guideServiceService;
@GetMapping("findAll")
public List<GuideService> findAll() {
return guideServiceService.findAll();
}
@GetMapping("add")
public String add(String phone,
boolean gGender,
String nkn,
String ct,
String dDate,
String eDate,
String sDay,
String procvince,
String city,
String message,
Integer status,
Integer demandId,
List<Integer> demandIdList) {
GuideService guideService = new GuideService();
setDemands(phone, gGender, nkn, ct, dDate, eDate, sDay, procvince, city, message, status, guideService, demandId, demandIdList);
guideServiceService.add(guideService);
return "添加成功";
}
@PostMapping("delbyid")
public String delById(@RequestBody Map<String, Object> map) {
int gid = (int) map.get("gid");
guideServiceService.deleteById(gid);
return "1";
}
@GetMapping("findbyid")
public GuideService getUserById(int gid) {
return guideServiceService.getGuideServiceById(gid);
}
@GetMapping("getByPhone")
public List<GuideService> getByPhone(String phone) {
System.out.println("根据手机号获取游客需求信息:" + phone);
return guideServiceService.getGuideServiceByPhone(phone);
}
@GetMapping("update")
public String update(int id,
String phone,
boolean gGender,
String nkn,
String ct,
String dDate,
String eDate,
String sDay,
String province,
String city,
String message,
Integer status,
Integer demandId,
List<Integer> demandIdList) {
GuideService guideService = guideServiceService.getGuideServiceById(id);
setDemands(phone, gGender, nkn, ct, dDate, eDate, sDay, province, city, message, status, guideService, demandId, demandIdList);
guideServiceService.update(guideService);
return "更新成功";
}
private void setDemands(String phone, boolean gGender, String nkn, String ct, String dDate, String eDate, String sDay, String province, String city, String message, Integer status, GuideService guideservice, Integer demandId, List<Integer> demandIdList) {
guideservice.setPhone(phone);
guideservice.setGuideGender(gGender);
guideservice.setNickname(nkn);
guideservice.setCreateTime(ct);
guideservice.setDepartureDate(dDate);
guideservice.setEndDate(eDate);
guideservice.setSumDay(sDay);
guideservice.setProvince(province);
guideservice.setCity(city);
guideservice.setMessage(message);
guideservice.setStatus(status);
guideservice.setDemandId(demandId);
guideservice.setDemandIdList(demandIdList);
}
}

@ -0,0 +1,28 @@
package com.softegg.freetogo.GuideService.service;
import com.softegg.freetogo.GuideService.bean.GuideService;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 2059
*/
public interface GuideServiceService {
List<GuideService> findAll();//查找所有需求
void add(GuideService guideService);//以demand为用户入库
void deleteById(int id);//删除对应id需求
GuideService getGuideServiceById(int id);//获得对应id需求
void update(GuideService guideService);//更新需求信息
List<GuideService> getGuideServiceByPhone(String phone);//获得对应手机号的导游用户的所有服务
List<GuideService> getGuideServiceByCity(String city);//根据所选城市获得导游服务列表
List<GuideService> getGuideServiceByProvince(String province);//根据所选城市获得导游服务列表
}

@ -0,0 +1,128 @@
package com.softegg.freetogo.GuideService.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.Dao.GuideServiceRepository;
import com.softegg.freetogo.GuideService.bean.GuideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Iterator;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/13 9:19
*/
@Component
public class GuideServiceServiceImpl implements GuideServiceService {
@Autowired
private GuideServiceRepository GuideServiceRepository;
@Autowired
private GuideServiceRepository guideServiceRepository;
/**
* @description:
* @param: null
* @return: java.util.List<com.softegg.freetogo.GuideService.Bean.GuideService>
* @author: wuyifan
* @date: 2024/5/13 9:21
*/
public List<GuideService> findAll() {
System.out.println("查询成功");
return GuideServiceRepository.findAll();
}
/**
* @description: guideService
* @param: guideService
* @return: void
* @author: wuyifan
* @date: 2024/5/13 922
*/
public void add(GuideService guideService) {
GuideServiceRepository.save(guideService);
System.out.println("添加成功");
}
/**
* @description: id
* @param: id
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/10 20:02
*/
public GuideService getGuideServiceById(int id) {
return GuideServiceRepository.findById(id).orElse(null);
}
/**
* @description: gid
* @param: id
* @return: void
* @author: zhanglinhao
* @date: 2024/5/9 22:53
*/
public void deleteById(int gid) {
guideServiceRepository.deleteById(gid);
System.out.println("删除成功:" + gid);
}
/**
* @description:
* @param: guideService
* @return: void
* @author: wuyifan
* @date: 2024/5/10 20:05
*/
public void update(GuideService guideService) {
GuideServiceRepository.save(guideService);
System.out.println("服务更新成功");
}
/**
* @description:
* @param: phone
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/16 15:18
*/
public List<GuideService> getGuideServiceByPhone(String phone) {
List<GuideService> guideServiceList = GuideServiceRepository.findByPhone(phone);
Iterator<GuideService> iterator = guideServiceList.iterator();
while (iterator.hasNext()) {
GuideService guideService = iterator.next();
if (guideService.getStatus() == 4) {
iterator.remove(); // 使用迭代器的 remove 方法
}
}
return guideServiceList;
}
/**
* @description:
* @param: city
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/16 15:30
*/
public List<GuideService> getGuideServiceByCity(String city) {
return GuideServiceRepository.findByCity(city);
}
/**
* @description:
* @param: city
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/16 15:30
*/
public List<GuideService> getGuideServiceByProvince(String province) {
return GuideServiceRepository.findByProvince(province);
}
}

@ -0,0 +1,4 @@
package com.softegg.freetogo.HeatMap.controller;
public class HeatMapController {
}

@ -0,0 +1,11 @@
package com.softegg.freetogo.HeatMap.service;
public interface HeatMapService {
int[] provinceDemandsHeatMap();//获得每个省份的游客需求数目
int[] cityDemandsHeatMap(String province);//获得目标省份的游客需求数目
int[] provinceGuideServiceHeatMap();
int[] cityGuideServiceHeatMap(String province);
}

@ -0,0 +1,192 @@
package com.softegg.freetogo.HeatMap.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.GuideService.bean.GuideService;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* description:
* @author:wuyifan
* date:2024/6/6 10:51
*/
@Component
public class HeatMapServiceImpl implements HeatMapService {
@Autowired
DemandsService demandsService;
@Autowired
GuideServiceService guideServiceService;
public static void main(String[] args) {
List<String> provinceList = new ArrayList<>();
JSONParser parser = new JSONParser();
try {
// 读取 JSON 文件内容并解析为 JSONObject
Object obj = parser.parse(new FileReader("C:/Users/WYF/Desktop/软件体系结构/FreeToGo/src/main/java/com/softegg/freetogo/HeatMap/service/area.json")); // 直接使用文件名表示相对路径
JSONObject jsonObject = (JSONObject) obj;
for (Object province : jsonObject.keySet()) {
provinceList.add(province.toString());
}
System.out.println("所有省份列表:");
for (String province : provinceList) {
System.out.println(province);
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
}
/**
* @description: List
* @param: null
* @return: List<String>
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
public List<String> getAllProvinces() {
List<String> provinceList = new ArrayList<>();
JSONParser parser = new JSONParser();
try {
// 读取 JSON 文件内容并解析为 JSONObject
Object obj = parser.parse(new FileReader("C:/Users/WYF/Desktop/软件体系结构/FreeToGo/src/main/java/com/softegg/freetogo/HeatMap/service/area.json"));
JSONObject jsonObject = (JSONObject) obj;
// 遍历每个省份
for (Object province : jsonObject.keySet()) {
// 将省份添加到列表中
provinceList.add(province.toString());
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
return provinceList;
}
/**
* @description: List
* @param: String
* @return: List<String>
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
public List<String> getCitiesInProvince(String province) {
List<String> cityList = new ArrayList<>();
JSONParser parser = new JSONParser();
try {
// 读取 JSON 文件内容并解析为 JSONObject
Object obj = parser.parse(new FileReader("C:/Users/WYF/Desktop/软件体系结构/FreeToGo/src/main/java/com/softegg/freetogo/HeatMap/service/area.json"));
JSONObject jsonObject = (JSONObject) obj;
// 获取湖南省的城市信息
JSONObject hunanCities = (JSONObject) jsonObject.get(province);
// 遍历每个城市并将城市名称添加到列表中
for (Object city : hunanCities.keySet()) {
cityList.add(city.toString());
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
return cityList;
}
/**
* @description:
* @param: null
* @return: int[]
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
@Override
public int[] provinceDemandsHeatMap(){
List<String> provinceList = getAllProvinces();
int[] sum = new int[provinceList.size()];
int i = 0;
for (String province : provinceList) {
List<Demands> demandsList = demandsService.getDemandsByProvince(province);
sum[i] = demandsList.size();
i++;
}
return sum;
}
/**
* @description:
* @param: String
* @return: int[]
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
@Override
public int[] cityDemandsHeatMap(String province){
List<String> cityList = getCitiesInProvince(province);
int[] sum = new int[cityList.size()];
int i = 0;
for (String city : cityList) {
List<Demands> demandsList = demandsService.getDemandsByCity(city);
sum[i] = demandsList.size();
i++;
}
return sum;
}
/**
* @description:
* @param: null
* @return: int[]
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
@Override
public int[] provinceGuideServiceHeatMap(){
List<String> provinceList = getAllProvinces();
int[] sum = new int[provinceList.size()];
int i = 0;
for (String province : provinceList) {
List<GuideService> guideServiceList = guideServiceService.getGuideServiceByProvince(province);
sum[i] = guideServiceList.size();
i++;
}
return sum;
}
/**
* @description:
* @param: String
* @return: int[]
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
@Override
public int[] cityGuideServiceHeatMap(String province){
List<String> cityList = getCitiesInProvince(province);
int[] sum = new int[cityList.size()];
int i = 0;
for (String city : cityList) {
List<GuideService> guideServiceList = guideServiceService.getGuideServiceByCity(city);
sum[i] = guideServiceList.size();
i++;
}
return sum;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -1,6 +1,7 @@
package com.softegg.freetogo.Login.controller;
import com.softegg.freetogo.Login.service.LoginService;
import com.softegg.freetogo.User.Dao.GuidesRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -22,6 +23,9 @@ public class LoginController {
@Autowired
LoginService loginService;
@Autowired
GuidesRepository guidesRepository;
/**
* @description:
* @param: map
@ -34,14 +38,8 @@ public class LoginController {
System.out.println(map);
System.out.println("phone:" + map.get("phone").toString());
System.out.println("password" + map.get("password").toString());
int tag = loginService.loginAccount(map.get("name").toString(), map.get("password").toString());
System.out.println("LoginTag:" + tag);
=======
System.out.println("phone:" + map.get("phone").toString());
System.out.println("password" + map.get("password").toString());
int tag = loginService.loginAccount(map.get("name").toString(), map.get("password").toString());
int tag = loginService.loginAccount(map.get("phone").toString(), map.get("password").toString());
System.out.println("LoginTag:" + tag);
>>>>>>> zhanglinhao_branch
return switch (tag) {
case 1000 -> 1;//登陆成功
case 1001 -> 2;//密码或账号错误
@ -49,7 +47,6 @@ public class LoginController {
case 1005 -> 6;//未输入账号密码
case 1006 -> 7;//未输入账号
case 1007 -> 8;//未输入密码
case 1008 -> 9;//身份证输入错误
default -> 0;
};
}
@ -66,14 +63,15 @@ public class LoginController {
System.out.println(map);
int tag = loginService.registerAccount((String) map.get("name"), (String) map.get("password"), (String) map.get("phone"), (String) map.get("nickname"), (String) map.get("IDCard"));
System.out.println("RegisterTag:" + tag);
=======
int tag = loginService.registerAccount((String) map.get("name"), (String) map.get("password"), (String) map.get("phone"), (String) map.get("nickname"), (String) map.get("IDCard"));
System.out.println("RegisterTag:" + tag);
>>>>>>> zhanglinhao_branch
return switch (tag) {
case 1003 -> 4;//该账户已经注册
case 1004 -> 5;//注册成功
case 1008 -> 9;//身份证输入错误18位
case 1010 -> 11;//手机号输入错误11位
case 1011 -> 12;//密码过短最少8位
case 1012 -> 13;//姓名未输入
default -> 0;
};
}
}

@ -17,4 +17,5 @@ public interface LoginService {
String phone,
String nickname,
String IDCard);//注册
}

@ -1,13 +1,12 @@
package com.softegg.freetogo.Login.service;
import com.softegg.freetogo.User.Dao.GuidesRepository;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
=======
>>>>>>> zhanglinhao_branch
/**
* @description:
@ -18,6 +17,8 @@ import java.time.LocalDateTime;
public class LoginServiceImpl implements LoginService {
@Autowired
UsersService usersService;
@Autowired
GuidesRepository guidesRepository;
/**
* @description:
@ -63,8 +64,14 @@ public class LoginServiceImpl implements LoginService {
String IDCard) {
if (usersService.isRegister(phone))
return 1003;//该账户已经注册
else if(name.isEmpty())
return 1012;//姓名未输入
else if (IDCard.length() != 18)
return 1008;//身份证输入错误
else if (phone.length() != 11)
return 1010;//手机号输入错误
else if (password.length() < 8)
return 1011;//密码过于简单
else {
LocalDateTime currentTime = LocalDateTime.now();
System.out.println("注册信息:姓名:" + name + "密码:" + password + "电话:" + phone + "昵称:" + nickname + "身份证:" + IDCard);
@ -72,10 +79,13 @@ public class LoginServiceImpl implements LoginService {
user.setPhone(phone);
user.setPassword(password);
user.setNickname(nickname);
user.setIDCard(IDCard);
user.setIdcard(IDCard);
user.setName(name);
user.setCreatetime((currentTime.getYear() + "-" + currentTime.getMonthValue() + "-" + currentTime.getDayOfMonth()));
user.setGender(isMale(IDCard));
user.setStatus(0);
user.setReputation(60);
user.setMembertype(false);
usersService.add(user);
return 1004;//注册成功
}

@ -6,4 +6,8 @@
1005->6 未输入账号密码
1006->7 未输入账号
1007->8 身份证输入错误
1008->9
1008->9 成功注册导游
1009->10 已是导游
1010->11 手机号输入错误
1011->12 密码过短
1012->13 未输入姓名

@ -0,0 +1,4 @@
package com.softegg.freetogo.Search.controller;
public class SearchController {
}

@ -0,0 +1,4 @@
package com.softegg.freetogo.Search.service;
public interface SearchService {
}

@ -0,0 +1,4 @@
package com.softegg.freetogo.Search.service;
public class SearchServiceImpl {
}

@ -1,15 +1,15 @@
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 com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.SendDemand.service.SendDemandService;
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.List;
import java.util.Map;
/**
* @description:
* @author:wuyifan
@ -23,19 +23,50 @@ public class SendDemandController {
@Autowired
SendDemandService sendDemandService;
@Autowired
DemandsService demandsService;
/**
* @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";
};
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/16 11:01
*/
@GetMapping("sendAllDemands")
public List<Demands> sendAllDemand(String phone) {
System.out.println("收到目标用户手机号:" + phone);
List<Demands> dlist = demandsService.getDemandsByPhone(phone);
System.out.println(dlist);
return dlist;
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/4 16:12
*/
@GetMapping("demand")
public Demands demand(int did) {
System.out.println("需求did:"+did);
return demandsService.getDemandById(did);
}
}

@ -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);
}

@ -2,11 +2,16 @@ package com.softegg.freetogo.SendDemand.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.User.service.UsersService;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
/**
* @description:
* @author:wuyifan
@ -16,9 +21,11 @@ import org.springframework.stereotype.Component;
public class SendDemandServiceImpl implements SendDemandService {
@Autowired
DemandsService demandsService;
@Autowired
UsersService usersService;
/**
* @description:
* @description:
* @param: city
* @return: int
* @author: wuyifan
@ -26,14 +33,38 @@ 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();
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;//添加游客需求成功
}
}

@ -0,0 +1,76 @@
package com.softegg.freetogo.SendGuideService.controller;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.SendGuideService.service.SendGuideServiceService;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/5/13 10:47
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/SendGuideService")
public class SendGuideServiceController {
@Autowired
SendGuideServiceService sendGuideServiceService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/13 10:48
*/
@PostMapping("register")
public int SendDemand(@RequestBody Map<String, Object> map) {
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;//用户非导游
}
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/16 11:01
*/
@GetMapping("sendAllGuideService")
public List<GuideService> sendAllGuideService(String phone) {
List<GuideService> glist = guideServiceService.getGuideServiceByPhone(phone);
return glist;
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/4 16:10
*/
@GetMapping("GuideService")
public GuideService GuideService(int gid) {
return guideServiceService.getGuideServiceById(gid);
}
}

@ -0,0 +1,14 @@
package com.softegg.freetogo.SendGuideService.service;
import org.springframework.stereotype.Service;
/**
* @description:
* @author:wuyifan
* @date:2024/5/13 11:11
*/
@Service
public interface SendGuideServiceService {
int sendnewGuideServiceAccount(String city, String phone, String date, String message);
}

@ -0,0 +1,76 @@
package com.softegg.freetogo.SendGuideService.service;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
/**
* @description:
* @author:wuyifan
* @date:2024/5/13 10:53
*/
@Component
public class SendGuideServiceServiceImpl implements SendGuideServiceService {
@Autowired
GuideServiceService guideServiceService;
@Autowired
UsersService usersService;
/**
* @description:
* @param: city
* @return: int
* @author: wuyifan
* @date: 2024/5/10 23:25
*/
@Override
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();
dDate = dDate.substring(0, 10);
eDate = eDate.substring(0, 10);
System.out.println(dDate);
System.out.println(eDate);
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;//添加导游服务成功
}
}

@ -0,0 +1,12 @@
package com.softegg.freetogo.User.Dao;
import com.softegg.freetogo.User.bean.Guides;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @description: Jpa
* @author: zhanglinhao
* @date: 2024/5/16 10:44
*/
public interface GuidesRepository extends JpaRepository<Guides, Integer> {
}

@ -0,0 +1,31 @@
package com.softegg.freetogo.User.bean;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/16 10:33
*/
@Entity
@Table(name = "guides")
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Guides {
@Id
private Integer uid;
@Column(name = "residence")
private String rsd;
@Column(name = "familiarareas")
private String fa;
@Column(name = "synopsis")
private String syns;
@Column(name = "experance")
private boolean re;
}

@ -29,8 +29,8 @@ public class Users {
private String password;
@Column
private String createtime;
@Column
private String IDCard;
@Column(name="IDCard")
private String idcard;
@Column
private int reputation;
@Column
@ -52,7 +52,7 @@ public class Users {
this.reputation = rpt;
this.phone = phone;
this.nickname = nkn;
this.IDCard = idc;
this.idcard = idc;
this.gender = gender;
this.membertype = type;
this.status = status;

@ -1,6 +1,8 @@
package com.softegg.freetogo.User.controller;
import com.softegg.freetogo.User.bean.Guides;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.GuidesService;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -15,10 +17,12 @@ import java.util.Map;
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/Users")
@RequestMapping("/users")
public class UsersController {
@Autowired
private UsersService usersService;
UsersService usersService;
@Autowired
GuidesService guidesService;
/**
* @description: users
@ -35,18 +39,6 @@ public class UsersController {
/**
* @description:
* @param: name
* @param: email
* @param: psw
* @param: ct
* @param: rpt
* @param: phone
* @param: nkn
* @param: idc
* @param: gender
* @param: type
* @param: status
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/10 8:17
*/
@ -97,18 +89,6 @@ public class UsersController {
/**
* @description: 使GET
* @param: name
* @param: email
* @param: password
* @param: ct
* @param: rpt
* @param: phone
* @param: nkn
* @param: idc
* @param: gender
* @param: type
* @param: status
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/10 8:17
*/
@ -139,22 +119,23 @@ public class UsersController {
* @author: zhanglinhao
* @date: 2024/5/10 19:45
*/
@PostMapping("pupdate")
public boolean pupdate(@RequestBody Map<String, Map<String, Object>> user) {
Map<String, Object> ubody = user.get("user");
// @PostMapping("pupdate")
// public boolean pupdate(@RequestBody Map<String, Map<String, Object>> user) {
// Map<String, Object> ubody = user.get("user");
//
// System.out.println(ubody);
// System.out.println(ubody.get("uid"));
Users User = new Users((int) ubody.get("uid"), (String) ubody.get("name"), (String) ubody.get("email"), (String) ubody.get("password"), (String) ubody.get("createtime"), (String) ubody.get("IDCard"), (int) ubody.get("reputation"), (boolean) ubody.get("gender"), (boolean) ubody.get("membertype"), (String) ubody.get("phone"), (String) ubody.get("nickname"), (int) ubody.get("status"));
usersService.update(User);
return true;
}
//// System.out.println(ubody.get("uid"));
// Users User = new Users((int) ubody.get("uid"), (String) ubody.get("name"), (String) ubody.get("email"), (String) ubody.get("password"), (String) ubody.get("createtime"), (String) ubody.get("idcard"), (int) ubody.get("reputation"), (boolean) ubody.get("gender"), (boolean) ubody.get("membertype"), (String) ubody.get("phone"), (String) ubody.get("nickname"), (int) ubody.get("status"));
// usersService.update(User);
// return true;
// }
@PostMapping("Pupdate")
public boolean Pupdate(@RequestBody Map<String, Users> user) {
Users ubody = user.get("user");
System.out.println(ubody);
// System.out.println(ubody.get("uid"));
Users User = new Users(ubody.getUid(), ubody.getName(), ubody.getEmail(), ubody.getPassword(), ubody.getCreatetime(), ubody.getIDCard(), ubody.getReputation(), ubody.isGender(), ubody.isMembertype(), ubody.getPhone(), ubody.getNickname(), ubody.getStatus());
Users User = new Users(ubody.getUid(), ubody.getName(), ubody.getEmail(), ubody.getPassword(), ubody.getCreatetime(), ubody.getIdcard(), ubody.getReputation(), ubody.isGender(), ubody.isMembertype(), ubody.getPhone(), ubody.getNickname(), ubody.getStatus());
usersService.update(User);
return true;
}
@ -169,24 +150,73 @@ public class UsersController {
@GetMapping("getByPhone")
public Users getByPhone(String phone) {
System.out.println("根据手机号获取用户信息:" + phone);
System.out.println(usersService.getUserByPhone(phone));
return usersService.getUserByPhone(phone);
}
/**
* @description: user
* @param: name
* @param: email
* @param: psw
* @param: ct
* @param: rpt
* @description:
* @param: phone
* @param: nkn
* @param: idc
* @param: gender
* @param: type
* @param: status
* @param: user
* @return: void
* @return: boolean
* @author: zhanglinhao
* @date: 2024/5/15 20:03
*/
@GetMapping("isGuide")
public boolean isGuide(String phone) {
System.out.println("查寻是否是导游:" + phone);
return usersService.isGuide(phone);
}
/**
* @description: id
* @param: phone
* @return: int
* @author: zhanglinhao
* @date: 2024/5/16 11:13
*/
@GetMapping("getUid")
public int getUid(String phone) {
System.out.println("搜索uid使用的电话:" + phone);
return usersService.getIdByPhone(phone);
}
/**
* @description:
* @param: guide
* @return: int
* @author: zhanglinhao
* @date: 2024/5/16 10:15
*/
// @PostMapping("registerToGuide")
// public int registerToGuide(@RequestBody Map<String,Map<String,String>> grequesting) {//Map<String, Map<String, Object>> gbody) {
// System.out.println("接收的注册请求:"+grequesting);
// Map<String,String> gbody = grequesting.get("registerToGuide");
// System.out.println("处理后的注册请求:"+gbody);
// Guides guide = new Guides();
// guide.setUid(Integer.parseInt(gbody.get("uid")));
// guide.setRsd(gbody.get("rsd"));
// guide.setFa(gbody.get("fa"));
// guide.setSyns(gbody.get("syns"));
// guide.setRe(Boolean.parseBoolean(gbody.get("re")));
// if(guidesService.registerToGuide(guide))
// return 1;
// else
// return 0;
// }
@PostMapping("registerToGuide")
public int registerToGuide(@RequestBody Map<String,Guides> grequesting) {//Map<String, Map<String, Object>> gbody) {
System.out.println(grequesting);
Guides guide = grequesting.get("registerToGuide");
System.out.println(guide);
if(guidesService.registerToGuide(guide))
return 1;
else
return 0;
}
/**
* @description: user
* @author: zhanglinhao
* @date: 2024/5/10 8:18
*/
@ -211,7 +241,7 @@ public class UsersController {
user.setCreatetime(ct);
user.setPhone(phone);
user.setNickname(nkn);
user.setIDCard(idc);
user.setIdcard(idc);
user.setStatus(status);
}
}

@ -0,0 +1,14 @@
package com.softegg.freetogo.User.service;
import com.softegg.freetogo.User.bean.Guides;
import org.springframework.stereotype.Service;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/16 10:45
*/
@Service
public interface GuidesService {
boolean registerToGuide(Guides guide);//注册成为导游,将导游注册信息入库
}

@ -0,0 +1,49 @@
package com.softegg.freetogo.User.service;
import com.softegg.freetogo.User.Dao.GuidesRepository;
import com.softegg.freetogo.User.bean.Guides;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/16 10:46
*/
@Component
public class GuidesServiceImpl implements GuidesService {
@Autowired
GuidesRepository guidesRepository;
@Autowired
UsersService usersService;
//
// @Override
// public void registerToGuide(Guides guide) {
// guidesRepository.save(guide);
// System.out.println("成功保存注册导游信息!");
// }
/**
* @description:
* @param: guide
* @return: int
* @author: zhanglinhao
* @date: 2024/5/15 21:19
*/
@Override
public boolean registerToGuide(Guides guide) {
System.out.println("注册成为导游id:" + guide.getUid());
Users user = usersService.getUserById(guide.getUid());
user.setMembertype(true);
guidesRepository.save(guide);
if (user.isMembertype()) {
System.out.println("注册成功!");
return true;
}else{
System.out.println("注册失败!");
return false;
}
}
}

@ -73,7 +73,8 @@ public class UserServiceImpl implements UsersService {
*/
public void update(Users user) {
usersRepository.save(user);
System.out.println("更新成功:" + user);
System.out.println("更新成功:");
showInfo(user);
}
/**
@ -86,7 +87,13 @@ public class UserServiceImpl implements UsersService {
public boolean isRegister(String phone) {
Users users = usersRepository.findByPhone(phone);
System.out.println("正在验证用户是否注册:" + users);
return users != null;
if (users == null) {
System.out.println("用户未注册");
return false;
} else {
System.out.println("用户已注册");
return true;
}
}
/**
@ -100,4 +107,63 @@ public class UserServiceImpl implements UsersService {
System.out.println("通过手机号查找用户:" + phone);
return usersRepository.findByPhone(phone);
}
/**
* @description:
* @param: phone
* @return: boolean
* @author: zhanglinhao
* @date: 2024/5/15 21:32
*/
@Override
public boolean isGuide(String phone) {
System.out.println("判断是不是导游:" + phone);
Users user = getUserByPhone(phone);
if (user.isMembertype()) {
System.out.println("是导游:" + phone);
return true;
} else {
System.out.println("不是导游:" + phone);
return false;
}
}
/**
* @description: uid
* @param: phone
* @return: int
* @author: zhanglinhao
* @date: 2024/5/16 10:54
*/
@Override
public int getIdByPhone(String phone) {
Users user = usersRepository.findByPhone(phone);
if (user == null) {
System.out.println("该电话号码未注册");
return -1;
} else {
System.out.println("查询到的id:" + user.getUid());
return user.getUid();
}
}
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/16 15:55
*/
@Override
public void showInfo(Users user) {
System.out.println(user.getUid());
System.out.println(user.getName());
System.out.println(user.getPhone());
System.out.println(user.getPassword());
System.out.println(user.getNickname());
System.out.println(user.getCreatetime());
System.out.println(user.getIdcard());
System.out.println(user.getReputation());
System.out.println(user.getStatus());
System.out.println(user.isGender());
System.out.println(user.isMembertype());
}
}

@ -25,4 +25,9 @@ public interface UsersService {
boolean isRegister(String phone);//判断该手机号(账号)是否已经入库
Users getUserByPhone(String phone);//根据手机号获得用户
boolean isGuide(String phone);//查询是否是导游
int getIdByPhone(String phone);//查找uid
void showInfo(Users user);//打印所有信息
}

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" packagePrefix="com.softegg.freetogo" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/freetogo.iml" filepath="$PROJECT_DIR$/freetogo.iml" />
</modules>
</component>
</project>

@ -0,0 +1,25 @@
//package com.softegg.freetogo.Api.authencation;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.IOException;
//
///**
// * @description:
// * @author: zhanglinhao
// * @date: 2024/5/23 15:47
// */
//@RestController
//@RequestMapping("/api")
//public class authenticationController {
// @Autowired
// com.softegg.freetogo.Api.authencation.authenticationService authenticationService;
//
// @GetMapping("authenticate")
// public void authenticate(String idc, String phone, String name) throws IOException {
// authenticationService.authenticate(idc, phone, name);
// }
//}

@ -0,0 +1,56 @@
//package com.softegg.freetogo.Api.authencation;
//
//import okhttp3.FormBody;
//import okhttp3.OkHttpClient;
//import okhttp3.Request;
//import okhttp3.Response;
//import org.springframework.stereotype.Service;
//
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.Iterator;
//import java.util.Map;
//
///**
// * @description: 身份验证api
// * @author: zhanglinhao
// * @date: 2024/5/23 15:12
// */
//@Service
//public class authenticationService {
// public void authenticate(String idc, String phone, String name) throws IOException {
// String url = "https://mobile3elements.shumaidata.com/mobile/verify_real_name";
// String appCode = "15704c321ae8459bb36fcadd888d67c4";
//
// Map<String, String> params = new HashMap<>();
// params.put("idcard", idc);
// params.put("mobile", phone);
// params.put("name", name);
// String result = postForm(appCode, url, params);
// System.out.println(result);
// }
//
// /**
// * 用到的HTTP工具包okhttp 3.13.1
// * <dependency>
// * <groupId>com.squareup.okhttp3</groupId>
// * <artifactId>okhttp</artifactId>
// * <version>3.13.1</version>
// * </dependency>
// */
// public static String postForm(String appCode, String url, Map<String, String> params) throws IOException {
// OkHttpClient client = new OkHttpClient.Builder().build();
// FormBody.Builder formbuilder = new FormBody.Builder();
// Iterator<String> it = params.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// formbuilder.add(key, params.get(key));
// }
// FormBody body = formbuilder.build();
// Request request = new Request.Builder().url(url).addHeader("Authorization", "APPCODE " + appCode).post(body).build();
// Response response = client.newCall(request).execute();
// System.out.println("返回状态码" + response.code() + ",message:" + response.message());
// String result = response.body().string();
// return result;
// }
//}

@ -0,0 +1,40 @@
//package com.softegg.freetogo.Api.captcha;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * @description:
// * @author: zhanglinhao
// * @date: 2024/5/24 9:54
// */
//@RestController
//@RequestMapping("/api")
//public class captchaController {
// @Autowired
// private RedisUtil redisUtil;
//
// @RequestMapping("/captcha")
// public JsonResult captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {
// SpecCaptcha specCaptcha = new SpecCaptcha(130, 48, 5);
// String verCode = specCaptcha.text().toLowerCase();
// String key = UUID.randomUUID().toString();
// // 存入redis并设置过期时间为30分钟
// redisUtil.setEx(key, verCode, 30, TimeUnit.MINUTES);
// // 将key和base64返回给前端
// return JsonResult.ok().put("key", key).put("image", specCaptcha.toBase64());
// }
//
// @ResponseBody
// @PostMapping("/login")
// public JsonResult login(String username,String password,String verCode,String verKey){
// // 获取redis中的验证码
// String redisCode = redisUtil.get(verKey);
// // 判断验证码
// if (verCode==null || !redisCode.equals(verCode.trim().toLowerCase())) {
// return JsonResult.error("验证码不正确");
// }
// }
//}

@ -0,0 +1,18 @@
package com.softegg.freetogo.Api.captcha;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.GeneralPath;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Random;
import java.util.UUID;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/24 9:27
*/
public class captchaService {
}

@ -0,0 +1,27 @@
package com.softegg.freetogo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @description:http使
* @author:zhanglinhao
* @date:2024/5/9 15:20
*/
@Configuration
public class Configurer implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
//是否发送Cookie
.allowCredentials(true)
//放行哪些原始域
.allowedOriginPatterns("*")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.exposedHeaders("*");
// registry.addMapping("/**").allowedOrigins("http://106.52.218.118:8090");
}
}

@ -0,0 +1,19 @@
package com.softegg.freetogo.Demand.Dao;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @description:Jpa
* @author:wuyifan
* @date:2024/5/10 19:50
*/
public interface DemandsRepository extends JpaRepository<Demands, Integer> {
List<Demands> findByPhone(String phone);
List<Demands> findByCity(String city);
List<Demands> findByProvince(String province);
}

@ -0,0 +1,53 @@
package com.softegg.freetogo.Demand.bean;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
/**
* @description:demand
* @author:wuyifan
* @date:2024/5/10 11:36
*/
@Entity
@Table(name = "demands")
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Demands {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer did;
@Column
private String phone;//游客手机号码
@Column(name = "tourist_gender")
private boolean touristGender;//游客性别 ture:male, false:female
@Column
private String nickname;//发布需求的游客昵称信息
@Column(name = "create_time")
private String createTime;//需求发布时间
@Column(name = "departure_date")
private String departureDate;//游客需求起始日期
@Column(name = "end_date")
private String endDate;//游客需求结束日期
@Column(name = "sum_day")
private String sumDay;//游客旅游总天数
@Column
private String province;//发布需求的目的省份
@Column
private String city;//发布需求的目的城市
@Column
private String message;//需求备注内容
@Column
private Integer status;//游客需求状态 0未匹配 1请求匹配 2已完成匹配 3已完成所有服务
@Column
private Integer guideServiceId;//游客需求最终匹配到的导游服务id
@ElementCollection
@Column(name = "guide_service_id_list")
private List<Integer> guideServiceIdList;//游客需求申请匹配到的导游服务id
}

@ -0,0 +1,107 @@
package com.softegg.freetogo.Demand.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* @description:Demand
* @author:wuyifan
* @date:2024/5/10 11:40
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/demands")
public class DemandsController {
@Autowired
private DemandsService demandsService;
@GetMapping("findAllRandom")
public List<Demands> findAllRandom() {
List<Demands> dlist = demandsService.findAll();
Collections.shuffle(dlist);
return dlist;
}
@GetMapping("add")
public String add(String phone,
boolean tGender,
String nkn,
String ct,
String dDate,
String eDate,
String sDay,
String province,
String city,
String message,
Integer status,
Integer guideServiceId,
List<Integer> guideServiceIdList) {
Demands demand = new Demands();
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, province, city, message, status, demand, guideServiceId, guideServiceIdList);
demandsService.add(demand);
return "添加成功";
}
@PostMapping("delbyid")
public int delById(@RequestBody Map<String, Object> map) {
int did = Integer.parseInt(map.get("did").toString());
demandsService.deleteById(did);
return 1;
}
@GetMapping("findbyid")
public Demands getUserById(int id) {
return demandsService.getDemandById(id);
}
@GetMapping("update")
public String update(int id,
String phone,
boolean tGender,
String nkn,
String ct,
String dDate,
String eDate,
String sDay,
String province,
String city,
String message,
Integer status,
Integer guideServiceId,
List<Integer> guideServiceIdList) {
Demands demand = demandsService.getDemandById(id);
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, province, city, message, status, demand, guideServiceId, guideServiceIdList);
demandsService.update(demand);
return "更新成功";
}
@GetMapping("getByPhone")
public List<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 province, String city, String message, Integer status, Demands demand,Integer guideServiceId,List<Integer> guideServiceIdList) {
demand.setPhone(phone);
demand.setTouristGender(tGender);
demand.setNickname(nkn);
demand.setCreateTime(ct);
demand.setDepartureDate(dDate);
demand.setEndDate(eDate);
demand.setSumDay(sDay);
demand.setProvince(province);
demand.setCity(city);
demand.setMessage(message);
demand.setStatus(status);
demand.setGuideServiceId(guideServiceId);
demand.setGuideServiceIdList(guideServiceIdList);
}
}

@ -0,0 +1,28 @@
package com.softegg.freetogo.Demand.service;
import com.softegg.freetogo.Demand.bean.Demands;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 2059
*/
public interface DemandsService {
List<Demands> findAll();//查找所有需求
void add(Demands demand);//以demand为用户入库
void deleteById(int id);//删除对应id需求
Demands getDemandById(int id);//获得对应id需求
void update(Demands demand);//更新需求信息
List<Demands> getDemandsByPhone(String phone);//根据手机号获得对应游客用户的服务
List<Demands> getDemandsByCity(String city);//根据手机号获得对应游客用户的服务
List<Demands> getDemandsByProvince(String province);//根据手机号获得对应游客用户的服务
}

@ -0,0 +1,119 @@
package com.softegg.freetogo.Demand.service;
import com.softegg.freetogo.Demand.Dao.DemandsRepository;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Iterator;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 19:50
*/
@Component
public class DemandsServiceImpl implements DemandsService {
@Autowired
private DemandsRepository DemandsRepository;
/**
* @description:
* @param: null
* @return: java.util.List<com.softegg.freetogo.Demand.Bean.Demands>
* @author: wuyifan
* @date: 2024/5/10 19:53
*/
public List<Demands> findAll() {
System.out.println("查询成功");
return DemandsRepository.findAll();
}
/**
* @description: demand
* @param: demand
* @return: void
* @author: wuyifan
* @date: 2024/5/10 19:55
*/
public void add(Demands demand) {
DemandsRepository.save(demand);
System.out.println("添加成功");
}
/**
* @description: id
* @param: id
* @return: void
* @author: wuyifan
* @date: 2024/5/10 19:59
*/
public void deleteById(int did) {
DemandsRepository.deleteById(did);
System.out.println("删除成功对应did:");
}
/**
* @description:
* @param: id
* @return: com.softegg.freetogo.Demand.Bean.Demands
* @author: wuyifan
* @date: 2024/5/10 20:02
*/
public Demands getDemandById(int id) {
return DemandsRepository.findById(id).orElse(null);
}
/**
* @description:
* @param: demand
* @return: void
* @author: wuyifan
* @date: 2024/5/10 20:05
*/
public void update(Demands demand) {
DemandsRepository.save(demand);
System.out.println("需求更新成功");
}
/**
* @description:
* @param: phone
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/15 20:18
*/
public List<Demands> getDemandsByPhone(String phone) {
List<Demands> demandsList = DemandsRepository.findByPhone(phone);
// 使用迭代器的 remove 方法
demandsList.removeIf(demand -> demand.getStatus() == 4);
return demandsList;
}
/**
* @description:
* @param: city
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/15 20:18
*/
public List<Demands> getDemandsByCity(String city) {
return DemandsRepository.findByCity(city);
}
/**
* @description:
* @param: city
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/15 20:18
*/
public List<Demands> getDemandsByProvince(String province) {
return DemandsRepository.findByProvince(province);
}
}

@ -0,0 +1,140 @@
package com.softegg.freetogo.DemandMatch.controller;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.DemandMatch.service.DemandMatchService;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/6/4 14:47
*/
@RestController
@RequestMapping("/DemandMatch")
public class DemandMatchController {
@Autowired
DemandMatchService demandMatchService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/4 14:48
*/
@GetMapping("register")
public List<GuideService> GuideMatch(int did) {
System.out.println("接收的did:"+did);
return demandMatchService.guideMatchAccount(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/4 14:48
*/
@GetMapping("specific")
public List<GuideService> specific(int did, int gid) {
System.out.println("接收的did:"+did);
return demandMatchService.guideMatchAccount(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("match")
public int Match(@RequestBody Map<String, Object> map) {
int did = (int) map.get("did");
System.out.println("接收的did:"+did);
int gid = (int) map.get("gid");
System.out.println("接收的did:"+did);
return demandMatchService.match(did, gid);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@GetMapping("confirmedPage")
public List<GuideService> confirmedpage(int did) {
System.out.println("接收的did:"+did);
return demandMatchService.confirmedPage(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("confirmed")
public int confirmed(@RequestBody Map<String, Object> map) {
int did = Integer.parseInt(map.get("did").toString());
System.out.println("接收的did:"+did);
int gid = Integer.parseInt(map.get("gid").toString());
System.out.println("接收的did:"+gid);
return demandMatchService.confirmed(did, gid);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("refuse")
public int refuse(@RequestBody Map<String, Object> map) {
int did = (int) map.get("did");
System.out.println("接收的did:"+did);
return demandMatchService.refuse(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("finish")
public int finish(@RequestBody Map<String, Object> map) {
int did = (int) map.get("did");
System.out.println("接收的did:"+did);
return demandMatchService.finish(did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("delete")
public int delete(@RequestBody Map<String, Object> map) {
int did = (int) map.get("did");
System.out.println("接收的did:"+did);
return demandMatchService.delete(did);
}
}

@ -0,0 +1,26 @@
package com.softegg.freetogo.DemandMatch.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import java.util.List;
public interface DemandMatchService {
List<GuideService> guideMatchAccount(int did);
int match(int did, int gid);
int confirmed(int did, int gid);
List<GuideService> confirmedPage(int did);
int refuse(int did);
int finish(int did);
int delete(int did);
double timeScore(int gsum, String gddate, String gedate, int dsum, String dddate, String dedate);
double messageScore(String gmessage, String dmessage);
}

@ -0,0 +1,401 @@
package com.softegg.freetogo.DemandMatch.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.User.service.UsersService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static java.lang.Math.abs;
import java.time.LocalDate;
/**
* description:
* @author:wuyifan
* date:2024/5/28 19:51
*/
@Component
public class DemandMatchServiceImpl implements DemandMatchService{
@Autowired
DemandsService demandsService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: city
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public List<GuideService> guideMatchAccount(int did){
Demands demand = demandsService.getDemandById(did);
int demandSumDay = Integer.parseInt(demand.getSumDay());
String demandDepartureDate = demand.getDepartureDate();
String demandEndDate = demand.getEndDate();
String demandMessage = demand.getMessage();
List<GuideService> guideServiceList = guideServiceService.getGuideServiceByCity(demand.getCity());
// 使用迭代器的 remove 方法
guideServiceList.removeIf(guideService -> guideService.getStatus() > 1);
int length = guideServiceList.size();
double[] sumScores = new double[length];
int i = 0;
for (GuideService guideService : guideServiceList) {
double sumScore = 0;
int guideServiceSumDay = Integer.parseInt(guideService.getSumDay());
String guideServiceDepartureDate = guideService.getDepartureDate();
String guideServiceEndDate = guideService.getEndDate();
String guideServiceMessage = guideService.getMessage();
double timeScore = timeScore(guideServiceSumDay, guideServiceDepartureDate, guideServiceEndDate, demandSumDay, demandDepartureDate, demandEndDate);
double messageScore = messageScore(guideServiceMessage, demandMessage);
sumScore += timeScore + messageScore;
sumScores[i] = sumScore;
i++;
}
// 创建一个包含索引和值的列表
List<Map.Entry<Double, GuideService>> list = new ArrayList<>();
for (int j = 0; j < sumScores.length; j++) {
list.add(new AbstractMap.SimpleEntry<>(sumScores[j], guideServiceList.get(j)));
}
// 根据sumScores的元素大小对 list 进行排序
list.sort((o1, o2) -> o2.getKey().compareTo(o1.getKey()));
List<GuideService> newgList = new ArrayList<>();
for (Map.Entry<Double, GuideService> entry : list) {
newgList.add(entry.getValue());
}
return newgList;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int match(int did, int gid){
Demands demand = demandsService.getDemandById(did);
GuideService guideService = guideServiceService.getGuideServiceById(gid);
List<Integer> demandIdList = guideService.getDemandIdList();
if (demandIdList == null) {
demandIdList = new ArrayList<>();
}
if(!demandIdList.contains(did)) {
demandIdList.add(did);
}
guideService.setStatus(1);
guideService.setDemandIdList(demandIdList);
demandsService.update(demand);
guideServiceService.update(guideService);
System.out.println(guideService.getDemandIdList());
return 1006;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int confirmed(int did, int gid){
Demands demand = demandsService.getDemandById(did);
GuideService guideService = guideServiceService.getGuideServiceById(gid);
demand.setStatus(2);
demand.setGuideServiceId(gid);
guideService.setStatus(2);
guideService.setDemandId(did);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1007;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public List<GuideService> confirmedPage(int did){
Demands demand = demandsService.getDemandById(did);
List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
List<GuideService> guideServiceList = new ArrayList<>();
for(int number : guideServiceIdList) {
GuideService guideService = guideServiceService.getGuideServiceById(number);
guideServiceList.add(guideService);
}
return guideServiceList;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int refuse(int did){
Demands demand = demandsService.getDemandById(did);
int gid = demand.getGuideServiceId();
GuideService guideService = guideServiceService.getGuideServiceById(gid);
List<Integer> demandIdList = guideService.getDemandIdList();
if (demandIdList == null) {
guideService.setStatus(0);
}else {
guideService.setStatus(1);
}
List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
if(guideServiceIdList == null){
demand.setStatus(0);
}else {
demand.setStatus(1);
}
demand.setGuideServiceId(null);
guideService.setDemandId(null);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int finish(int did){
Demands demand = demandsService.getDemandById(did);
int gid = demand.getGuideServiceId();
GuideService guideService = guideServiceService.getGuideServiceById(gid);
demand.setStatus(3);
demand.setGuideServiceIdList(null);
guideService.setStatus(3);
guideService.setDemandIdList(null);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int delete(int did){
Demands demand = demandsService.getDemandById(did);
demand.setStatus(4);
demandsService.update(demand);
return 1;
}
public static boolean isRangeWithinRange(LocalDate startDate1, LocalDate endDate1, LocalDate startDate2, LocalDate endDate2) {
// 第一个范围的起始日期必须在第二个范围内或与其起始日期相同
return !startDate1.isBefore(startDate2) && !endDate1.isAfter(endDate2);
}
/**
* @description:
* @param: gsumdsumddateedate
* @return: float
* @author: wuyifan
* @date: 2024/5/28 20:35
*/
@Override
public double timeScore(int gsum, String gddate, String gedate, int dsum, String dddate, String dedate){
double score = 0;
int difference = gsum - dsum;
if (abs(difference) < 15 ){
score += 10 / (float)(abs(difference) + 1);
}
// 使用DateTimeFormatter将字符串转换为LocalDate对象
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate1 = LocalDate.parse(dddate, formatter);
LocalDate endDate1 = LocalDate.parse(dedate, formatter);
LocalDate startDate2 = LocalDate.parse(gddate, formatter);
LocalDate endDate2 = LocalDate.parse(gedate, formatter);
// 判断第一个范围是否在第二个范围内
boolean isRange1WithinRange2 = isRangeWithinRange(startDate1, endDate1, startDate2, endDate2);
if (isRange1WithinRange2){
score += 100;
}
return score;
}
/**
* @description: Jaccard
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:35
*/
public static double jaccardSimilarity(String s1, String s2) {
if (s1 == null || s2 == null ) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Set<Character> set1 = new HashSet<>();
Set<Character> set2 = new HashSet<>();
for (char c : s1.toCharArray()) {
set1.add(c);
}
for (char c : s2.toCharArray()) {
set2.add(c);
}
Set<Character> intersection = new HashSet<>(set1);
intersection.retainAll(set2);
Set<Character> union = new HashSet<>(set1);
union.addAll(set2);
return (double) intersection.size() / union.size();
}
/**
* @description:
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:35
*/
private static Map<Character, Integer> getCharacterFrequency(String s) {
Map<Character, Integer> frequencyMap = new HashMap<>();
for (char c : s.toCharArray()) {
frequencyMap.put(c, frequencyMap.getOrDefault(c, 0) + 1);
}
return frequencyMap;
}
public static double cosineSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Map<Character, Integer> freq1 = getCharacterFrequency(s1);
Map<Character, Integer> freq2 = getCharacterFrequency(s2);
double dotProduct = 0.0;
double mag1 = 0.0;
double mag2 = 0.0;
for (char c : freq1.keySet()) {
if (freq2.containsKey(c)) {
dotProduct += freq1.get(c) * freq2.get(c);
}
mag1 += Math.pow(freq1.get(c), 2);
}
for (char c : freq2.keySet()) {
mag2 += Math.pow(freq2.get(c), 2);
}
mag1 = Math.sqrt(mag1);
mag2 = Math.sqrt(mag2);
return dotProduct / (mag1 * mag2);
}
/**
* @description: Dice
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:25
*/
public static double diceCoefficient(String s1, String s2) {
if (s1 == null || s2 == null ) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
int intersection = 0;
for (int i = 0; i < s1.length() - 1; i++) {
String bigram = s1.substring(i, i + 2);
if (s2.contains(bigram)) {
intersection++;
}
}
int union = s1.length() + s2.length() - intersection;
return (double) (2 * intersection) / union;
}
/**
* @description: N-gram
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:22
*/
private static Set<String> generateNGrams(String s, int n) {
if (s == null || s.length() < n || n <= 0) {
throw new IllegalArgumentException("Invalid input string or n-gram size");
}
Set<String> nGrams = new HashSet<>();
for (int i = 0; i <= s.length() - n; i++) {
nGrams.add(s.substring(i, i + n));
}
return nGrams;
}
public static double bigramSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Set<String> bigrams1 = generateNGrams(s1, 2);
Set<String> bigrams2 = generateNGrams(s2, 2);
Set<String> commonBigrams = new HashSet<>(bigrams1);
commonBigrams.retainAll(bigrams2);
Set<String> allBigrams = new HashSet<>(bigrams1);
allBigrams.addAll(bigrams2);
return (double) commonBigrams.size() / allBigrams.size();
}
/**
* @description:
* @param: gmessagedmessage
* @return: float
* @author: wuyifan
* @date: 2024/5/28 20:35
*/
@Override
public double messageScore(String gmessage, String dmessage){
double score;
double similarity1 = jaccardSimilarity(gmessage, dmessage);
double similarity2 = cosineSimilarity(gmessage, dmessage);
double similarity3 = diceCoefficient(gmessage, dmessage);
double similarity4 = bigramSimilarity(gmessage, dmessage);
score = similarity1 + similarity2 + similarity3 + similarity4;
return score;
}
}

@ -0,0 +1,15 @@
package com.softegg.freetogo.Evaluate.Dao;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @description: Jpa
* @author: zhanglinhao
* @date: 2024/5/10 9:27
*/
public interface EvaluateRepository extends JpaRepository<Evaluations, Integer> {
// List<Evaluations> findByEditorPhone(String phone);
// List<Evaluations> findByEditedPhone(String phone);
}

@ -0,0 +1,32 @@
package com.softegg.freetogo.Evaluate.bean;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/10 9:07
*/
@Entity
@Table(name = "evaluation")
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Evaluations {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int eid;//评价id
@Column(name = "createtime")
private String ct;//创建日期
@Column(name = "modifytime")
private String mt;//编辑日期
@Column
private String ebody;//评价本体
@Column
private int satisfaction;//满意度整数1-5
}

@ -0,0 +1,115 @@
package com.softegg.freetogo.Evaluate.controller;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import com.softegg.freetogo.Evaluate.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/11 17:33
*/
@RestController
@RequestMapping("/evaluate")
public class EvaluationController {
@Autowired
EvaluateService evaluateService;
/**
* @description:
* @param: null
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/12 0:11
*/
@GetMapping("findAllEvaluation")
public List<Evaluations> findAllEvaluation() {
return evaluateService.evaluationList();
}
/**
* @description:
* @param: ebody
* @return: void
* @author: zhanglinhao
* @date: 2024/5/12 0:28
*/
@PostMapping("addEvaluation")
public void addEvaluation(@RequestBody Map<String, String> ebody) {
LocalDateTime currentTime = LocalDateTime.now();
Evaluations evaluation = new Evaluations();
evaluation.setEid(Integer.parseInt(ebody.get("eid")));
evaluation.setEbody(ebody.get("ebody"));
evaluation.setSatisfaction(Integer.parseInt(ebody.get("satisfaction")));
evaluation.setCt(currentTime.toString());
evaluation.setMt(currentTime.toString());
evaluateService.addEvaluation(evaluation);
}
/**
* @description:
* @param: phone
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/12 0:30
*/
// @GetMapping("evaluationByPhone")
// public List<Evaluations> evaluationByPhone(String phone) {
// return evaluateService.getEListByPhone(phone);
// }
@GetMapping("getEvaluation")
public Evaluations getEvaluation(int eid) {
return evaluateService.getEvaluationById(eid);
}
/**
* @description:
* @param: eid
* @param: ebody
* @return: void
* @author: zhanglinhao
* @date: 2024/5/12 13:31
*/
@PostMapping("editEvaluation")
public void editEvaluation(@RequestBody Map<String, String> ebody) {
System.out.println("接收的json:" + ebody);
LocalDateTime currentTime = LocalDateTime.now();
Evaluations evaluation = new Evaluations(Integer.parseInt(ebody.get("eid")), ebody.get("ct"), currentTime.toString(), ebody.get("ebody"), Integer.parseInt(ebody.get("satisfaction")));
evaluateService.editEvaluation(evaluation);
}
/**
* @description:
* @param: eid
* @return: void
* @author: zhanglinhao
* @date: 2024/5/12 13:32
*/
@GetMapping("deleteEvaluation")
public void deleteEvaluation(int eid) {
evaluateService.deleteEvaluation(eid);
}
/**
* @description:
* @param: phone
* @return: int
* @author: zhanglinhao
* @date: 2024/5/12 13:39
*/
// @GetMapping("getSatisfaction")
// public String getSatisfaction(String phone) {
// List<Evaluations> elist = evaluateService.getEvaluatedByPhone(phone);
// float sumOfSatisfaction = 0;
// for (Evaluations evaluation : elist) {
// sumOfSatisfaction += evaluation.getSatisfaction();
// }
// System.out.println("查询满意度:"+ sumOfSatisfaction);
// return Float.toString(sumOfSatisfaction /elist.size());
// }
}

@ -0,0 +1,27 @@
package com.softegg.freetogo.Evaluate.service;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/10 8:52
*/
@Service
public interface EvaluateService {
List<Evaluations> evaluationList();//获取所有评论
// List<Evaluations> getEListByPhone(String phone);//根据电话筛选评价
// List<Evaluations> getEvaluatedByPhone(String phone);
Evaluations getEvaluationById(int eid);//根据id获取评论
void addEvaluation(Evaluations evaluation);//添加评论
void editEvaluation(Evaluations evaluation);//编辑评论
void deleteEvaluation(int eid);//删除评论
}

@ -0,0 +1,112 @@
package com.softegg.freetogo.Evaluate.service;
import com.softegg.freetogo.Evaluate.Dao.EvaluateRepository;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/10 9:25
*/
@Component
public class EvaluateServiceImpl implements EvaluateService {
@Autowired
EvaluateRepository evaluateRepository;
/**
* @description:
* @param: null
* @return: void
* @author: zhanglinhao
* @date: 2024/5/10 9:25
*/
@Override
public List<Evaluations> evaluationList() {
System.out.println("查询评论");
return evaluateRepository.findAll();
}
/**
* @description: id
* @param: eid
* @return: com.softegg.freetogo.Evaluate.bean.Evaluations
* @author: zhanglinhao
* @date: 2024/5/15 8:13
*/
@Override
public Evaluations getEvaluationById(int eid) {
return evaluateRepository.findById(eid).get();
}
/**
* @description:
* @param: phone
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/11 16:28
*/
// @Override
// public List<Evaluations> getEListByPhone(String phone) {
// System.out.println("查询" + phone + "的评论");
// return evaluateRepository.findByEditorPhone(phone);
// }
/**
* @description:
* @param: phone
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/12 21:21
*/
// @Override
// public List<Evaluations> getEvaluatedByPhone(String phone) {
// return evaluateRepository.findByEditedPhone(phone);
// }
/**
* @description:
* @param: evaluation
* @return: void
* @author: zhanglinhao
* @date: 2024/5/10 21:20
*/
@Override
public void addEvaluation(Evaluations evaluation) {
evaluateRepository.save(evaluation);
System.out.println("添加评论:" + evaluation.getEbody());
}
/**
* @description:
* @param: eid
* @return: void
* @author: zhanglinhao
* @date: 2024/5/11 17:10
*/
@Override
public void editEvaluation(Evaluations evaluation) {
int eid = evaluation.getEid();
System.out.println("编辑评论:" + eid);
evaluateRepository.save(evaluation);
System.out.println("编辑成功:" + eid);
}
/**
* @description:
* @param: eid
* @return: void
* @author: zhanglinhao
* @date: 2024/5/11 17:28
*/
@Override
public void deleteEvaluation(int eid) {
evaluateRepository.deleteById(eid);
System.out.println("删除评论:" + eid);
}
}

@ -0,0 +1,9 @@
package com.softegg.freetogo.FeedBack;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/20 11:14
*/
public class bean {
}

@ -0,0 +1,13 @@
package com.softegg.freetogo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class FreeToGoApplication {
public static void main(String[] args) {
SpringApplication.run(FreeToGoApplication.class, args);
}
}

@ -0,0 +1,119 @@
package com.softegg.freetogo.GuideMatch.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.GuideMatch.service.GuideMatchService;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/5/30 10:47
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/GuideMatch")
public class GuideMatchController {
@Autowired
GuideMatchService guideMatchService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/30 20:48
*/
@GetMapping("register")
public List<Demands> GuideMatch(int gid) {
System.out.println("需匹配的gid:" + gid);
return guideMatchService.guideMatchAccount(gid);
}
/**
* @description:
* @param: map
* @return: java.lang.int
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("match")
public int Match(@RequestBody Map<String, Object> map) {
int gid = Integer.parseInt(map.get("gid").toString());
System.out.println("接收的gid:"+gid);
int did = Integer.parseInt(map.get("did").toString());
System.out.println("接收的did:"+did);
return guideMatchService.match(gid, did);
}
/**
* @description:
* @param: gid
* @return: java.lang.Demands
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@GetMapping("confirmedPage")
public List<Demands> confirmedpage(int gid) {
System.out.println("接收的gid:"+gid);
return guideMatchService.confirmedPage(gid);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("confirmed")
public int confirmed(@RequestBody Map<String, Object> map) {
int gid = Integer.parseInt(map.get("gid").toString());
System.out.println("接收的did:"+gid);
int did = Integer.parseInt(map.get("did").toString());
System.out.println("接收的did:"+did);
return guideMatchService.confirmed(gid, did);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("refuse")
public int refuse(@RequestBody Map<String, Object> map) {
int gid = (int) map.get("gid");
System.out.println("接收的gid:"+gid);
return guideMatchService.refuse(gid);
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/11 1012
*/
@PostMapping("delete")
public int delete(@RequestBody Map<String, Object> map) {
int gid = (int) map.get("gid");
System.out.println("接收的gid:"+gid);
return guideMatchService.delete(gid);
}
}

@ -0,0 +1,31 @@
package com.softegg.freetogo.GuideMatch.service;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/28 19:45
*/
@Service
public interface GuideMatchService {
List<Demands> guideMatchAccount(int gid);
int match(int gid, int did);
List<Demands> confirmedPage(int gid);
int confirmed(int did, int gid);
int refuse(int gid);
int delete(int gid);
double timeScore(int gsum, String gddate, String gedate, int dsum, String dddate, String dedate);
double messageScore(String gmessage, String dmessage);
}

@ -0,0 +1,384 @@
package com.softegg.freetogo.GuideMatch.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.User.service.UsersService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static java.lang.Math.abs;
/**
* description:
* @author:wuyifan
* date:2024/5/28 19:51
*/
@Component
public class GuideMatchServiceImpl implements GuideMatchService {
@Autowired
DemandsService demandsService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: city
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public List<Demands> guideMatchAccount(int gid){
GuideService guideService = guideServiceService.getGuideServiceById(gid);
int guideServiceSumDay = Integer.parseInt(guideService.getSumDay());
String guideServiceDepartureDate = guideService.getDepartureDate();
String guideServiceEndDate = guideService.getEndDate();
String guideServiceMessage = guideService.getMessage();
List<Demands> dlist = demandsService.getDemandsByCity(guideService.getCity());
// 使用迭代器的 remove 方法
dlist.removeIf(demand -> demand.getStatus() > 1);
int length = dlist.size();
double[] sumScores = new double[length];
int i = 0;
for (Demands demands : dlist) {
double sumScore = 0;
int demandsSumDay = Integer.parseInt(demands.getSumDay());
String demandsDepartureDate = demands.getDepartureDate();
String demandsEndDate = demands.getEndDate();
String demandsMessage = demands.getMessage();
double timeScore = timeScore(guideServiceSumDay,guideServiceDepartureDate,guideServiceEndDate,demandsSumDay,demandsDepartureDate,demandsEndDate);
double messageScore = messageScore(guideServiceMessage, demandsMessage);
sumScore += timeScore + messageScore;
sumScores[i] = sumScore;
i++;
}
// 创建一个包含索引和值的列表
List<Map.Entry<Double, Demands>> list = new ArrayList<>();
for (int j = 0; j < sumScores.length; j++) {
list.add(new AbstractMap.SimpleEntry<>(sumScores[j], dlist.get(j)));
}
// 根据sumScores的元素大小对 list 进行排序
list.sort((o1, o2) -> o2.getKey().compareTo(o1.getKey()));
List<Demands> newdList = new ArrayList<>();
for (Map.Entry<Double, Demands> entry : list) {
newdList.add(entry.getValue());
}
return newdList;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int match(int gid, int did){
Demands demand = demandsService.getDemandById(did);
GuideService guideService = guideServiceService.getGuideServiceById(gid);
demand.setStatus(1);
List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
if (guideServiceIdList == null) {
guideServiceIdList = new ArrayList<>();
}
if(!guideServiceIdList.contains(gid)){
guideServiceIdList.add(gid);
}
demand.setGuideServiceIdList(guideServiceIdList);
// List<Integer> demandIdList = guideService.getDemandIdList();
// if (demandIdList == null) {
// demandIdList = new ArrayList<>();
// }
// demandIdList.add(did);
// guideService.setDemandIdList(demandIdList);
demandsService.update(demand);
guideServiceService.update(guideService);
System.out.println(demand.getGuideServiceIdList());
return 1006;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public List<Demands> confirmedPage(int gid){
GuideService guideService = guideServiceService.getGuideServiceById(gid);
List<Integer> demandIdList = guideService.getDemandIdList();
List<Demands> demandsList = new ArrayList<>();
for(int number : demandIdList) {
Demands demand = demandsService.getDemandById(number);
demandsList.add(demand);
}
return demandsList;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int confirmed(int gid, int did){
Demands demand = demandsService.getDemandById(did);
GuideService guideService = guideServiceService.getGuideServiceById(gid);
demand.setStatus(2);
demand.setGuideServiceId(gid);
guideService.setStatus(2);
guideService.setDemandId(did);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1007;
}
/**
* @description:
* @param: did,gid
* @return: int
* author: wuyifan
* @date: 2024/5/28 19:52
*/
@Override
public int refuse(int gid){
GuideService guideService = guideServiceService.getGuideServiceById(gid);
int did = guideService.getDemandId();
Demands demand = demandsService.getDemandById(gid);
List<Integer> demandIdList = guideService.getDemandIdList();
if (demandIdList == null) {
guideService.setStatus(0);
}else {
guideService.setStatus(1);
}
List<Integer> guideServiceIdList = demand.getGuideServiceIdList();
if(guideServiceIdList == null){
demand.setStatus(0);
}else {
demand.setStatus(1);
}
guideService.setDemandId(null);
demand.setGuideServiceId(null);
demandsService.update(demand);
guideServiceService.update(guideService);
return 1;
}
@Override
public int delete(int gid){
GuideService guideService = guideServiceService.getGuideServiceById(gid);
guideService.setStatus(4);
guideServiceService.update(guideService);
return 1;
}
public static boolean isRangeWithinRange(LocalDate startDate1, LocalDate endDate1, LocalDate startDate2, LocalDate endDate2) {
return !startDate1.isBefore(startDate2) && !endDate1.isAfter(endDate2);
}
/**
* @description:
* @param: gsumdsumddateedate
* @return: float
* @author: wuyifan
* @date: 2024/5/28 20:35
*/
@Override
public double timeScore(int gsum, String gddate, String gedate, int dsum, String dddate, String dedate){
double score = 0;
int difference = gsum - dsum;
if (abs(difference) < 15 ){
score += 10 / (float)(abs(difference) + 1);
}
// 使用DateTimeFormatter将字符串转换为LocalDate对象
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate1 = LocalDate.parse(dddate, formatter);
LocalDate endDate1 = LocalDate.parse(dedate, formatter);
System.out.println(startDate1);
System.out.println(endDate1);
LocalDate startDate2 = LocalDate.parse(gddate, formatter);
LocalDate endDate2 = LocalDate.parse(gedate, formatter);
System.out.println(startDate2);
System.out.println(endDate2);
// 判断第一个范围是否在第二个范围内
boolean isRange1WithinRange2 = isRangeWithinRange(startDate1, endDate1, startDate2, endDate2);
if (isRange1WithinRange2){
score += 100;
}
return score;
}
/**
* @description: Jaccard
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:35
*/
public static double jaccardSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Set<Character> set1 = new HashSet<>();
Set<Character> set2 = new HashSet<>();
for (char c : s1.toCharArray()) {
set1.add(c);
}
for (char c : s2.toCharArray()) {
set2.add(c);
}
Set<Character> intersection = new HashSet<>(set1);
intersection.retainAll(set2);
Set<Character> union = new HashSet<>(set1);
union.addAll(set2);
return (double) intersection.size() / union.size();
}
/**
* @description:
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:35
*/
private static Map<Character, Integer> getCharacterFrequency(String s) {
Map<Character, Integer> frequencyMap = new HashMap<>();
for (char c : s.toCharArray()) {
frequencyMap.put(c, frequencyMap.getOrDefault(c, 0) + 1);
}
return frequencyMap;
}
public static double cosineSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Map<Character, Integer> freq1 = getCharacterFrequency(s1);
Map<Character, Integer> freq2 = getCharacterFrequency(s2);
double dotProduct = 0.0;
double mag1 = 0.0;
double mag2 = 0.0;
for (char c : freq1.keySet()) {
if (freq2.containsKey(c)) {
dotProduct += freq1.get(c) * freq2.get(c);
}
mag1 += Math.pow(freq1.get(c), 2);
}
for (char c : freq2.keySet()) {
mag2 += Math.pow(freq2.get(c), 2);
}
mag1 = Math.sqrt(mag1);
mag2 = Math.sqrt(mag2);
return dotProduct / (mag1 * mag2);
}
/**
* @description: Dice
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:25
*/
public static double diceCoefficient(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
int intersection = 0;
for (int i = 0; i < s1.length() - 1; i++) {
String bigram = s1.substring(i, i + 2);
if (s2.contains(bigram)) {
intersection++;
}
}
int union = s1.length() + s2.length() - intersection;
return (double) (2 * intersection) / union;
}
/**
* @description: N-gram
* @param: String
* @return: float
* @author: wuyifan
* @date: 2024/5/30 20:22
*/
private static Set<String> generateNGrams(String s, int n) {
if (s == null || s.length() < n || n <= 0) {
throw new IllegalArgumentException("Invalid input string or n-gram size");
}
Set<String> nGrams = new HashSet<>();
for (int i = 0; i <= s.length() - n; i++) {
nGrams.add(s.substring(i, i + n));
}
return nGrams;
}
public static double bigramSimilarity(String s1, String s2) {
if (s1 == null || s2 == null || s1.isEmpty() || s2.isEmpty()) {
return 0.0; // 如果任何一个字符串为空直接返回0
}
Set<String> bigrams1 = generateNGrams(s1, 2);
Set<String> bigrams2 = generateNGrams(s2, 2);
Set<String> commonBigrams = new HashSet<>(bigrams1);
commonBigrams.retainAll(bigrams2);
Set<String> allBigrams = new HashSet<>(bigrams1);
allBigrams.addAll(bigrams2);
return (double) commonBigrams.size() / allBigrams.size();
}
/**
* @description:
* @param: gmessagedmessage
* @return: float
* @author: wuyifan
* @date: 2024/5/28 20:35
*/
@Override
public double messageScore(String gmessage, String dmessage){
double score;
double similarity1 = jaccardSimilarity(gmessage, dmessage);
double similarity2 = cosineSimilarity(gmessage, dmessage);
double similarity3 = diceCoefficient(gmessage, dmessage);
double similarity4 = bigramSimilarity(gmessage, dmessage);
score = similarity1 + similarity2 + similarity3 + similarity4;
return score;
}
}

@ -0,0 +1,20 @@
package com.softegg.freetogo.GuideService.Dao;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @description:Jpa
* @author:wuyifan
* @date:2024/5/13 9:17
*/
public interface GuideServiceRepository extends JpaRepository<GuideService, Integer> {
List<GuideService> findByPhone(String phone);
List<GuideService> findByCity(String city);
List<GuideService> findByProvince(String province);
}

@ -0,0 +1,53 @@
package com.softegg.freetogo.GuideService.bean;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
/**
* @description:guideService
* @author:wuyifan
* @date:2024/5/13 9:14
*/
@Entity
@Table(name = "guideService")
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class GuideService {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer gid;
@Column
private String phone;//导游手机号码
@Column(name = "guide_gender")
private boolean guideGender;//导游性别 ture:male, false:female
@Column
private String nickname;//发布需求的导游昵称信息
@Column(name = "create_time")
private String createTime;//服务发布时间
@Column(name = "departure_date")
private String departureDate;//导游服务起始日期
@Column(name = "end_date")
private String endDate;//导游服务结束日期
@Column(name = "sum_day")
private String sumDay;//导游服务总天数
@Column
private String province;//导游服务的目的省份
@Column
private String city;//导游服务的目的城市
@Column
private String message;//导游服务备注内容
@Column
private Integer status;//导游服务状态 0未匹配 1请求匹配 2已完成匹配 3已完成所有服务
@Column
private Integer demandId;//导游服务最终匹配到的游客需求id
@ElementCollection
@Column
private List<Integer> demandIdList;//游客需求申请匹配到的导游服务id
}

@ -0,0 +1,103 @@
package com.softegg.freetogo.GuideService.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:Guide
* @author:wuyifan
* @date:2024/5/13 9:26
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/guideService")
public class GuideServiceController {
@Autowired
private GuideServiceService guideServiceService;
@GetMapping("findAll")
public List<GuideService> findAll() {
return guideServiceService.findAll();
}
@GetMapping("add")
public String add(String phone,
boolean gGender,
String nkn,
String ct,
String dDate,
String eDate,
String sDay,
String procvince,
String city,
String message,
Integer status,
Integer demandId,
List<Integer> demandIdList) {
GuideService guideService = new GuideService();
setDemands(phone, gGender, nkn, ct, dDate, eDate, sDay, procvince, city, message, status, guideService, demandId, demandIdList);
guideServiceService.add(guideService);
return "添加成功";
}
@PostMapping("delbyid")
public String delById(@RequestBody Map<String, Object> map) {
int gid = (int) map.get("gid");
guideServiceService.deleteById(gid);
return "1";
}
@GetMapping("findbyid")
public GuideService getUserById(int gid) {
return guideServiceService.getGuideServiceById(gid);
}
@GetMapping("getByPhone")
public List<GuideService> getByPhone(String phone) {
System.out.println("根据手机号获取游客需求信息:" + phone);
return guideServiceService.getGuideServiceByPhone(phone);
}
@GetMapping("update")
public String update(int id,
String phone,
boolean gGender,
String nkn,
String ct,
String dDate,
String eDate,
String sDay,
String province,
String city,
String message,
Integer status,
Integer demandId,
List<Integer> demandIdList) {
GuideService guideService = guideServiceService.getGuideServiceById(id);
setDemands(phone, gGender, nkn, ct, dDate, eDate, sDay, province, city, message, status, guideService, demandId, demandIdList);
guideServiceService.update(guideService);
return "更新成功";
}
private void setDemands(String phone, boolean gGender, String nkn, String ct, String dDate, String eDate, String sDay, String province, String city, String message, Integer status, GuideService guideservice, Integer demandId, List<Integer> demandIdList) {
guideservice.setPhone(phone);
guideservice.setGuideGender(gGender);
guideservice.setNickname(nkn);
guideservice.setCreateTime(ct);
guideservice.setDepartureDate(dDate);
guideservice.setEndDate(eDate);
guideservice.setSumDay(sDay);
guideservice.setProvince(province);
guideservice.setCity(city);
guideservice.setMessage(message);
guideservice.setStatus(status);
guideservice.setDemandId(demandId);
guideservice.setDemandIdList(demandIdList);
}
}

@ -0,0 +1,28 @@
package com.softegg.freetogo.GuideService.service;
import com.softegg.freetogo.GuideService.bean.GuideService;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 2059
*/
public interface GuideServiceService {
List<GuideService> findAll();//查找所有需求
void add(GuideService guideService);//以demand为用户入库
void deleteById(int id);//删除对应id需求
GuideService getGuideServiceById(int id);//获得对应id需求
void update(GuideService guideService);//更新需求信息
List<GuideService> getGuideServiceByPhone(String phone);//获得对应手机号的导游用户的所有服务
List<GuideService> getGuideServiceByCity(String city);//根据所选城市获得导游服务列表
List<GuideService> getGuideServiceByProvince(String province);//根据所选城市获得导游服务列表
}

@ -0,0 +1,123 @@
package com.softegg.freetogo.GuideService.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.GuideService.Dao.GuideServiceRepository;
import com.softegg.freetogo.GuideService.bean.GuideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Iterator;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/13 9:19
*/
@Component
public class GuideServiceServiceImpl implements GuideServiceService {
@Autowired
private GuideServiceRepository GuideServiceRepository;
@Autowired
private GuideServiceRepository guideServiceRepository;
/**
* @description:
* @param: null
* @return: java.util.List<com.softegg.freetogo.GuideService.Bean.GuideService>
* @author: wuyifan
* @date: 2024/5/13 9:21
*/
public List<GuideService> findAll() {
System.out.println("查询成功");
return GuideServiceRepository.findAll();
}
/**
* @description: guideService
* @param: guideService
* @return: void
* @author: wuyifan
* @date: 2024/5/13 922
*/
public void add(GuideService guideService) {
GuideServiceRepository.save(guideService);
System.out.println("添加成功");
}
/**
* @description: id
* @param: id
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/10 20:02
*/
public GuideService getGuideServiceById(int id) {
return GuideServiceRepository.findById(id).orElse(null);
}
/**
* @description: gid
* @param: id
* @return: void
* @author: zhanglinhao
* @date: 2024/5/9 22:53
*/
public void deleteById(int gid) {
guideServiceRepository.deleteById(gid);
System.out.println("删除成功:" + gid);
}
/**
* @description:
* @param: guideService
* @return: void
* @author: wuyifan
* @date: 2024/5/10 20:05
*/
public void update(GuideService guideService) {
GuideServiceRepository.save(guideService);
System.out.println("服务更新成功");
}
/**
* @description:
* @param: phone
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/16 15:18
*/
public List<GuideService> getGuideServiceByPhone(String phone) {
List<GuideService> guideServiceList = GuideServiceRepository.findByPhone(phone);
// 使用迭代器的 remove 方法
guideServiceList.removeIf(guideService -> guideService.getStatus() == 4);
return guideServiceList;
}
/**
* @description:
* @param: city
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/16 15:30
*/
public List<GuideService> getGuideServiceByCity(String city) {
return GuideServiceRepository.findByCity(city);
}
/**
* @description:
* @param: city
* @return: com.softegg.freetogo.GuideService.Bean.GuideService
* @author: wuyifan
* @date: 2024/5/16 15:30
*/
public List<GuideService> getGuideServiceByProvince(String province) {
return GuideServiceRepository.findByProvince(province);
}
}

@ -0,0 +1,4 @@
package com.softegg.freetogo.HeatMap.controller;
public class HeatMapController {
}

@ -0,0 +1,11 @@
package com.softegg.freetogo.HeatMap.service;
public interface HeatMapService {
int[] provinceDemandsHeatMap();//获得每个省份的游客需求数目
int[] cityDemandsHeatMap(String province);//获得目标省份的游客需求数目
int[] provinceGuideServiceHeatMap();
int[] cityGuideServiceHeatMap(String province);
}

@ -0,0 +1,192 @@
package com.softegg.freetogo.HeatMap.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.GuideService.bean.GuideService;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* description:
* @author:wuyifan
* date:2024/6/6 10:51
*/
@Component
public class HeatMapServiceImpl implements HeatMapService {
@Autowired
DemandsService demandsService;
@Autowired
GuideServiceService guideServiceService;
public static void main(String[] args) {
List<String> provinceList = new ArrayList<>();
JSONParser parser = new JSONParser();
try {
// 读取 JSON 文件内容并解析为 JSONObject
Object obj = parser.parse(new FileReader("C:/Users/WYF/Desktop/软件体系结构/FreeToGo/src/main/java/com/softegg/freetogo/HeatMap/service/area.json")); // 直接使用文件名表示相对路径
JSONObject jsonObject = (JSONObject) obj;
for (Object province : jsonObject.keySet()) {
provinceList.add(province.toString());
}
System.out.println("所有省份列表:");
for (String province : provinceList) {
System.out.println(province);
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
}
/**
* @description: List
* @param: null
* @return: List<String>
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
public List<String> getAllProvinces() {
List<String> provinceList = new ArrayList<>();
JSONParser parser = new JSONParser();
try {
// 读取 JSON 文件内容并解析为 JSONObject
Object obj = parser.parse(new FileReader("C:/Users/WYF/Desktop/软件体系结构/FreeToGo/src/main/java/com/softegg/freetogo/HeatMap/service/area.json"));
JSONObject jsonObject = (JSONObject) obj;
// 遍历每个省份
for (Object province : jsonObject.keySet()) {
// 将省份添加到列表中
provinceList.add(province.toString());
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
return provinceList;
}
/**
* @description: List
* @param: String
* @return: List<String>
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
public List<String> getCitiesInProvince(String province) {
List<String> cityList = new ArrayList<>();
JSONParser parser = new JSONParser();
try {
// 读取 JSON 文件内容并解析为 JSONObject
Object obj = parser.parse(new FileReader("C:/Users/WYF/Desktop/软件体系结构/FreeToGo/src/main/java/com/softegg/freetogo/HeatMap/service/area.json"));
JSONObject jsonObject = (JSONObject) obj;
// 获取湖南省的城市信息
JSONObject hunanCities = (JSONObject) jsonObject.get(province);
// 遍历每个城市并将城市名称添加到列表中
for (Object city : hunanCities.keySet()) {
cityList.add(city.toString());
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
return cityList;
}
/**
* @description:
* @param: null
* @return: int[]
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
@Override
public int[] provinceDemandsHeatMap(){
List<String> provinceList = getAllProvinces();
int[] sum = new int[provinceList.size()];
int i = 0;
for (String province : provinceList) {
List<Demands> demandsList = demandsService.getDemandsByProvince(province);
sum[i] = demandsList.size();
i++;
}
return sum;
}
/**
* @description:
* @param: String
* @return: int[]
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
@Override
public int[] cityDemandsHeatMap(String province){
List<String> cityList = getCitiesInProvince(province);
int[] sum = new int[cityList.size()];
int i = 0;
for (String city : cityList) {
List<Demands> demandsList = demandsService.getDemandsByCity(city);
sum[i] = demandsList.size();
i++;
}
return sum;
}
/**
* @description:
* @param: null
* @return: int[]
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
@Override
public int[] provinceGuideServiceHeatMap(){
List<String> provinceList = getAllProvinces();
int[] sum = new int[provinceList.size()];
int i = 0;
for (String province : provinceList) {
List<GuideService> guideServiceList = guideServiceService.getGuideServiceByProvince(province);
sum[i] = guideServiceList.size();
i++;
}
return sum;
}
/**
* @description:
* @param: String
* @return: int[]
* @author: wuyifan
* @date: 2024/6/6 15:48
*/
@Override
public int[] cityGuideServiceHeatMap(String province){
List<String> cityList = getCitiesInProvince(province);
int[] sum = new int[cityList.size()];
int i = 0;
for (String city : cityList) {
List<GuideService> guideServiceList = guideServiceService.getGuideServiceByCity(city);
sum[i] = guideServiceList.size();
i++;
}
return sum;
}
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,77 @@
package com.softegg.freetogo.Login.controller;
import com.softegg.freetogo.Login.service.LoginService;
import com.softegg.freetogo.User.Dao.GuidesRepository;
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 java.util.Map;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/9 9:35
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/Login")
public class LoginController {
@Autowired
LoginService loginService;
@Autowired
GuidesRepository guidesRepository;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/9 22:44
*/
@PostMapping("login")
public int Login(@RequestBody Map<String, Object> map) {
System.out.println(map);
System.out.println("phone:" + map.get("phone").toString());
System.out.println("password" + map.get("password").toString());
int tag = loginService.loginAccount(map.get("phone").toString(), map.get("password").toString());
System.out.println("LoginTag:" + tag);
return switch (tag) {
case 1000 -> 1;//登陆成功
case 1001 -> 2;//密码或账号错误
case 1002 -> 3;//该账户未注册
case 1005 -> 6;//未输入账号密码
case 1006 -> 7;//未输入账号
case 1007 -> 8;//未输入密码
default -> 0;
};
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/9 22:45
*/
@PostMapping("register")
public int Register(@RequestBody Map<String, Object> map) {
System.out.println(map);
int tag = loginService.registerAccount((String) map.get("name"), (String) map.get("password"), (String) map.get("phone"), (String) map.get("nickname"), (String) map.get("IDCard"));
System.out.println("RegisterTag:" + tag);
return switch (tag) {
case 1003 -> 4;//该账户已经注册
case 1004 -> 5;//注册成功
case 1008 -> 9;//身份证输入错误18位
case 1010 -> 11;//手机号输入错误11位
case 1011 -> 12;//密码过短最少8位
case 1012 -> 13;//姓名未输入
default -> 0;
};
}
}

@ -0,0 +1,21 @@
package com.softegg.freetogo.Login.service;
import org.springframework.stereotype.Service;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/9 8:37
*/
@Service
public interface LoginService {
int loginAccount(String phone, String password);//登录
// int registerAccount(String phone, String password);
int registerAccount(String name,
String password,
String phone,
String nickname,
String IDCard);//注册
}

@ -0,0 +1,98 @@
package com.softegg.freetogo.Login.service;
import com.softegg.freetogo.User.Dao.GuidesRepository;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/9 9:33
*/
@Component
public class LoginServiceImpl implements LoginService {
@Autowired
UsersService usersService;
@Autowired
GuidesRepository guidesRepository;
/**
* @description:
* @param: phone
* @param: password
* @return: int
* @author: zhanglinhao
* @date: 2024/5/9 22:46
*/
@Override
public int loginAccount(String phone, String password) {
if (phone.isEmpty() && password.isEmpty())
return 1005;//未输入账号密码
else if (phone.isEmpty())
return 1006;//未输入账号
else if (password.isEmpty())
return 1007;//未输入密码
if (usersService.isRegister(phone)) {
if (usersService.getUserByPhone(phone).getPassword().equals(password))
return 1000;//登录成功
else
return 1001;//密码或账号错误
} else
return 1002;//该账户未注册
}
/**
* @description:
* @param: name
* @param: password
* @param: phone
* @param: nickname
* @param: IDCard
* @return: int
* @author: zhanglinhao
* @date: 2024/5/11 15:57
*/
@Override
public int registerAccount(String name,
String password,
String phone,
String nickname,
String IDCard) {
if (usersService.isRegister(phone))
return 1003;//该账户已经注册
else if(name.isEmpty())
return 1012;//姓名未输入
else if (IDCard.length() != 18)
return 1008;//身份证输入错误
else if (phone.length() != 11)
return 1010;//手机号输入错误
else if (password.length() < 8)
return 1011;//密码过于简单
else {
LocalDateTime currentTime = LocalDateTime.now();
System.out.println("注册信息:姓名:" + name + "密码:" + password + "电话:" + phone + "昵称:" + nickname + "身份证:" + IDCard);
Users user = new Users();
user.setPhone(phone);
user.setPassword(password);
user.setNickname(nickname);
user.setIdcard(IDCard);
user.setName(name);
user.setCreatetime((currentTime.getYear() + "-" + currentTime.getMonthValue() + "-" + currentTime.getDayOfMonth()));
user.setGender(isMale(IDCard));
user.setStatus(0);
user.setReputation(60);
user.setMembertype(false);
usersService.add(user);
return 1004;//注册成功
}
}
boolean isMale(String IDCard) {
System.out.println("根据身份证判断性别:" + IDCard + " 第17位:" + IDCard.charAt(16));
return (int) IDCard.charAt(16) % 2 != 0;
}
}

@ -0,0 +1,13 @@
1000->1 登录成功
1001->2 密码或账号错误
1002->3 该账户未注册
1003->4 该账户已经注册
1004->5 注册成功
1005->6 未输入账号密码
1006->7 未输入账号
1007->8 身份证输入错误
1008->9 成功注册导游
1009->10 已是导游
1010->11 手机号输入错误
1011->12 密码过短
1012->13 未输入姓名

@ -0,0 +1,4 @@
package com.softegg.freetogo.Search.controller;
public class SearchController {
}

@ -0,0 +1,4 @@
package com.softegg.freetogo.Search.service;
public interface SearchService {
}

@ -0,0 +1,4 @@
package com.softegg.freetogo.Search.service;
public class SearchServiceImpl {
}

@ -0,0 +1,72 @@
package com.softegg.freetogo.SendDemand.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.SendDemand.service.SendDemandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:09
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/SendDemand")
public class SendDemandController {
@Autowired
SendDemandService sendDemandService;
@Autowired
DemandsService demandsService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/10 22:45
*/
@PostMapping("register")
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";
};
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/16 11:01
*/
@GetMapping("sendAllDemands")
public List<Demands> sendAllDemand(String phone) {
System.out.println("收到目标用户手机号:" + phone);
List<Demands> dlist = demandsService.getDemandsByPhone(phone);
System.out.println(dlist);
return dlist;
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/4 16:12
*/
@GetMapping("demand")
public Demands demand(int did) {
System.out.println("需求did:"+did);
return demandsService.getDemandById(did);
}
}

@ -0,0 +1,13 @@
package com.softegg.freetogo.SendDemand.service;
import org.springframework.stereotype.Service;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:31
*/
@Service
public interface SendDemandService {
int sendnewDemandAccount(String city, String phone, String date, String message);
}

@ -0,0 +1,70 @@
package com.softegg.freetogo.SendDemand.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:10
*/
@Component
public class SendDemandServiceImpl implements SendDemandService {
@Autowired
DemandsService demandsService;
@Autowired
UsersService usersService;
/**
* @description:
* @param: city
* @return: int
* @author: wuyifan
* @date: 2024/5/10 23:25
*/
@Override
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();
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;//添加游客需求成功
}
}

@ -0,0 +1,76 @@
package com.softegg.freetogo.SendGuideService.controller;
import com.softegg.freetogo.GuideService.bean.GuideService;
import com.softegg.freetogo.GuideService.service.GuideServiceService;
import com.softegg.freetogo.SendGuideService.service.SendGuideServiceService;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/5/13 10:47
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/SendGuideService")
public class SendGuideServiceController {
@Autowired
SendGuideServiceService sendGuideServiceService;
@Autowired
UsersService usersService;
@Autowired
GuideServiceService guideServiceService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/13 10:48
*/
@PostMapping("register")
public int SendDemand(@RequestBody Map<String, Object> map) {
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;//用户非导游
}
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/5/16 11:01
*/
@GetMapping("sendAllGuideService")
public List<GuideService> sendAllGuideService(String phone) {
List<GuideService> glist = guideServiceService.getGuideServiceByPhone(phone);
return glist;
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: wuyifan
* @date: 2024/6/4 16:10
*/
@GetMapping("GuideService")
public GuideService GuideService(int gid) {
return guideServiceService.getGuideServiceById(gid);
}
}

@ -0,0 +1,14 @@
package com.softegg.freetogo.SendGuideService.service;
import org.springframework.stereotype.Service;
/**
* @description:
* @author:wuyifan
* @date:2024/5/13 11:11
*/
@Service
public interface SendGuideServiceService {
int sendnewGuideServiceAccount(String city, String phone, String date, String message);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save