-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
需要有实时沟通的功能,同时也能发送图片和视频,并且要能让会员能发起邀约成行的功能,让不同的人发出自己的行程,有意向的人可以加入。
同时可以推荐机票,酒店等的参考价格,或者接入第三方,能下单签证,订机票,订酒店等功能
- Loading branch information
1 parent
747eda9
commit 5ad07f6
Showing
10 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/com/aiassistant/controller/ChatController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.aiassistant.controller; | ||
|
||
import com.aiassistant.model.Message; | ||
import com.aiassistant.service.ChatService; | ||
import com.aiassistant.utils.ResultModel; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@RestController | ||
public class ChatController { | ||
private final ChatService chatService; | ||
|
||
@Autowired | ||
public ChatController(ChatService chatService) { | ||
this.chatService = chatService; | ||
} | ||
|
||
@PostMapping("/sendMessage") | ||
public ResultModel<Message> sendMessage(@RequestParam String content, | ||
@RequestParam(required = false) MultipartFile image, | ||
@RequestParam(required = false) MultipartFile video) { | ||
return chatService.sendMessage(content, image, video); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/aiassistant/controller/RecommendationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.aiassistant.controller; | ||
|
||
import com.aiassistant.model.Recommendation; | ||
import com.aiassistant.model.TravelPlan; | ||
import com.aiassistant.service.RecommendationService; | ||
import com.aiassistant.utils.ResultModel; | ||
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.RestController; | ||
|
||
@RestController | ||
public class RecommendationController { | ||
private RecommendationService recommendationService; | ||
|
||
@Autowired | ||
public RecommendationController(RecommendationService recommendationService) { | ||
this.recommendationService = recommendationService; | ||
} | ||
|
||
@PostMapping("/recommendation") | ||
public ResultModel<Recommendation> getRecommendation(@RequestBody TravelPlan travelPlan) { | ||
Recommendation recommendation = recommendationService.getRecommendation(travelPlan); | ||
return ResultModel.ofSuccess(recommendation); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/aiassistant/controller/ThirdPartyController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.aiassistant.controller; | ||
|
||
import com.aiassistant.service.ThirdPartyService; | ||
import com.aiassistant.utils.ResultModel; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/third-party") | ||
public class ThirdPartyController { | ||
|
||
private final ThirdPartyService thirdPartyService; | ||
|
||
@Autowired | ||
public ThirdPartyController(ThirdPartyService thirdPartyService) { | ||
this.thirdPartyService = thirdPartyService; | ||
} | ||
|
||
@PostMapping("/access") | ||
public ResultModel<String> accessThirdParty(@RequestParam String platform, @RequestParam String userId, @RequestParam String orderInfo) { | ||
return thirdPartyService.accessThirdParty(platform, userId, orderInfo); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/aiassistant/controller/TravelPlanController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.aiassistant.controller; | ||
|
||
import com.aiassistant.model.TravelPlan; | ||
import com.aiassistant.service.TravelPlanService; | ||
import com.aiassistant.utils.ResultModel; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Date; | ||
|
||
@RestController | ||
public class TravelPlanController { | ||
private final TravelPlanService travelPlanService; | ||
|
||
@Autowired | ||
public TravelPlanController(TravelPlanService travelPlanService) { | ||
this.travelPlanService = travelPlanService; | ||
} | ||
|
||
@PostMapping("/travel-plan") | ||
public ResultModel<TravelPlan> publishTravelPlan(@RequestParam String title, | ||
@RequestParam String description, | ||
@RequestParam Date startTime, | ||
@RequestParam Date endTime, | ||
@RequestParam Integer limit) { | ||
return travelPlanService.publishTravelPlan(title, description, startTime, endTime, limit); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.aiassistant.mapper; | ||
|
||
import com.aiassistant.model.Message; | ||
import org.apache.ibatis.annotations.Insert; | ||
import org.apache.ibatis.annotations.Options; | ||
import org.apache.ibatis.annotations.SelectKey; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface MessageMapper { | ||
@Insert("INSERT INTO message(content) VALUES(#{content})") | ||
@Options(useGeneratedKeys = true, keyProperty = "id") | ||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = int.class) | ||
int insertMessage(Message message); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/aiassistant/mapper/TravelPlanMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.aiassistant.mapper; | ||
|
||
import com.aiassistant.model.TravelPlan; | ||
import org.apache.ibatis.annotations.Insert; | ||
import org.apache.ibatis.annotations.Options; | ||
import org.apache.ibatis.annotations.SelectKey; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface TravelPlanMapper { | ||
@Insert("INSERT INTO travel_plan(user_id, start_time, end_time, destination, remark) " + | ||
"VALUES(#{userId}, #{startTime}, #{endTime}, #{destination}, #{remark})") | ||
@Options(useGeneratedKeys = true, keyProperty = "id") | ||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = int.class) | ||
int insertTravelPlan(TravelPlan travelPlan); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.aiassistant.service; | ||
|
||
import com.aiassistant.mapper.MessageMapper; | ||
import com.aiassistant.model.Message; | ||
import com.aiassistant.utils.ResultModel; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Service | ||
public class ChatService { | ||
private final MessageMapper messageMapper; | ||
|
||
@Autowired | ||
public ChatService(MessageMapper messageMapper) { | ||
this.messageMapper = messageMapper; | ||
} | ||
|
||
public ResultModel<Message> sendMessage(String content, MultipartFile image, MultipartFile video) { | ||
// Save the message to the database | ||
Message message = new Message(); | ||
message.setContent(content); | ||
message.setImage(image != null ? image.getOriginalFilename() : null); | ||
message.setVideo(video != null ? video.getOriginalFilename() : null); | ||
messageMapper.insertMessage(message); | ||
|
||
// Return the message object | ||
return ResultModel.ofSuccess(message); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/aiassistant/service/RecommendationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.aiassistant.service; | ||
|
||
import com.aiassistant.model.Recommendation; | ||
import com.aiassistant.model.TravelPlan; | ||
import com.aiassistant.utils.ResultModel; | ||
|
||
public interface RecommendationService { | ||
ResultModel<Recommendation> getRecommendation(TravelPlan travelPlan); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.aiassistant.service; | ||
|
||
import com.aiassistant.utils.ResultModel; | ||
|
||
public interface ThirdPartyService { | ||
ResultModel<String> accessThirdParty(String platform, String userId, String orderInfo); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/aiassistant/service/TravelPlanService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.aiassistant.service; | ||
|
||
import com.aiassistant.mapper.TravelPlanMapper; | ||
import com.aiassistant.model.TravelPlan; | ||
import com.aiassistant.utils.ResultModel; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Date; | ||
|
||
@Service | ||
public class TravelPlanService { | ||
private final TravelPlanMapper travelPlanMapper; | ||
|
||
@Autowired | ||
public TravelPlanService(TravelPlanMapper travelPlanMapper) { | ||
this.travelPlanMapper = travelPlanMapper; | ||
} | ||
|
||
public ResultModel<TravelPlan> publishTravelPlan(String title, String description, Date startTime, Date endTime, Integer limit) { | ||
TravelPlan travelPlan = new TravelPlan(); | ||
travelPlan.setTitle(title); | ||
travelPlan.setDescription(description); | ||
travelPlan.setStartTime(startTime); | ||
travelPlan.setEndTime(endTime); | ||
travelPlan.setLimit(limit); | ||
|
||
travelPlanMapper.insertTravelPlan(travelPlan); | ||
|
||
return ResultModel.ofSuccess(travelPlan); | ||
} | ||
} |