diff --git a/pom.xml b/pom.xml index 707d8d3f403fc470fcd982db4b21c1ba6cc9f04d..fc1f4481d6a382b5398485d9869bc9f063d8b428 100644 --- a/pom.xml +++ b/pom.xml @@ -20,10 +20,10 @@ 1.8 - + org.springframework.boot spring-boot-starter-web @@ -74,11 +74,11 @@ 2.3.1 test - + org.aspectj @@ -97,6 +97,32 @@ fastjson 1.2.78 + + org.springframework.security + spring-security-config + 5.7.11 + + + com.auth0 + java-jwt + 3.11.0 + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + org.apache.commons + commons-pool2 + + + + com.fasterxml.jackson.core + jackson-databind + + diff --git a/src/main/java/com/suse/jd_system_server/Vo/HotelPageListVo.java b/src/main/java/com/suse/jd_system_server/Vo/HotelPageListVo.java new file mode 100644 index 0000000000000000000000000000000000000000..b63d841c24726fe3082f612538a7779308d5316a --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/Vo/HotelPageListVo.java @@ -0,0 +1,25 @@ +package com.suse.jd_system_server.Vo; + + +import com.suse.jd_system_server.auto.entity.Hotel; +import lombok.Data; + +@Data +public class HotelPageListVo extends Hotel { + /** + * 酒店对应的评论数量 + */ + private Integer commentCount; + /** + * 酒店对应的好评数量 + */ + private Integer goodCommentCount; + /** + * 酒店中房间价格最小的 + */ + private Integer minPrice; + /** + * 酒店对应的一条评论 + */ + private String com_text; +} diff --git a/src/main/java/com/suse/jd_system_server/Vo/RolesVo.java b/src/main/java/com/suse/jd_system_server/Vo/RolesVo.java new file mode 100644 index 0000000000000000000000000000000000000000..5cd7c0c4c7e007cd5f0237d0b5979a848fecf01d --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/Vo/RolesVo.java @@ -0,0 +1,13 @@ +package com.suse.jd_system_server.Vo; + +import com.suse.jd_system_server.entity.Authority; +import com.suse.jd_system_server.entity.Role; + +import java.util.List; + +public class RolesVo extends Role { + /** + * 权限列表 + */ + private List authorityList; +} diff --git a/src/main/java/com/suse/jd_system_server/aspect/logAspect.java b/src/main/java/com/suse/jd_system_server/aspect/logAspect.java index f0c2ce3b0d52a5e03c1120113aec302c1b6b93aa..633e61603239622e3ea37ee03b48894148f0c103 100644 --- a/src/main/java/com/suse/jd_system_server/aspect/logAspect.java +++ b/src/main/java/com/suse/jd_system_server/aspect/logAspect.java @@ -45,6 +45,8 @@ public class logAspect { //获取用户信息,用户信息在登录存入session String userName = (String) request.getSession().getAttribute("userName"); Long userId = (Long) request.getSession().getAttribute("userId"); +// System.out.println("userName:"+userName); +// System.out.println("userId:"+userId); //获取用户操作信息。通过反射注解中的value获取 MethodSignature signature = (MethodSignature) joinPoint.getSignature(); diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/AuthorityController.java b/src/main/java/com/suse/jd_system_server/auto/controller/AuthorityController.java index cb7c5bcbb65c466bd5ee36de4fb551e4dacdd046..cab9383eecf6d31abccf1f05c126fb76cddf0467 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/AuthorityController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/AuthorityController.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.controller; import com.suse.jd_system_server.auto.service.AuthorityService; -import com.suse.jd_system_server.entity.Authority; +import com.suse.jd_system_server.auto.entity.Authority; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -16,6 +16,8 @@ import java.util.List; */ @RestController @RequestMapping("/AuthorityURL") + +@CrossOrigin public class AuthorityController { diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/BedController.java b/src/main/java/com/suse/jd_system_server/auto/controller/BedController.java index 7a78da4db66e993a631f73bd966540721f3bbba0..b35e2fafcbd5540db6e24bbdf87f87b37e70f82f 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/BedController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/BedController.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.Bed; +import com.suse.jd_system_server.auto.entity.Bed; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -16,6 +16,7 @@ import com.suse.jd_system_server.auto.service.BedService; */ @RestController @RequestMapping("/BedURL") +@CrossOrigin public class BedController { diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/CommentsController.java b/src/main/java/com/suse/jd_system_server/auto/controller/CommentsController.java index 2bc84cfd47f7289da10eb9b8530afb3702ba1e59..36c5f8f4cb86e4611be9245c234fcd34ff36949c 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/CommentsController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/CommentsController.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.controller; import com.suse.jd_system_server.auto.service.CommentsService; -import com.suse.jd_system_server.entity.Comments; +import com.suse.jd_system_server.auto.entity.Comments; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; @@ -18,6 +18,7 @@ import com.suse.jd_system_server.auto.service.CommentsService; */ @RestController @RequestMapping("/CommentsURL") +@CrossOrigin public class CommentsController { diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/HotelController.java b/src/main/java/com/suse/jd_system_server/auto/controller/HotelController.java index bc754a957a2a99d9a5fc5192250ce08efb0024eb..5398204243267b1ea966999ada36a2d2ab25ea1f 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/HotelController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/HotelController.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.Hotel; +import com.suse.jd_system_server.auto.entity.Hotel; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; @@ -18,6 +18,7 @@ import com.suse.jd_system_server.auto.service.HotelService; */ @RestController @RequestMapping("/HotelURL") +@CrossOrigin public class HotelController { @@ -102,6 +103,7 @@ public class HotelController { */ @PostMapping("/selectList") public Result selectList(@RequestBody Map param){ + System.out.println(param); return Result.buildSuccess(hotelservice.selectList(param),hotelservice.selectCount(param)); } diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/ImgController.java b/src/main/java/com/suse/jd_system_server/auto/controller/ImgController.java index 53b1f766ed1b879b4e494e8713b2e3d3a831d78c..9476a9938c23e330ab7782795f92d2ae1e089114 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/ImgController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/ImgController.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.Img; +import com.suse.jd_system_server.auto.entity.Img; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; @@ -17,6 +17,7 @@ import com.suse.jd_system_server.auto.service.ImgService; */ @RestController @RequestMapping("/ImgURL") +@CrossOrigin public class ImgController { diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/LogsController.java b/src/main/java/com/suse/jd_system_server/auto/controller/LogsController.java index 7acfd1126f6926cba22d81c5650b17187fe5c5af..a2c353b702643b5e28415890f90c8f572ede6ead 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/LogsController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/LogsController.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.Logs; +import com.suse.jd_system_server.auto.entity.Logs; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -16,6 +16,7 @@ import com.suse.jd_system_server.auto.service.LogsService; */ @RestController @RequestMapping("/LogsURL") +@CrossOrigin public class LogsController { diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/OrdersController.java b/src/main/java/com/suse/jd_system_server/auto/controller/OrdersController.java index 80401bab49000b26fb36ed7da487e59f11ffad2c..cdd7a39ca057d7600e41221e1319db918d1d96e4 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/OrdersController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/OrdersController.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.Orders; +import com.suse.jd_system_server.auto.entity.Orders; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -16,6 +16,7 @@ import com.suse.jd_system_server.auto.service.OrdersService; */ @RestController @RequestMapping("/OrdersURL") +@CrossOrigin public class OrdersController { @@ -115,4 +116,4 @@ public class OrdersController { -} \ No newline at end of file +} diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/RoleController.java b/src/main/java/com/suse/jd_system_server/auto/controller/RoleController.java index 915e451db48fb5f170a299f18cfb224ed6ab5108..0491242bc25e8e2fa9568f0cbf9a9bd2dec23992 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/RoleController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/RoleController.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.Role; +import com.suse.jd_system_server.auto.entity.Role; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -16,6 +16,7 @@ import com.suse.jd_system_server.auto.service.RoleService; */ @RestController @RequestMapping("/RoleURL") +@CrossOrigin public class RoleController { diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/RoomController.java b/src/main/java/com/suse/jd_system_server/auto/controller/RoomController.java index 8d08f9b9e8042fdb0f332ab5aaaf78fa2b1cca9a..cc03b9d70549daee3e44e305f2a684b262084be9 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/RoomController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/RoomController.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.Room; +import com.suse.jd_system_server.auto.entity.Room; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -16,6 +16,7 @@ import com.suse.jd_system_server.auto.service.RoomService; */ @RestController @RequestMapping("/RoomURL") +@CrossOrigin public class RoomController { diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/TestyController.java b/src/main/java/com/suse/jd_system_server/auto/controller/TestyController.java index f883a271f3e75ca14f7e9070c61942b01825059b..68a7f219c38b7ffc25c0e2bf85f1536940ad232f 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/TestyController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/TestyController.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.Testy; +import com.suse.jd_system_server.auto.entity.Testy; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -16,6 +16,7 @@ import com.suse.jd_system_server.auto.service.TestyService; */ @RestController @RequestMapping("/TestyURL") +@CrossOrigin public class TestyController { diff --git a/src/main/java/com/suse/jd_system_server/auto/controller/UserController.java b/src/main/java/com/suse/jd_system_server/auto/controller/UserController.java index 1452f7a79b3393833b652a7c55802ade9c63657e..547d6a4bdf4a9a0d9b97703c1416155957dcf9f0 100644 --- a/src/main/java/com/suse/jd_system_server/auto/controller/UserController.java +++ b/src/main/java/com/suse/jd_system_server/auto/controller/UserController.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.controller; -import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.auto.entity.User; import com.suse.jd_system_server.auto.empty.Result; import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -16,6 +16,7 @@ import com.suse.jd_system_server.auto.service.UserService; */ @RestController @RequestMapping("/UserURL") +@CrossOrigin public class UserController { @@ -37,6 +38,7 @@ public class UserController { */ @PostMapping("/updateByUser_id") public Result updateByUser_id(@RequestBody User demo){ + System.out.println(demo); return Result.buildSuccess(userservice.updateByUser_id( demo)); } @@ -59,6 +61,7 @@ public class UserController { */ @PostMapping("/insert") public Result insert(@RequestBody User demo){ + System.out.println(demo); Result.buildSuccess(userservice.insert(demo)); return Result.buildSuccess(demo); } @@ -100,6 +103,7 @@ public class UserController { */ @PostMapping("/selectList") public Result selectList(@RequestBody Map param){ + System.out.println(param); return Result.buildSuccess(userservice.selectList(param),userservice.selectCount(param)); } @@ -115,4 +119,4 @@ public class UserController { -} \ No newline at end of file +} diff --git a/src/main/java/com/suse/jd_system_server/auto/empty/Result.java b/src/main/java/com/suse/jd_system_server/auto/empty/Result.java index a5573b0b1de826826047898ecc2fd80baa1b9e05..9507982a5247e3ec18e8488e32c3e965e25c82dd 100644 --- a/src/main/java/com/suse/jd_system_server/auto/empty/Result.java +++ b/src/main/java/com/suse/jd_system_server/auto/empty/Result.java @@ -4,6 +4,9 @@ package com.suse.jd_system_server.auto.empty; import lombok.Data; +import java.util.HashMap; +import java.util.Map; + @Data public class Result { @@ -32,6 +35,8 @@ public class Result { private Long count; + //动态数据 + private Map map = new HashMap();//动态数据,根据需要为返回值添加信息 /** * 构建带分页的返回 @@ -81,5 +86,13 @@ public class Result { return result; } + /** + * 动态添加数据 + */ + public Result add(String key, Object value){ + this.map.put(key,value); + return this; + } + } \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/auto/entity/Comments.java b/src/main/java/com/suse/jd_system_server/auto/entity/Comments.java index f03018ac2f0f14d03cbb5daf39f532aabafa7efb..fb0af19f510138c287bddd2555d2e115e726cdf9 100644 --- a/src/main/java/com/suse/jd_system_server/auto/entity/Comments.java +++ b/src/main/java/com/suse/jd_system_server/auto/entity/Comments.java @@ -77,4 +77,10 @@ public class Comments implements Serializable{ private Integer status; + /** + * 字段解释:评价性质,0好1差- + */ + + private Integer com_status; + } \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/auto/entity/Hotel.java b/src/main/java/com/suse/jd_system_server/auto/entity/Hotel.java index 5c428205d4bf46bd601e6c039c2def3950ce7a0d..b1130749b4b7a3c846f068c4d188ea51d18d39de 100644 --- a/src/main/java/com/suse/jd_system_server/auto/entity/Hotel.java +++ b/src/main/java/com/suse/jd_system_server/auto/entity/Hotel.java @@ -114,7 +114,7 @@ public class Hotel implements Serializable{ * 字段解释: */ - private Integer telphone; + private String telphone; diff --git a/src/main/java/com/suse/jd_system_server/auto/entity/Img.java b/src/main/java/com/suse/jd_system_server/auto/entity/Img.java index 9fade44baec1ee87c3d53df9d647860abdec0ac2..668bfa74c6ec0975d6b5bae9b6dd80f9e0a7f6a7 100644 --- a/src/main/java/com/suse/jd_system_server/auto/entity/Img.java +++ b/src/main/java/com/suse/jd_system_server/auto/entity/Img.java @@ -52,4 +52,9 @@ public class Img implements Serializable{ private String img_url; + /** + * 字段解释:是否属于酒店,0酒店1房间 + */ + private Integer is_hotel; + } \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/auto/mapper/CommentsMapper.java b/src/main/java/com/suse/jd_system_server/auto/mapper/CommentsMapper.java index 5bcea55797dcd509240f690daa0995a686eba930..59e5742cc091cb9f49de6ef8eaf527b288f400e8 100644 --- a/src/main/java/com/suse/jd_system_server/auto/mapper/CommentsMapper.java +++ b/src/main/java/com/suse/jd_system_server/auto/mapper/CommentsMapper.java @@ -12,6 +12,7 @@ import java.util.List; */ public interface CommentsMapper extends BaseMapper{ + /** 根据Com_id查询 */ diff --git a/src/main/java/com/suse/jd_system_server/auto/mapper/LoginMapper.java b/src/main/java/com/suse/jd_system_server/auto/mapper/LoginMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..33fe3bd676b2b6bdf54e6c6a6d06fc7f200baf97 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/auto/mapper/LoginMapper.java @@ -0,0 +1,27 @@ +package com.suse.jd_system_server.auto.mapper; + +import com.suse.jd_system_server.entity.Authority; +import com.suse.jd_system_server.entity.User; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface LoginMapper { + User selectByname(String username); + List selectAuthority(Long userid); + + List selectAuthorityList(Long role_id); + + List selectallAuthority(); + + void deleteau(@Param("param") Map param); + + void register(Map param); + + List selectProvince(); + + List selectCity(@Param("cityName") String cityName); +} diff --git a/src/main/java/com/suse/jd_system_server/auto/mapper/Shb_hotelPageMapper.java b/src/main/java/com/suse/jd_system_server/auto/mapper/Shb_hotelPageMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..84ebb2bf1f4b9f53b7ab26e92f4fcb867d6d4897 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/auto/mapper/Shb_hotelPageMapper.java @@ -0,0 +1,14 @@ +package com.suse.jd_system_server.auto.mapper; + +import com.suse.jd_system_server.Vo.HotelPageListVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface Shb_hotelPageMapper { + + List selectHotelLists(@Param("map") Map map); +} diff --git a/src/main/java/com/suse/jd_system_server/auto/service/AuthorityService.java b/src/main/java/com/suse/jd_system_server/auto/service/AuthorityService.java index 7b8e9afe49fcb9f43b549468d91cce01674ce04c..1244472bbf038a0f2baef13cd29d5d762e25d5a6 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/AuthorityService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/AuthorityService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Authority; +import com.suse.jd_system_server.auto.entity.Authority; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/BedService.java b/src/main/java/com/suse/jd_system_server/auto/service/BedService.java index 956c38b7eee0aec1cc7cdb5fb8698387deb8fcbb..529d220031676e4be1d958d5c44155d53510b4d5 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/BedService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/BedService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Bed; +import com.suse.jd_system_server.auto.entity.Bed; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/CommentsService.java b/src/main/java/com/suse/jd_system_server/auto/service/CommentsService.java index 6085f2c8539f9bd3d0167279f6212ee5636008d6..4484f3c65186d626d0b07f3799139c57d5666a0e 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/CommentsService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/CommentsService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Comments; +import com.suse.jd_system_server.auto.entity.Comments; import java.util.Map; import java.util.List; /** @@ -62,4 +62,5 @@ public interface CommentsService { selectCount:(根据集合查询数量) */ public Long selectCount(Map param); + } \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/auto/service/HotelService.java b/src/main/java/com/suse/jd_system_server/auto/service/HotelService.java index 6ae907418a89a3d02ddc1e96a9715d474f79adbf..59aee0f365a349e2d2bf0a8eceea1fab2adae0b0 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/HotelService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/HotelService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Hotel; +import com.suse.jd_system_server.auto.entity.Hotel; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/ImgService.java b/src/main/java/com/suse/jd_system_server/auto/service/ImgService.java index bb72890ea8b8265c74d78bfc8436af59eae79f1d..8d707213ed731fde3eb01a644d0872a9d264dc9f 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/ImgService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/ImgService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Img; +import com.suse.jd_system_server.auto.entity.Img; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/LogsService.java b/src/main/java/com/suse/jd_system_server/auto/service/LogsService.java index 3c69c1c3af61f4c8109bfb91a4f547ff588a8723..8ab0fb4fc3c0a5a7bb7c5967ce23f086380bb727 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/LogsService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/LogsService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Logs; +import com.suse.jd_system_server.auto.entity.Logs; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/OrdersService.java b/src/main/java/com/suse/jd_system_server/auto/service/OrdersService.java index 605326bd6a06ec3f8509e1b47303f4ad9de341d2..7f0ae0c6c67a11a7986ad565c5daf653994119f7 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/OrdersService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/OrdersService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Orders; +import com.suse.jd_system_server.auto.entity.Orders; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/RoleService.java b/src/main/java/com/suse/jd_system_server/auto/service/RoleService.java index 57ec61d149791ab711e8c58bf72a33f67a529103..9d703c92c41bcf0f20c2659b6936b38f7d178aa2 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/RoleService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/RoleService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Role; +import com.suse.jd_system_server.auto.entity.Role; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/RoomService.java b/src/main/java/com/suse/jd_system_server/auto/service/RoomService.java index df27a2d29860bf562c49ae44174d2a2a8b3f1bc7..d91db19aa9fb9ca8b7a8815f12ea707b40edc169 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/RoomService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/RoomService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Room; +import com.suse.jd_system_server.auto.entity.Room; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/TestyService.java b/src/main/java/com/suse/jd_system_server/auto/service/TestyService.java index 7ec4eb473adda688d56211c3d6c19692f95cbade..48b9592d1682d1482363fd3150c0fd5a4ae75784 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/TestyService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/TestyService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.Testy; +import com.suse.jd_system_server.auto.entity.Testy; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/UserService.java b/src/main/java/com/suse/jd_system_server/auto/service/UserService.java index b35776828ff3fbd6790881deeff2cba79b9c55c4..ef2fd51bdeee083269dccb28a21c334262f1f11e 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/UserService.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/UserService.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service; -import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.auto.entity.User; import java.util.Map; import java.util.List; /** diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/AuthorityServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/AuthorityServiceImpl.java index a5371a59db593bf4ef17148a77b22eb636d74f28..d3fdfb96d673dd100489deeb8bfb09459217a94a 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/AuthorityServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/AuthorityServiceImpl.java @@ -1,7 +1,7 @@ package com.suse.jd_system_server.auto.service.impl; -import com.suse.jd_system_server.entity.Authority; +import com.suse.jd_system_server.auto.entity.Authority; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/BedServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/BedServiceImpl.java index 96b520176e57784b125728b48248182e0066d38c..6d8c6526b35115ccd2c9a6d7d6f07b9acac251af 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/BedServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/BedServiceImpl.java @@ -1,7 +1,8 @@ package com.suse.jd_system_server.auto.service.impl; -import com.suse.jd_system_server.entity.Bed; +import com.suse.jd_system_server.annotation.logWeaving; +import com.suse.jd_system_server.auto.entity.Bed; import java.util.Map; import java.util.HashMap; import java.util.List; @@ -42,6 +43,7 @@ public class BedServiceImpl implements BedService{ /** 根据Bed_id删除 */ + @logWeaving("对床型表的一次删除操作") public Integer deleteByBed_id(Long bed_id){ return beddao.deleteByBed_id(bed_id); } @@ -53,6 +55,7 @@ public class BedServiceImpl implements BedService{ /** insert:(插入) */ + @logWeaving("对床型表的一次插入操作") public Object insert(Bed demo){ beddao.insert(demo); return demo; @@ -63,6 +66,7 @@ public class BedServiceImpl implements BedService{ /** insertOrUpdate(插入或更新(根据主键或唯一索引更新,主键和唯一索引不会改变)) */ + @logWeaving("对床型表的一次修改操作") public Integer insertOrUpdate(Bed demo){ return beddao.insertOrUpdate(demo); } diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/CommentsServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/CommentsServiceImpl.java index e6984b5dc57c838ae6ea46d6af874cbcc8987bf3..122b7c2048239585a1d4d0287d0fa8e67fa9f8e3 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/CommentsServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/CommentsServiceImpl.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.service.impl; import com.suse.jd_system_server.auto.mapper.CommentsMapper; -import com.suse.jd_system_server.entity.Comments; +import com.suse.jd_system_server.auto.entity.Comments; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/HotelServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/HotelServiceImpl.java index f0d3af9353a0877177218b7b7b51d54c51a9cee6..e494fd5d920e11da0a273d2238deb73d4f47bc8a 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/HotelServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/HotelServiceImpl.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.service.impl; import com.suse.jd_system_server.auto.mapper.HotelMapper; -import com.suse.jd_system_server.entity.Hotel; +import com.suse.jd_system_server.auto.entity.Hotel; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/ImgServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/ImgServiceImpl.java index 1a4422876ae83a187375041fdab50f6dc2780285..a8cec3a576abdc0a441a8cc64f3bcdec3d4fea50 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/ImgServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/ImgServiceImpl.java @@ -1,8 +1,9 @@ package com.suse.jd_system_server.auto.service.impl; +import com.suse.jd_system_server.annotation.logWeaving; import com.suse.jd_system_server.auto.mapper.ImgMapper; -import com.suse.jd_system_server.entity.Img; +import com.suse.jd_system_server.auto.entity.Img; import java.util.Map; import java.util.HashMap; import java.util.List; @@ -42,6 +43,7 @@ public class ImgServiceImpl implements ImgService{ /** 根据Img_id删除 */ + @logWeaving("对图片表的一次删除操作") public Integer deleteByImg_id(Long img_id){ return imgdao.deleteByImg_id(img_id); } @@ -53,6 +55,7 @@ public class ImgServiceImpl implements ImgService{ /** insert:(插入) */ + @logWeaving("对图片表的一次插入操作") public Object insert(Img demo){ imgdao.insert(demo); return demo; @@ -63,6 +66,7 @@ public class ImgServiceImpl implements ImgService{ /** insertOrUpdate(插入或更新(根据主键或唯一索引更新,主键和唯一索引不会改变)) */ + @logWeaving("对图片表的一次修改操作") public Integer insertOrUpdate(Img demo){ return imgdao.insertOrUpdate(demo); } diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/LogsServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/LogsServiceImpl.java index a50409a879ce3874a4c1ffca436f16ed062076a0..a6d8fe0eacaffa649664b33dcecb4f292b0fcbbd 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/LogsServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/LogsServiceImpl.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.service.impl; import com.suse.jd_system_server.auto.mapper.LogsMapper; -import com.suse.jd_system_server.entity.Logs; +import com.suse.jd_system_server.auto.entity.Logs; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/OrdersServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/OrdersServiceImpl.java index 38f4f9b14d35ece770f45f1e77e87a356abe2c96..cd9c9dfaf9312e4d573cdb76e4f40fd2b80cedfe 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/OrdersServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/OrdersServiceImpl.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.service.impl; import com.suse.jd_system_server.auto.mapper.OrdersMapper; -import com.suse.jd_system_server.entity.Orders; +import com.suse.jd_system_server.auto.entity.Orders; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/RoleServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/RoleServiceImpl.java index 21851d5867505178a12f42f709f1a2a01508e110..a89b53d0c0e2ab965a271319d03a643cefeb07eb 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/RoleServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/RoleServiceImpl.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.service.impl; import com.suse.jd_system_server.auto.mapper.RoleMapper; -import com.suse.jd_system_server.entity.Role; +import com.suse.jd_system_server.auto.entity.Role; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/RoomServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/RoomServiceImpl.java index e63a57416a44cc809aeeb908d8ed7a16c1f6afe4..7527f3efdd4db6d842fe4f023a0e90b87b35bb77 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/RoomServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/RoomServiceImpl.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.service.impl; import com.suse.jd_system_server.auto.mapper.RoomMapper; -import com.suse.jd_system_server.entity.Room; +import com.suse.jd_system_server.auto.entity.Room; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/TestyServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/TestyServiceImpl.java index 10d440f33a33b2b12527fdcbfa090dc1868bb6b4..92f1ef390276a6d1248ac672c08d02e86fb98f37 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/TestyServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/TestyServiceImpl.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.service.impl; import com.suse.jd_system_server.auto.mapper.TestyMapper; -import com.suse.jd_system_server.entity.Testy; +import com.suse.jd_system_server.auto.entity.Testy; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/auto/service/impl/UserServiceImpl.java b/src/main/java/com/suse/jd_system_server/auto/service/impl/UserServiceImpl.java index 318bcb68caf324814c18b2be1a050943b51e0da3..0a76785a08495f364bfddd93b100600151c99e0a 100644 --- a/src/main/java/com/suse/jd_system_server/auto/service/impl/UserServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/auto/service/impl/UserServiceImpl.java @@ -2,7 +2,7 @@ package com.suse.jd_system_server.auto.service.impl; import com.suse.jd_system_server.auto.mapper.UserMapper; -import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.auto.entity.User; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/com/suse/jd_system_server/controller/BedController_lhj.java b/src/main/java/com/suse/jd_system_server/controller/BedController_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..7b38bdbfc438622df1133975d693033760faef15 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/BedController_lhj.java @@ -0,0 +1,21 @@ +package com.suse.jd_system_server.controller; + +import com.suse.jd_system_server.auto.empty.Result; +import com.suse.jd_system_server.service.BedService_lhj; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/BedURLlhj") +@CrossOrigin +public class BedController_lhj { + @Autowired + private BedService_lhj bedservice; + /** + 根据Com_id查询 + */ + @GetMapping("/searchbed/{room_id}") + public Result searchbed(@PathVariable(value = "room_id") Long room_id){ + return Result.buildSuccess(bedservice.searchbed(room_id)); + } +} \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/controller/CommentsController_lhj.java b/src/main/java/com/suse/jd_system_server/controller/CommentsController_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..8f989f110bbdf0673dbe0c7b2938c106392c0223 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/CommentsController_lhj.java @@ -0,0 +1,22 @@ +package com.suse.jd_system_server.controller; + +import com.suse.jd_system_server.auto.empty.Result; +import com.suse.jd_system_server.auto.service.CommentsService; +import com.suse.jd_system_server.service.CommentsService_lhj; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/CommentsURL1") +@CrossOrigin +public class CommentsController_lhj { + @Autowired + private CommentsService_lhj commentsservice; + /** + 根据Com_id查询 + */ + @GetMapping("/connect/{hotelId}") + public Result connect(@PathVariable(value = "hotelId") Long hotelId){ + return Result.buildSuccess(commentsservice.connect(hotelId)); + } +} diff --git a/src/main/java/com/suse/jd_system_server/controller/HotelController_lhj.java b/src/main/java/com/suse/jd_system_server/controller/HotelController_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..7704bd202b8cfc5662db75262fb4a7a535b8035d --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/HotelController_lhj.java @@ -0,0 +1,22 @@ +package com.suse.jd_system_server.controller; + +import com.suse.jd_system_server.auto.empty.Result; +import com.suse.jd_system_server.service.HotelService_lhj; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/HotelURLlhj") +@CrossOrigin +public class HotelController_lhj { + @Autowired + private HotelService_lhj hotelservice; + /** + 根据Com_id查询 + */ + @GetMapping("/searchhotel/{hotelId}") + public Result searchhotel(@PathVariable(value = "hotelId") Long hotelId){ + return Result.buildSuccess(hotelservice.searchhotel(hotelId)); + } +} diff --git a/src/main/java/com/suse/jd_system_server/controller/MapController.java b/src/main/java/com/suse/jd_system_server/controller/MapController.java new file mode 100644 index 0000000000000000000000000000000000000000..2aacba132d39e8f79c10163ed013e6e03f5121b7 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/MapController.java @@ -0,0 +1,88 @@ +package com.suse.jd_system_server.controller; + +import com.suse.jd_system_server.dao.MapDao; +import com.suse.jd_system_server.dao.UserDao; +import com.suse.jd_system_server.entity.Hotel; +import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.epmty.Locations; +import com.suse.jd_system_server.utils.BaiduMapUtil; +import com.suse.jd_system_server.utils.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +/** + * Map组件Controller层 + */ +@RestController +@RequestMapping("/map") +@CrossOrigin() +public class MapController { + @Autowired + private UserDao userDao; + @Autowired + private MapDao mapDao; + //为前端地址批量解析JSP提供用户所在城市的酒店名列表 + @GetMapping("/getHotels") + public Result> getHotels(Long userId){ +// System.out.println("成功进入..."); + User user = userDao.selects(userId); + + String userCity = BaiduMapUtil.getUserCity(user);//获取用户城市部分字段 + ArrayList hotels = BaiduMapUtil.getHotels(userCity); + + if(hotels.isEmpty())return Result.buildFail("暂无此城市酒店信息,请告知客服等待网站数据更新!"); + else{ + Result> result = Result.buildSuccess(hotels); + result.add("userLng",user.getAddrx()); + result.add("userLat",user.getAddry()); + result.add("city",userCity); + return result; + } + } + + //为导航提供必要的数据 + //输入:userId,hotelName + //输出:用户经纬度、用户地址名、酒店经纬度 + @PostMapping("/guide") + public Result guide(@RequestBody Map map){ + + //获取参数 + String userId = String.valueOf(map.get("userId")); + String hotelName = (String) map.get("ends"); + if(userId.isEmpty() || hotelName.isEmpty())return Result.buildFail("参数缺失!"); + //业务查询 + User user = userDao.selects(Long.parseLong(userId)); + Hotel hotel = mapDao.getHotelInfo("hotel_name", hotelName); + + //设置并返回结果集 + if(user == null || hotel == null)return Result.buildFail("查无此地!"); + else{ + Result result = Result.buildSuccess(); + result.add("starts",user.getAddr()); + result.add("userLng",user.getAddrx()); + result.add("userLat",user.getAddry()); + result.add("hotelLng",hotel.getAddx()); + result.add("hotelLat",hotel.getAddy()); + return result; + } + } + + //获取指定酒店的信息 + @GetMapping("/getHotel") + public Result getHotel(String hotel){ + Hotel hotelInfo = mapDao.getHotelInfo("hotel_name", hotel); + return Result.buildSuccess(hotelInfo); + } + + //坐标拾取系统,地址解析 + @PostMapping("/getAddr") + public Result getAddr(@RequestBody Locations location) throws Exception { + String address = BaiduMapUtil.getAddress(location.getLng(), location.getLat()); + return Result.buildSuccess(address); + } + +} diff --git a/src/main/java/com/suse/jd_system_server/controller/RoomController_lhj.java b/src/main/java/com/suse/jd_system_server/controller/RoomController_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..267cd3ede44ed48b6ff59cb0fd26c8a9252470e3 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/RoomController_lhj.java @@ -0,0 +1,21 @@ +package com.suse.jd_system_server.controller; + +import com.suse.jd_system_server.auto.empty.Result; +import com.suse.jd_system_server.service.RoomService_lhj; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/RoomURLlhj") +@CrossOrigin +public class RoomController_lhj { + @Autowired + private RoomService_lhj roomservice; + /** + 根据Com_id查询 + */ + @GetMapping("/searchroom/{room_id}") + public Result searchroom(@PathVariable(value = "room_id") Long room_id){ + return Result.buildSuccess(roomservice.searchroom(room_id)); + } +} diff --git a/src/main/java/com/suse/jd_system_server/controller/ShbGeneralController.java b/src/main/java/com/suse/jd_system_server/controller/ShbGeneralController.java new file mode 100644 index 0000000000000000000000000000000000000000..fef411d38435d4934ae427ee61679982f956eef2 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/ShbGeneralController.java @@ -0,0 +1,91 @@ +package com.suse.jd_system_server.controller; + +import com.suse.jd_system_server.service.LoginService; +import com.suse.jd_system_server.utils.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +@RestController +@RequestMapping("/General") +@CrossOrigin +public class ShbGeneralController { + + @Autowired + private LoginService loginService; + + /** + * 登录 + * @param param + * @return + */ + @PostMapping("login") + public Result login(@RequestBody Map param){ + return loginService.Login(param.get("username").toString(), param.get("password").toString()); + } + + /** + * 退出登录 + * @param userId + * @return + */ + @GetMapping("logout") + public Result logout(Long userId) { + return loginService.Logout(userId); + } + + /** + * 注册 + * @param param + * @return + */ + @PostMapping("/register") + public Result register(@RequestBody Map param){ + return loginService.Register(param); + } + /** + * 查询角色对应权限 + * @param role_id + * @return + */ + @GetMapping("/selectRoles/{role_id}") + public Result selectRoles(@PathVariable(value = "role_id")Long role_id){ + return Result.buildSuccess(loginService.selectRoles(role_id)); + } + /** + * 查询所有权限 + * @return + */ + @GetMapping("/selectallAuthority") + public Result selectallAuthority(){ + return Result.buildSuccess(loginService.selectallAuthority()); + } + /** + * 删除角色对应权限 + * @param param + * @return + */ + @PostMapping("/deleteau") + public Result deleteau(@RequestBody Map param){ + loginService.deleteau(param); + return Result.buildSuccess(); + } + + /** + * 查询省份 + * @return + */ + @GetMapping("/selectProvince") + public Result selectProvince(){ + return Result.buildSuccess(loginService.selectProvince()); + } + /** + * 查询城市 + * @return + */ + @GetMapping("/selectCity") + public Result selectCity(String cityName){ + return Result.buildSuccess(loginService.selectCity(cityName)); + } +} diff --git a/src/main/java/com/suse/jd_system_server/controller/ShbRolesController.java b/src/main/java/com/suse/jd_system_server/controller/ShbRolesController.java new file mode 100644 index 0000000000000000000000000000000000000000..35adf652fd5d1a0ff9c6921f963c45f969d37c1e --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/ShbRolesController.java @@ -0,0 +1,14 @@ +package com.suse.jd_system_server.controller; + +import com.suse.jd_system_server.utils.Result; +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; + +@RestController +@RequestMapping("/roles") +public class ShbRolesController { + + +} diff --git a/src/main/java/com/suse/jd_system_server/controller/Shb_hotelPageController.java b/src/main/java/com/suse/jd_system_server/controller/Shb_hotelPageController.java new file mode 100644 index 0000000000000000000000000000000000000000..e30f2d1e9d6b5ce8d05cf99462a2f241aefb2d56 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/Shb_hotelPageController.java @@ -0,0 +1,29 @@ +package com.suse.jd_system_server.controller; + +import com.suse.jd_system_server.Vo.HotelPageListVo; +import com.suse.jd_system_server.service.Shb_hotelPageService; +import com.suse.jd_system_server.service.impl.Shb_hotelPageServiceImpl; +import com.suse.jd_system_server.utils.Result; +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.List; +import java.util.Map; + +@RestController +@RequestMapping("/HotelPage") +public class Shb_hotelPageController { + + @Autowired + private Shb_hotelPageService service; + + @PostMapping("selectHotelList") + public Result selectHotelList(@RequestBody Map param){ + System.out.println(param); + List hotelPageListVos = service.selectHotelList(param); + return Result.buildSuccess(hotelPageListVos); + } +} diff --git a/src/main/java/com/suse/jd_system_server/controller/UserOrdersController.java b/src/main/java/com/suse/jd_system_server/controller/UserOrdersController.java new file mode 100644 index 0000000000000000000000000000000000000000..c7baa16ef2573c6d5120c072dc39633fe999524d --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/controller/UserOrdersController.java @@ -0,0 +1,67 @@ +package com.suse.jd_system_server.controller; + + +import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.service.UserService_rp; +import com.suse.jd_system_server.service.impl.OrdersServiceImpl_rp; +import com.suse.jd_system_server.service.impl.UserServiceImpl_rp; +import com.suse.jd_system_server.utils.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.Base64; +import java.util.Map; + +@RestController +@RequestMapping("/PersonalOrders") +@CrossOrigin() +public class UserOrdersController { + @Autowired + OrdersServiceImpl_rp ordersService; + @Autowired + UserServiceImpl_rp userServiceImpl_rp; + @GetMapping("/getOrdersListById/{user_id}") + public Result getOrdersListById (@PathVariable(value = "user_id")Long user_id){ + return Result.buildSuccess(ordersService.getOrdersList(user_id)); + } + + @GetMapping("/getOrderById/{order_id}") + public Result getOrderById (@PathVariable(value = "order_id")Long order_id){ + return Result.buildSuccess(ordersService.getOrderById(order_id)); + } + + @PostMapping("/searchList") + public Result searchList(@RequestBody Map param){ + System.out.println(param); + return Result.buildSuccess(ordersService.searchList(param)); + } + @PostMapping("/updateUser") + public Result updateUser(@RequestBody User param){ +// System.out.println(param); + return Result.buildSuccess(userServiceImpl_rp.updateUser(param)); + } + @GetMapping("/selectUser/{user_id}") + public Result selectUser (@PathVariable(value = "user_id")Long user_id){ + return Result.buildSuccess(userServiceImpl_rp.selectUser(user_id)); + } + @PostMapping("/confPWD") + public Result confPWD (@RequestBody Map param){ +// System.out.println(param); + return Result.buildSuccess(userServiceImpl_rp.confPWD(param)); + } + @PostMapping("/cancelOrder") + public Result cancelOrder(@RequestBody Map param){ + System.out.println(param); + return Result.buildSuccess(ordersService.cancelOrder(param)); + } + @PostMapping("/uploadUi") + public String addUser(@RequestParam("files") MultipartFile file) throws IllegalStateException, IOException { + System.out.println(file.getOriginalFilename() + "图片已传入!!"); + byte[] b = file.getBytes(); + String str = Base64.getEncoder().encodeToString(b); +// System.out.println(str); + return str; + } +} diff --git a/src/main/java/com/suse/jd_system_server/dao/BedDao_lhj.java b/src/main/java/com/suse/jd_system_server/dao/BedDao_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..bf4bebdfb407442fc037b798110072dd778e528f --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/dao/BedDao_lhj.java @@ -0,0 +1,13 @@ +package com.suse.jd_system_server.dao; + +import com.suse.jd_system_server.auto.mapper.BaseMapper; +import com.suse.jd_system_server.entity.Bed_lhj; + +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface BedDao_lhj extends BaseMapper { + + List searchbed(@Param("room_id") Long room_id); +} \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/dao/CommentsDao_lhj.java b/src/main/java/com/suse/jd_system_server/dao/CommentsDao_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..77a82d4303a23e6b6b1d477ecd13e78a2ca47224 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/dao/CommentsDao_lhj.java @@ -0,0 +1,17 @@ +package com.suse.jd_system_server.dao; + +import com.suse.jd_system_server.auto.entity.Comments; +import com.suse.jd_system_server.auto.mapper.BaseMapper; +import com.suse.jd_system_server.entity.Comments_lhj; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface CommentsDao_lhj extends BaseMapper { + /** + 根据Com_id查询 + */ + public List connect(@Param("hotelId") Long hotelId); +} diff --git a/src/main/java/com/suse/jd_system_server/dao/HotelDao_lhj.java b/src/main/java/com/suse/jd_system_server/dao/HotelDao_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..51564ed77f7b6b802eb6958ca831a9efcb36d527 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/dao/HotelDao_lhj.java @@ -0,0 +1,18 @@ +package com.suse.jd_system_server.dao; + + +import com.suse.jd_system_server.auto.entity.Room; +import com.suse.jd_system_server.auto.mapper.BaseMapper; +import com.suse.jd_system_server.entity.Room_lhj; +import org.apache.ibatis.annotations.Param; +import java.util.HashMap; +import java.util.List; +/** + *@作者:lhj + *DAO接口 + *@Date:2023/10/18 + */ +public interface HotelDao_lhj extends BaseMapper { + + List searchhotel(@Param("hotelId") Long hotelId); +} \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/dao/MapDao.java b/src/main/java/com/suse/jd_system_server/dao/MapDao.java new file mode 100644 index 0000000000000000000000000000000000000000..bc1ea80be76a2b3d6cae44e66227947003f6e546 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/dao/MapDao.java @@ -0,0 +1,20 @@ +package com.suse.jd_system_server.dao; + +import com.suse.jd_system_server.entity.Hotel; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.ArrayList; + +/** + * 地图组件需要的dao + */ +@Mapper +public interface MapDao { + //获取一个城市内所有酒店信息 + @Select("select addx,addy,hotel_name from hotel where city = #{city}") + ArrayList getLocation(String city); + //获取信息 + @Select("select * from hotel where ${str} = #{value}") + Hotel getHotelInfo(String str,T value); +} diff --git a/src/main/java/com/suse/jd_system_server/dao/OrdersDao_rp.java b/src/main/java/com/suse/jd_system_server/dao/OrdersDao_rp.java new file mode 100644 index 0000000000000000000000000000000000000000..7b0057e87373ee9cfa89e2f175feb19f2eab3853 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/dao/OrdersDao_rp.java @@ -0,0 +1,19 @@ +package com.suse.jd_system_server.dao; + +import com.suse.jd_system_server.entity.Orders_rp; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface OrdersDao_rp { + //根据用户id查找订单 + List getOrdersList(long user_id); + //根据订单id查找订单详情 + List getOrderById(long order_id); + //条件查询 + List searchList(Map param); + //取消订单 + Integer cancelOrder(Map param); +} diff --git a/src/main/java/com/suse/jd_system_server/dao/RoomDao_lhj.java b/src/main/java/com/suse/jd_system_server/dao/RoomDao_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..0b1a1c65cb4c1220a77653583e3f58f03fc92732 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/dao/RoomDao_lhj.java @@ -0,0 +1,19 @@ +package com.suse.jd_system_server.dao; + + +import com.suse.jd_system_server.auto.entity.Room; +import com.suse.jd_system_server.auto.mapper.BaseMapper; +import com.suse.jd_system_server.entity.Room_lhj; +import org.apache.ibatis.annotations.Param; +import java.util.HashMap; +import java.util.List; +/** + *@作者:lhj + *DAO接口 + *@Date:2023/10/18 + */ +public interface RoomDao_lhj extends BaseMapper { + + List searchroom(@Param("room_id") Long room_id); + +} \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/dao/UserDao.java b/src/main/java/com/suse/jd_system_server/dao/UserDao.java index 88d15325b63110c65acdde432eca7d11533ec4bc..1d4999350a113dd2e03fa688b22e5eef2b449b79 100644 --- a/src/main/java/com/suse/jd_system_server/dao/UserDao.java +++ b/src/main/java/com/suse/jd_system_server/dao/UserDao.java @@ -2,6 +2,7 @@ package com.suse.jd_system_server.dao; import com.suse.jd_system_server.entity.User; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; /** @@ -10,5 +11,5 @@ import org.apache.ibatis.annotations.Select; @Mapper public interface UserDao { @Select("select * from user where user_id = #{id}") - User selects(Long id); + User selects(@Param("id") Long id); } diff --git a/src/main/java/com/suse/jd_system_server/dao/UserDao_rp.java b/src/main/java/com/suse/jd_system_server/dao/UserDao_rp.java new file mode 100644 index 0000000000000000000000000000000000000000..a36f834637295bdc32ac15fe954d4dfe296119ee --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/dao/UserDao_rp.java @@ -0,0 +1,20 @@ +package com.suse.jd_system_server.dao; + +import com.suse.jd_system_server.entity.User; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface UserDao_rp { + //根据id修改用户信息 + Integer updateUser(User user); + //查找用户信息 + User selectUser (Long userId); + //确认用户密码是否相同 + boolean confPWD(Map param); + //修改用户密码 + Integer changePWD(Map param); + +} diff --git a/src/main/java/com/suse/jd_system_server/entity/Bed_lhj.java b/src/main/java/com/suse/jd_system_server/entity/Bed_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..6e6c0d28e288ad001d7e91fb3ef95ef906b9dc08 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/entity/Bed_lhj.java @@ -0,0 +1,14 @@ +package com.suse.jd_system_server.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Bed_lhj { + private Long room_id; + private String bedName; + private String bedShape; +} diff --git a/src/main/java/com/suse/jd_system_server/entity/Comments_lhj.java b/src/main/java/com/suse/jd_system_server/entity/Comments_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..f38021c619859cdce91d15a89d062bd1eb8c323b --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/entity/Comments_lhj.java @@ -0,0 +1,15 @@ +package com.suse.jd_system_server.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Comments_lhj extends Comments{ + + private String userName; + private String img; + private String description; +} diff --git a/src/main/java/com/suse/jd_system_server/entity/Hotel_lhj.java b/src/main/java/com/suse/jd_system_server/entity/Hotel_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..fc7b10dcae163788508d1d62e8727127baa2aadf --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/entity/Hotel_lhj.java @@ -0,0 +1,13 @@ +package com.suse.jd_system_server.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Hotel_lhj { + private String imgUrl; + private Long hotelId; +} diff --git a/src/main/java/com/suse/jd_system_server/entity/Orders_rp.java b/src/main/java/com/suse/jd_system_server/entity/Orders_rp.java new file mode 100644 index 0000000000000000000000000000000000000000..94e3ca1c7b6c79a2e67cd2161d1e78ef6300bdff --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/entity/Orders_rp.java @@ -0,0 +1,52 @@ +package com.suse.jd_system_server.entity; + +import lombok.AllArgsConstructor; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Orders_rp extends Orders{ + + private String hotelName; + /** + * 酒店星级 + */ + private Long hotelStar; + + private String country; + + private String province; + + private String city; + + private String region; + /** + * 结构化地址 + */ + private String addr; + /** + * 能否停车(0否1是) + */ + private Integer isParking; + + private String telphone; + /** + * 酒店描述 + */ + private String description; + /** + * 酒店面积 + */ + private Double area; + /** + * 房间名 + */ + private String roomName; + /** + * 房间价格 + */ + private Double roomPrice; +} diff --git a/src/main/java/com/suse/jd_system_server/entity/Room_lhj.java b/src/main/java/com/suse/jd_system_server/entity/Room_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..ee61bc1a703456dc6af331f5206b2e82971d7905 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/entity/Room_lhj.java @@ -0,0 +1,24 @@ +package com.suse.jd_system_server.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 房间表(Room)实体类 + * + * @author makejava + * @since 2023-10-20 17:12:48 + */ + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Room_lhj { + private String imgUrl; + private Long room_id; + +} + diff --git a/src/main/java/com/suse/jd_system_server/entity/User.java b/src/main/java/com/suse/jd_system_server/entity/User.java index 1148be178c5eb7e1d1db53db7f981e66c9073749..5eb78d4be016155e52389d57255b7e360ce955a2 100644 --- a/src/main/java/com/suse/jd_system_server/entity/User.java +++ b/src/main/java/com/suse/jd_system_server/entity/User.java @@ -72,7 +72,7 @@ public class User implements Serializable { */ private Integer status; /** - * 用户资料状态(0未通过1已通过),默认为0 + * 用户资料状态(0已提交,1未通过,2已通过),默认为0 */ private Integer infoStatus; } diff --git a/src/main/java/com/suse/jd_system_server/epmty/Locations.java b/src/main/java/com/suse/jd_system_server/epmty/Locations.java new file mode 100644 index 0000000000000000000000000000000000000000..58d87996ff470beab7e8a6fbf29375d6e444d4e6 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/epmty/Locations.java @@ -0,0 +1,19 @@ +package com.suse.jd_system_server.epmty; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 地址类,经纬度 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Locations { + + private Double lng;//经度 + + private Double lat;//纬度 + +} diff --git a/src/main/java/com/suse/jd_system_server/filter/JwtAuthenticationTokenFilter.java b/src/main/java/com/suse/jd_system_server/filter/JwtAuthenticationTokenFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..d55c35896bc02d1df59f614cfafeae71d01871ee --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/filter/JwtAuthenticationTokenFilter.java @@ -0,0 +1,99 @@ +package com.suse.jd_system_server.filter; + +import com.alibaba.fastjson.JSON; +import com.auth0.jwt.interfaces.Claim; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.utils.JwtUtils; +import com.suse.jd_system_server.utils.Result; +import com.suse.jd_system_server.utils.loginHandler; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.filter.OncePerRequestFilter; +import org.springframework.web.servlet.HandlerExceptionResolver; + +import javax.annotation.Resource; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { + + @Autowired + private JwtUtils jwtUtils; + + + @Resource + private StringRedisTemplate stringRedisTemplate; + + @Autowired + @Qualifier("handlerExceptionResolver") + private HandlerExceptionResolver resolver; + + @Autowired + private com.suse.jd_system_server.utils.loginHandler loginHandler; + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + String requestUrl = request.getRequestURI(); + //登录请求则放行 + if (requestUrl.contains("/login") || requestUrl.contains("/register") || + requestUrl.contains("/selectHotelList") || requestUrl.contains("/map")|| + requestUrl.contains("/selectProvince") || requestUrl.contains("/selectCity") + ) { + doFilter(request, response, filterChain); + return; + } + //获取请求头信息 + String token = request.getHeader("token"); + + if (StringUtils.isEmpty(token)) { + //没有token +// throw new RuntimeException("token错误"); +// resolver.resolveException(request, response, null,new RuntimeException("客户端信息非法!!!")); +// request.setAttribute("errorMessage","该用户已被锁定!"); + MyException(response, "用户未登录"); + } else { + //有则解析token,获取用户信息 + //解析token +// Claim CluserId = jwtUtils.getUserFromToken(token).getClaim("userId"); + DecodedJWT CluserId = jwtUtils.getUserFromToken(token); + if (CluserId == null) { + MyException(response, "token错误"); + return; + } + Integer userId = CluserId.getClaim("userId").asInt(); + //从redis查看用户是否已经登录 + String struser = stringRedisTemplate.opsForValue().get("userid:" + userId); + if (struser == null) { + MyException(response, "用户未登录"); + return; + } + User user = new ObjectMapper().readValue(struser, User.class); + UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user, null, null); + SecurityContextHolder.getContext().setAuthentication(authenticationToken); + //放行 + doFilter(request, response, filterChain); + } + } + + private void MyException(HttpServletResponse response, String message) throws IOException { + Result result = Result.buildFail(message); + String json = JSON.toJSONString(result); + response.setStatus(200); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + response.getWriter().print(json); + } +} diff --git a/src/main/java/com/suse/jd_system_server/service/BedService_lhj.java b/src/main/java/com/suse/jd_system_server/service/BedService_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..344e9c703141bb776c17c11692bee29a7c9c4387 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/BedService_lhj.java @@ -0,0 +1,10 @@ +package com.suse.jd_system_server.service; + +import com.suse.jd_system_server.entity.Bed_lhj; + + +import java.util.List; + +public interface BedService_lhj { + public List searchbed(Long room_id); +} diff --git a/src/main/java/com/suse/jd_system_server/service/CommentsService_lhj.java b/src/main/java/com/suse/jd_system_server/service/CommentsService_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..1b628a8595caa982e64bf2760f6e61c0e2531834 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/CommentsService_lhj.java @@ -0,0 +1,20 @@ +package com.suse.jd_system_server.service; + +import com.suse.jd_system_server.entity.Comments; +import com.suse.jd_system_server.entity.Comments_lhj; + +import java.util.Map; +import java.util.List; +/** + *@作者:lhj + *Service接口 + *@Date:2023/10/18 + */ +public interface CommentsService_lhj { + + /** + 根据Com_id查询 + */ + public List connect(Long hotelId); + +} \ No newline at end of file diff --git a/src/main/java/com/suse/jd_system_server/service/HotelService_lhj.java b/src/main/java/com/suse/jd_system_server/service/HotelService_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..0a9b59837609b2b04ed399401c2b5f681ee444d6 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/HotelService_lhj.java @@ -0,0 +1,11 @@ +package com.suse.jd_system_server.service; + +import com.suse.jd_system_server.entity.Hotel_lhj; +import java.util.List; + +public interface HotelService_lhj { + /** + 根据Com_id查询 + */ + public List searchhotel(Long hotelId); +} diff --git a/src/main/java/com/suse/jd_system_server/service/LoginService.java b/src/main/java/com/suse/jd_system_server/service/LoginService.java new file mode 100644 index 0000000000000000000000000000000000000000..3986d954717f20dba88787b8d137aae018b716a1 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/LoginService.java @@ -0,0 +1,33 @@ +package com.suse.jd_system_server.service; + +import com.suse.jd_system_server.entity.Authority; +import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.utils.Result; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +@Service +public interface LoginService { + + User selectUserByName(String username); + + List selectAuthority(Long userid); + + Result Login(String username, String password); + + Result Logout(Long userId); + + Result Register(Map param); + + List selectRoles(Long role_id); + + List selectallAuthority(); + + void deleteau(Map param); + + List selectProvince(); + + List selectCity(String cityName); +} diff --git a/src/main/java/com/suse/jd_system_server/service/OrdersService_rp.java b/src/main/java/com/suse/jd_system_server/service/OrdersService_rp.java new file mode 100644 index 0000000000000000000000000000000000000000..86225a65ed107b41ad12b73c6c8f67689338bfd1 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/OrdersService_rp.java @@ -0,0 +1,15 @@ +package com.suse.jd_system_server.service; + +import com.suse.jd_system_server.entity.Orders_rp; + +import java.util.List; +import java.util.Map; + +public interface OrdersService_rp { + List getOrdersList(long user_id); + + List getOrderById(long order_id); + + List searchList(Map param); + Integer cancelOrder (Map param); +} diff --git a/src/main/java/com/suse/jd_system_server/service/RoomService_lhj.java b/src/main/java/com/suse/jd_system_server/service/RoomService_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..950c3190367487eaea12cc53cedeb5fe5363a3e4 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/RoomService_lhj.java @@ -0,0 +1,12 @@ +package com.suse.jd_system_server.service; + +import com.suse.jd_system_server.entity.Room_lhj; +import java.util.List; + +public interface RoomService_lhj { + /** + 根据Com_id查询 + */ + public List searchroom(Long room_id); +} + diff --git a/src/main/java/com/suse/jd_system_server/service/Shb_hotelPageService.java b/src/main/java/com/suse/jd_system_server/service/Shb_hotelPageService.java new file mode 100644 index 0000000000000000000000000000000000000000..e266bf7e56919e69d769d1aafb5a9057d18e3b86 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/Shb_hotelPageService.java @@ -0,0 +1,11 @@ +package com.suse.jd_system_server.service; + +import com.suse.jd_system_server.Vo.HotelPageListVo; + +import java.util.List; +import java.util.Map; + +public interface Shb_hotelPageService { + + List selectHotelList(Map param); +} diff --git a/src/main/java/com/suse/jd_system_server/service/UserService.java b/src/main/java/com/suse/jd_system_server/service/UserService.java new file mode 100644 index 0000000000000000000000000000000000000000..9919b11c017eac5b88be05e129e6508788698728 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/UserService.java @@ -0,0 +1,5 @@ +package com.suse.jd_system_server.service; + +public interface UserService { + +} diff --git a/src/main/java/com/suse/jd_system_server/service/UserService_rp.java b/src/main/java/com/suse/jd_system_server/service/UserService_rp.java new file mode 100644 index 0000000000000000000000000000000000000000..3a6cb1983361dc21cb80ddb85462e1c44e7e9ebf --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/UserService_rp.java @@ -0,0 +1,16 @@ +package com.suse.jd_system_server.service; + +import com.suse.jd_system_server.entity.User; +import org.springframework.stereotype.Service; + +import java.util.Map; + + +public interface UserService_rp { + //修改用户信息 + Integer updateUser(User user); + //根据id查找用户 + User selectUser(Long userId); + //确认密码是否重复并修改 + boolean confPWD(Map param); +} diff --git a/src/main/java/com/suse/jd_system_server/service/impl/BedServiceImpl_lhj.java b/src/main/java/com/suse/jd_system_server/service/impl/BedServiceImpl_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..5be9d55f622eb410ed384d21c3fadda161338a54 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/impl/BedServiceImpl_lhj.java @@ -0,0 +1,26 @@ +package com.suse.jd_system_server.service.impl; + + + +import com.suse.jd_system_server.dao.BedDao_lhj; + +import com.suse.jd_system_server.entity.Bed_lhj; + +import com.suse.jd_system_server.service.BedService_lhj; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class BedServiceImpl_lhj implements BedService_lhj { + + @Resource + private BedDao_lhj beddao; + + + public List searchbed(Long room_id){ + return beddao.searchbed(room_id); + } + +} diff --git a/src/main/java/com/suse/jd_system_server/service/impl/CommentsServiceImpl_lhj.java b/src/main/java/com/suse/jd_system_server/service/impl/CommentsServiceImpl_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..1f72bb954b9d41df26794e1b8cd2a40374991c65 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/impl/CommentsServiceImpl_lhj.java @@ -0,0 +1,21 @@ +package com.suse.jd_system_server.service.impl; +import com.suse.jd_system_server.dao.CommentsDao_lhj; +import com.suse.jd_system_server.entity.Comments; +import com.suse.jd_system_server.entity.Comments_lhj; +import com.suse.jd_system_server.service.CommentsService_lhj; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class CommentsServiceImpl_lhj implements CommentsService_lhj { + @Resource + private CommentsDao_lhj commentsdao; + /** + 根据Com_id查询 + */ + public List connect(Long hotelId){ + return commentsdao.connect(hotelId); + } +} diff --git a/src/main/java/com/suse/jd_system_server/service/impl/DatasourceInitServiceImpl.java b/src/main/java/com/suse/jd_system_server/service/impl/DatasourceInitServiceImpl.java index 0e86d0109d255c0afd9fcbc0dd25d12886ebee86..d72051eabeaaacff3a5c6b3ddceb6dd6ea154dea 100644 --- a/src/main/java/com/suse/jd_system_server/service/impl/DatasourceInitServiceImpl.java +++ b/src/main/java/com/suse/jd_system_server/service/impl/DatasourceInitServiceImpl.java @@ -3,6 +3,7 @@ package com.suse.jd_system_server.service.impl; import com.fasterxml.jackson.databind.JsonNode; import com.suse.jd_system_server.dao.DatasourceInitDao; import com.suse.jd_system_server.utils.BaiduMapUtil; +import com.suse.jd_system_server.utils.DataInitUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -20,8 +21,8 @@ public class DatasourceInitServiceImpl { */ public void insertHotelData(String code) throws Exception { JsonNode addr = BaiduMapUtil.getAddr("酒店",code); - BaiduMapUtil baiduMapUtil = new BaiduMapUtil(); - baiduMapUtil.insertHotelData(addr); + DataInitUtil dataInitUtil = new DataInitUtil(); + dataInitUtil.insertHotelData(addr); } /** diff --git a/src/main/java/com/suse/jd_system_server/service/impl/HotelServiceImpl_lhj.java b/src/main/java/com/suse/jd_system_server/service/impl/HotelServiceImpl_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..2862016df4a42b46bdedf8ab96dfc3ed5e3eeb30 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/impl/HotelServiceImpl_lhj.java @@ -0,0 +1,20 @@ +package com.suse.jd_system_server.service.impl; + +import com.suse.jd_system_server.dao.HotelDao_lhj; +import com.suse.jd_system_server.entity.Hotel_lhj; +import com.suse.jd_system_server.service.HotelService_lhj; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +@Service +public class HotelServiceImpl_lhj implements HotelService_lhj { + + @Resource + private HotelDao_lhj hoteldao; + + + public List searchhotel(Long hotelId){ + return hoteldao.searchhotel(hotelId); + } +} diff --git a/src/main/java/com/suse/jd_system_server/service/impl/LoginServiceImpl.java b/src/main/java/com/suse/jd_system_server/service/impl/LoginServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..81cd1d418bec9de49820438174df92d2cb67dc4e --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/impl/LoginServiceImpl.java @@ -0,0 +1,127 @@ +package com.suse.jd_system_server.service.impl; + + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.suse.jd_system_server.auto.mapper.LoginMapper; +import com.suse.jd_system_server.entity.Authority; +import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.service.LoginService; +import com.suse.jd_system_server.utils.JwtUtils; +import com.suse.jd_system_server.utils.MD5Utils; +import com.suse.jd_system_server.utils.Result; +import com.suse.jd_system_server.utils.SecurityUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Formatter; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@Service +public class LoginServiceImpl implements LoginService { + + @Autowired + private AuthenticationManager authenticationManager; + + @Resource + private StringRedisTemplate stringRedisTemplate; + + @Autowired + private LoginMapper loginMapper; + + @Autowired + HttpServletRequest httpServletRequest; + + @Override + public User selectUserByName(String username) { + return loginMapper.selectByname(username); + } + + @Override + public List selectAuthority(Long userid) { + return loginMapper.selectAuthority(userid); + } + + @Override + public Result Login(String username, String password) { + //判断密码是否正确 + UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password); + Authentication authenticate = authenticationManager.authenticate(authenticationToken); + if (Objects.isNull(authenticate)) { + throw new RuntimeException("用户名或密码错误"); + } + SecurityUser securityUser = (SecurityUser) authenticate.getPrincipal(); + User user = securityUser.getUser(); + System.out.println(user); + JwtUtils jwtUtils = new JwtUtils(); + String jwt = jwtUtils.createJwt(user.getUserId().intValue(), user.getUserName(), null); + //存入redis + try { + stringRedisTemplate.opsForValue().set("userid:" + user.getUserId(), new ObjectMapper().writeValueAsString(user)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + httpServletRequest.getSession().setAttribute("userId", user.getUserId()); + httpServletRequest.getSession().setAttribute("userName", user.getUserName()); +// System.out.println("setUserId:"+httpServletRequest.getSession().getAttribute("userId")); +// System.out.println("setUserId:"+httpServletRequest.getSession().getAttribute("userName")); + return Result.buildSuccess(jwt).add("userId", user.getUserId()); + } + + @Override + public Result Register(Map param) { + LocalDateTime time = LocalDateTime.now(); + String create_time = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + param.put("create_time",create_time); + param.put("update_time",create_time); + String password = MD5Utils.code(param.get("password").toString()); + param.put("pswd",password); + loginMapper.register(param); + return Result.buildSuccess(); + } + + @Override + public Result Logout(Long userId) { + Boolean delete = stringRedisTemplate.delete("userid:" + userId); + if (delete){ + return Result.buildSuccess(); + }else { + return Result.buildFail("退出登录失败"); + } + } + + @Override + public List selectRoles(Long role_id) { + return loginMapper.selectAuthorityList(role_id); + } + + @Override + public List selectallAuthority() { + return loginMapper.selectallAuthority(); + } + + @Override + public void deleteau(Map param) { + loginMapper.deleteau(param); + } + + @Override + public List selectProvince() { + return loginMapper.selectProvince(); + } + + @Override + public List selectCity(String cityName) { + return loginMapper.selectCity(cityName); + } +} diff --git a/src/main/java/com/suse/jd_system_server/service/impl/OrdersServiceImpl_rp.java b/src/main/java/com/suse/jd_system_server/service/impl/OrdersServiceImpl_rp.java new file mode 100644 index 0000000000000000000000000000000000000000..c1397fc110f63c7a93bbf9ec46be84d5d23834ef --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/impl/OrdersServiceImpl_rp.java @@ -0,0 +1,36 @@ +package com.suse.jd_system_server.service.impl; + +import com.suse.jd_system_server.annotation.logWeaving; +import com.suse.jd_system_server.dao.OrdersDao_rp; +import com.suse.jd_system_server.entity.Orders_rp; +import com.suse.jd_system_server.service.OrdersService_rp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +@Service +public class OrdersServiceImpl_rp implements OrdersService_rp { + @Autowired + OrdersDao_rp ordersDao; + @Override + public List getOrdersList(long user_id) { + return ordersDao.getOrdersList(user_id); + } + + @Override + public List getOrderById(long order_id) { + return ordersDao.getOrderById(order_id); + } + @Override + public List searchList(Map param) { + return ordersDao.searchList(param); + } + + @Override + @logWeaving("对订单表的订单状态进行修改操作") + public Integer cancelOrder(Map param) { + return ordersDao.cancelOrder(param); + } +} diff --git a/src/main/java/com/suse/jd_system_server/service/impl/RoomServiceImpl_lhj.java b/src/main/java/com/suse/jd_system_server/service/impl/RoomServiceImpl_lhj.java new file mode 100644 index 0000000000000000000000000000000000000000..8636721a5861d6befb0c67a191f9ec2968e49e1e --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/impl/RoomServiceImpl_lhj.java @@ -0,0 +1,25 @@ +package com.suse.jd_system_server.service.impl; + + + +import com.suse.jd_system_server.dao.RoomDao_lhj; +import com.suse.jd_system_server.entity.Room_lhj; +import com.suse.jd_system_server.service.RoomService_lhj; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class RoomServiceImpl_lhj implements RoomService_lhj { + + @Resource + private RoomDao_lhj roomdao; + + + public List searchroom(Long room_id){ + return roomdao.searchroom(room_id); + } + + +} diff --git a/src/main/java/com/suse/jd_system_server/service/impl/Shb_hotelPageServiceImpl.java b/src/main/java/com/suse/jd_system_server/service/impl/Shb_hotelPageServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..da8ca7d74f1dcb04d6fc3a6a2ed95b92daba84ee --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/impl/Shb_hotelPageServiceImpl.java @@ -0,0 +1,27 @@ +package com.suse.jd_system_server.service.impl; + +import com.github.pagehelper.PageHelper; +import com.suse.jd_system_server.Vo.HotelPageListVo; +import com.suse.jd_system_server.auto.mapper.Shb_hotelPageMapper; +import com.suse.jd_system_server.service.Shb_hotelPageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +@Transactional +@Service +public class Shb_hotelPageServiceImpl implements Shb_hotelPageService { + + @Autowired + private Shb_hotelPageMapper mapper; + + @Override + public List selectHotelList(Map param) { + param.put("pageNum",(Integer.parseInt(param.get("pageNum").toString())-1)*Integer.parseInt(param.get("pageSize").toString())); + List hotelPageListVos = mapper.selectHotelLists(param); + return hotelPageListVos; + } +} diff --git a/src/main/java/com/suse/jd_system_server/service/impl/UserServiceImpl_rp.java b/src/main/java/com/suse/jd_system_server/service/impl/UserServiceImpl_rp.java new file mode 100644 index 0000000000000000000000000000000000000000..aad1dbda17b6c82b0e0b0a65c521c22e47dac97c --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/service/impl/UserServiceImpl_rp.java @@ -0,0 +1,55 @@ +package com.suse.jd_system_server.service.impl; + +import com.suse.jd_system_server.annotation.logWeaving; +import com.suse.jd_system_server.dao.UserDao_rp; +import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.epmty.Locations; +import com.suse.jd_system_server.service.UserService_rp; +import com.suse.jd_system_server.utils.BaiduMapUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class UserServiceImpl_rp implements UserService_rp { + @Autowired + UserDao_rp userDao_rp; + @Override + @logWeaving("对用户表的用户名,个性签名,地址进行修改") + public Integer updateUser(User user) { + //通过结构化地址获取经纬度 + Locations locations = new Locations(); + if(user.getAddr() !="" && user.getAddr() != null){ + BaiduMapUtil baiduMapUtil = new BaiduMapUtil(); + try { + locations = baiduMapUtil.getAddressNi(user.getAddr()); + } catch (Exception e) { + System.out.println("获取经纬度失败"); + throw new RuntimeException(e); + } + } + user.setAddrx(locations.getLng()); + user.setAddry(locations.getLat()); + + return userDao_rp.updateUser(user); + } + + @Override + public User selectUser(Long userId) { + + return userDao_rp.selectUser(userId); + } + + @Override + @logWeaving("对用户表的密码核对操作不同则对密码进行修改") + public boolean confPWD(Map param) { + if (userDao_rp.confPWD(param)){ + return false; + }else { + userDao_rp.changePWD(param); + return true; + } + } + +} diff --git a/src/main/java/com/suse/jd_system_server/utils/BaiduMapUtil.java b/src/main/java/com/suse/jd_system_server/utils/BaiduMapUtil.java index cc95a68b4469af52c2657b3044686bf46824b2c1..58d0fb05b1b665b6b97a71335a0abe76ca2a2aa1 100644 --- a/src/main/java/com/suse/jd_system_server/utils/BaiduMapUtil.java +++ b/src/main/java/com/suse/jd_system_server/utils/BaiduMapUtil.java @@ -2,9 +2,10 @@ package com.suse.jd_system_server.utils; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.suse.jd_system_server.dao.DatasourceInitDao; +import com.suse.jd_system_server.dao.MapDao; import com.suse.jd_system_server.entity.Hotel; -import com.suse.jd_system_server.entity.HotelData; +import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.epmty.Locations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.util.UriUtils; @@ -14,10 +15,7 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.*; /** * 百度地图api @@ -51,15 +49,15 @@ import java.util.Map; public class BaiduMapUtil { public static String URL = "https://api.map.baidu.com/place/v2/search?";//地址信息请求地址 public static String DETAILURL = "https://api.map.baidu.com/place/v2/detail?";//地址详情请求地址 - public static String CODEURL = "https://api.map.baidu.com/reverse_geocoding/v3?";//地址逆编码请求地址 + public static String CODENIURL = "https://api.map.baidu.com/reverse_geocoding/v3?";//地址逆编码请求地址 + public static String CODEURL = "https://api.map.baidu.com/geocoding/v3?";//地址编码请求地址 private static String AK = "0Eed0TeyLRDZvX513Q8GDcDQkq4AAuIs";//AK密钥 - private static DatasourceInitDao dao; + private static MapDao dao; @Autowired - public void setDao(DatasourceInitDao dao) { + public void setDao(MapDao dao) { BaiduMapUtil.dao = dao; } - /** * 基础参数集 * 根据检索关键词返回一个参数map集合,来自搜索模块 @@ -73,7 +71,7 @@ public class BaiduMapUtil { } /** - * 百度地图提供,检验AK冰完成关键词检索,此处暂时用作获取各个行政区的酒店信息 + * 处理和解析地址并完成请求,此处暂时用作获取各个行政区的酒店信息列表 * @param strUrl,百度api提供的访问地址 * @param param,参数集 * @return 结果集的json字符串 @@ -156,68 +154,21 @@ public class BaiduMapUtil { return objectMapper.readTree(s); } - /** - * 为数据库插入数据,开发阶段使用 - * 需要递归获取一个对象内的需要数值,赋给entity实体类中的对应属性,一次创建一个新对象进行数据库表的插入 - * 获取多个String依次赋给新对象进行数据库操作 - * - * @param addr,待插入的值 - */ - public void insertHotelData(JsonNode addr) throws Exception { - HotelData hotel; - Iterator elements = addr.get("results").elements(); - JsonNode node; - - while(elements.hasNext()){ - node = elements.next(); - hotel = new HotelData(); -// System.out.println(node); -// 地址列表 -// System.out.println("0"+node); -// System.out.println("1"+node.get("uid")); -// System.out.println("2"+node.get("uid").asLong()); - hotel.setHotelName(node.get("name").asText()); - hotel.setAddx(node.get("location").get("lat").asDouble()); - hotel.setAddy(node.get("location").get("lat").asDouble()); - hotel.setProvince(node.get("province").asText()); - hotel.setCity(node.get("city").asText()); - hotel.setRegion(node.get("area").asText()); - hotel.setAddr(node.get("address").asText()); - hotel.setIsParking(node.get("detail").asInt()); - hotel.setTelphone(node.get("telephone").asText()); -// 循环中单个地址详细信息 - JsonNode detail = getDetail(String.valueOf(node.get("uid"))).get("result"); - hotel.setHotelStar(detail.get("detail_info").get("facility_rating").asLong()); - hotel.setDescription(detail.get("detail_info").get("environment_exterior").asText()); -// 其他数据 - hotel.setCountry("中国"); - hotel.setArea(500D); -// 数据插入 -// System.out.println("3"+hotel); - if(dao!=null){ - dao.hotelInsert(hotel); - }else{ - System.out.println("dao为空"); - } - } - - - } /** - * 输入经纬度返回结构化地址 - * @param addrx,经度 - * @param addry,维度 + * 地址解析:输入经纬度返回结构化地址 + * @param lng,经度 + * @param lat,维度 * @return 结构化地址 */ - public static String getAddress(String addrx,String addry) throws Exception { + public static String getAddress(Double lng,Double lat ) throws Exception { //逆编码地址 LinkedHashMap params = getParams(); params.put("coordtype", "wgs84ll"); params.put("extensions_poi", "0"); - params.put("location",addrx+","+addry); + params.put("location",lat+","+lng); // params.put("location","31.225696563611,121.49884033194"); - String s = requestGetAK(CODEURL, params); + String s = requestGetAK(CODENIURL, params); //处理数据 ObjectMapper objectMapper = new ObjectMapper(); @@ -225,7 +176,63 @@ public class BaiduMapUtil { return jsonNode.get("result").get("formatted_address").asText(); } + /** + * 地址编码:传入结构化地址获取经纬度 + */ + public static Locations getAddressNi(String addr) throws Exception { + Locations location = new Locations(); + LinkedHashMap params = getParams(); + + params.put("address", addr); + + String s = requestGetAK(CODEURL, params); + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode node = objectMapper.readTree(s).get("result").get("location"); + location.setLng(node.get("lng").asDouble()); + location.setLat(node.get("lat").asDouble()); + return location; + } + + + /** + * 获取用户城市名 + */ + public static String getUserCity(User user){ + String addr = user.getAddr(); + int starts = addr.indexOf("省"); + int ends = addr.indexOf("市"); + return addr.substring(starts+1,ends+1); + } + + /** + * 获取指定城市内的酒店经纬度对象数组 + */ + public static ArrayListgetLocations(String city){ + Locations location; + ArrayList list = dao.getLocation(city); + ArrayList res = new ArrayList<>(); + for (Hotel h: list) { + location = new Locations(); + location.setLng(h.getAddx()); + location.setLat(h.getAddy()); + res.add(location); + } + return res; + } + + /** + * 获取指定城市内的酒店名list + */ + public static ArrayList getHotels(String city){ + ArrayList hotels = dao.getLocation(city); + ArrayList list = new ArrayList<>(); + for (Hotel h: hotels) { + list.add(h.getHotelName()); + } + return list; + } /** * 为调用者返回搜索集中特定的key集合 diff --git a/src/main/java/com/suse/jd_system_server/utils/DataInitUtil.java b/src/main/java/com/suse/jd_system_server/utils/DataInitUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..ad31f275b5c9d84d9a169666ca6f594a88f9dbce --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/DataInitUtil.java @@ -0,0 +1,62 @@ +package com.suse.jd_system_server.utils; + +import com.fasterxml.jackson.databind.JsonNode; +import com.suse.jd_system_server.dao.DatasourceInitDao; +import com.suse.jd_system_server.entity.HotelData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Iterator; + +/** + * 数据初始化工具类 + */ +@Component +public class DataInitUtil { + private static DatasourceInitDao dao; + + @Autowired + public void setDao(DatasourceInitDao dao) { + DataInitUtil.dao = dao; + } + /** + * hotel表数据插入 + * 需要递归获取一个对象内的需要数值,赋给entity实体类中的对应属性,一次创建一个新对象进行数据库表的插入 + * 获取多个String依次赋给新对象进行数据库操作 + * + * @param addr,待插入的值 + */ + public void insertHotelData(JsonNode addr) throws Exception { + HotelData hotel; + Iterator elements = addr.get("results").elements(); + JsonNode node; + + while(elements.hasNext()){ + node = elements.next(); + hotel = new HotelData(); + + hotel.setHotelName(node.get("name").asText()); + hotel.setAddx(node.get("location").get("lng").asDouble()); + hotel.setAddy(node.get("location").get("lat").asDouble()); + hotel.setProvince(node.get("province").asText()); + hotel.setCity(node.get("city").asText()); + hotel.setRegion(node.get("area").asText()); + hotel.setAddr(node.get("address").asText()); + hotel.setIsParking(node.get("detail").asInt()); + hotel.setTelphone(node.get("telephone").asText()); +// 循环中单个地址详细信息 + JsonNode detail = BaiduMapUtil.getDetail(String.valueOf(node.get("uid"))).get("result"); + hotel.setHotelStar(detail.get("detail_info").get("facility_rating").asLong()); + hotel.setDescription(detail.get("detail_info").get("environment_exterior").asText()); +// 其他数据 + hotel.setCountry("中国"); + hotel.setArea(Math.random()*500+200); +// 数据插入 + if(dao!=null){ + dao.hotelInsert(hotel); + }else{ + System.out.println("dao为空"); + } + } + } +} diff --git a/src/main/java/com/suse/jd_system_server/utils/JwtUtils.java b/src/main/java/com/suse/jd_system_server/utils/JwtUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..a08bcbab7e9bb75ef37099d403a2075dc6913135 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/JwtUtils.java @@ -0,0 +1,74 @@ +package com.suse.jd_system_server.utils; + + +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.exceptions.JWTVerificationException; +import com.auth0.jwt.interfaces.DecodedJWT; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +public class JwtUtils { + private static final String secret="thomas";//密钥 + //创建Jwt + public String createJwt(Integer userId, String userName, List authList){ + Date issDate = new Date();//签发时间时间 + Date expireDate = new Date(issDate.getTime()+1000*60*60*2);//当前时间加上两小时 + Map headerClaims = new HashMap<>(); + headerClaims.put("alg","HS256"); + headerClaims.put("typ","JWT"); + return JWT.create().withHeader(headerClaims) + .withIssuer("pb")//设置签发人 + .withIssuedAt(issDate)//签发时间 + .withExpiresAt(expireDate)//设置过期时间 + .withClaim("userId",userId)//自定义声明 用户Id + .withClaim("userName",userName)//自定义声明 用户名 +// .withClaim("userAuth",authList)//自定义声明 用户权限 + .sign(Algorithm.HMAC256(secret));//使用HS265进行签名,使用secret作为密钥 + } + //校验Jwt + public boolean verifToken(String jwtToken){ + try { + JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(secret)).build(); + //校验token + DecodedJWT decodedJWT = jwtVerifier.verify(jwtToken); + Integer userId = decodedJWT.getClaim("userId").asInt(); + String userName = decodedJWT.getClaim("userName").asString(); + List userAuthList = decodedJWT.getClaim("userAuth").asList(String.class); + return true; + } catch (IllegalArgumentException e) { + e.printStackTrace(); + return false; + } catch (JWTVerificationException e) { + e.printStackTrace(); + return false; + } + } + + /** + * 从jwt的payload里获取声明,获取的用户Id + * @param jwt + * @return + */ + public DecodedJWT getUserFromToken(String jwt){ + try { + JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(secret)).build(); + //校验token + DecodedJWT decodedJWT = jwtVerifier.verify(jwt); +// return decodedJWT.getClaim("userId").asInt(); + Integer userId = decodedJWT.getClaim("userId").asInt(); + String userName = decodedJWT.getClaim("userName").asString(); + List userAuthList = decodedJWT.getClaim("userAuth").asList(String.class); + return decodedJWT; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/java/com/suse/jd_system_server/utils/MD5Utils.java b/src/main/java/com/suse/jd_system_server/utils/MD5Utils.java new file mode 100644 index 0000000000000000000000000000000000000000..06d91e15e6f502d64a6ab62c647738225b4d8e2d --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/MD5Utils.java @@ -0,0 +1,33 @@ +package com.suse.jd_system_server.utils; + +import org.springframework.stereotype.Component; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +@Component +public class MD5Utils { + public static String code(String str){ + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(str.getBytes()); + byte[]byteDigest = md.digest(); + int i; + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < byteDigest.length; offset++) { + i = byteDigest[offset]; + if (i < 0) + i += 256; + if (i < 16) + buf.append("0"); + buf.append(Integer.toHexString(i)); + } + //32位加密 + return buf.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/suse/jd_system_server/utils/MyAccessDeniedHandler.java b/src/main/java/com/suse/jd_system_server/utils/MyAccessDeniedHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..8df41ca96a64731a7c542cce32225121f9deca29 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/MyAccessDeniedHandler.java @@ -0,0 +1,25 @@ +package com.suse.jd_system_server.utils; + +import com.alibaba.fastjson.JSON; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.web.access.AccessDeniedHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class MyAccessDeniedHandler implements AccessDeniedHandler { + @Override + public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { + String message = accessDeniedException.getMessage(); + Result result = Result.buildFail(message); + String json = JSON.toJSONString(result); + response.setStatus(200); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + response.getWriter().print(json); + } +} diff --git a/src/main/java/com/suse/jd_system_server/utils/MyPasswordEncoder.java b/src/main/java/com/suse/jd_system_server/utils/MyPasswordEncoder.java new file mode 100644 index 0000000000000000000000000000000000000000..d0a1d1db485bc6baf386abfde999ffb047d6811c --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/MyPasswordEncoder.java @@ -0,0 +1,17 @@ +package com.suse.jd_system_server.utils; + +import org.springframework.security.crypto.password.PasswordEncoder; + +public class MyPasswordEncoder implements PasswordEncoder { + + + @Override + public String encode(CharSequence rawPassword) { + return MD5Utils.code(rawPassword.toString()); + } + + @Override + public boolean matches(CharSequence rawPassword, String encodedPassword) { + return encodedPassword.equals(MD5Utils.code(rawPassword.toString())); + } +} diff --git a/src/main/java/com/suse/jd_system_server/utils/Result.java b/src/main/java/com/suse/jd_system_server/utils/Result.java index 7c12729a3d75681122ae02817e536acedb784e6f..08004090ab7609af94b8fba6cda16e4a8bc5b5a0 100644 --- a/src/main/java/com/suse/jd_system_server/utils/Result.java +++ b/src/main/java/com/suse/jd_system_server/utils/Result.java @@ -1,6 +1,7 @@ package com.suse.jd_system_server.utils; import lombok.Data; +import lombok.Value; import java.util.HashMap; import java.util.Map; @@ -16,7 +17,7 @@ public class Result { private String msg;//提示信息 - Map map = new HashMap();//动态数据,根据需要为返回值添加信息 + private Map map = new HashMap();//动态数据,根据需要为返回值添加信息 /** * 带参的成功返回 @@ -49,7 +50,7 @@ public class Result { /** * 动态添加数据 */ - public Result add(String key,Object value){ + public Result add(String key, Object value){ this.map.put(key,value); return this; } diff --git a/src/main/java/com/suse/jd_system_server/utils/SecurityUser.java b/src/main/java/com/suse/jd_system_server/utils/SecurityUser.java new file mode 100644 index 0000000000000000000000000000000000000000..950945fb739aaf8bfc7f38e0144ec5c50b4aa7fd --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/SecurityUser.java @@ -0,0 +1,72 @@ +package com.suse.jd_system_server.utils; + +import com.suse.jd_system_server.entity.User; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.Collection; +import java.util.List; + + +public class SecurityUser implements UserDetails { + + private final User user; + private List authorities; + + public SecurityUser(User user){ + this.user=user; + } + + public void setAuthorities(List authorities) { + this.authorities = authorities; + } + + public User getUser() { + return user; + } + + @Override + public Collection getAuthorities() {//配置权限 +// GrantedAuthority grantedAuthority = new GrantedAuthority() { +// @Override +// public String getAuthority() { +// return null; +// } +// }; +// List list = new ArrayList<>(); +// list.add(grantedAuthority); + return authorities; + } + + @Override + public String getPassword() {//获取用户密码 + return user.getPassword(); + } + + @Override + public String getUsername() {//获取用户名 + return user.getUserName(); + } + + @Override + public boolean isAccountNonExpired() {//返回用户账户是否过期 + return true; + } + + @Override + public boolean isAccountNonLocked() {//返回账户是否已锁定 + return true; + } + + @Override + public boolean isCredentialsNonExpired() {//返回凭据/密码是否过期 + return true; + } + + @Override + public boolean isEnabled() {// + return true; + } +} + diff --git a/src/main/java/com/suse/jd_system_server/utils/SecurityUserDetailsServiceImpl.java b/src/main/java/com/suse/jd_system_server/utils/SecurityUserDetailsServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b822dcc946bf8516388daf40ffcec902c759c123 --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/SecurityUserDetailsServiceImpl.java @@ -0,0 +1,48 @@ +package com.suse.jd_system_server.utils; + +import com.suse.jd_system_server.entity.Authority; +import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.service.LoginService; +import com.suse.jd_system_server.service.impl.LoginServiceImpl; +import lombok.SneakyThrows; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component +public class SecurityUserDetailsServiceImpl implements UserDetailsService { + + + @Autowired + private LoginServiceImpl loginService; + + @SneakyThrows + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + User user = loginService.selectUserByName(username); + if (null==user){ + throw new UsernameNotFoundException("用户不存在"); + } + if (user.getStatus()==0){ + throw new RuntimeException("用户未激活"); + } + List sysMenus = loginService.selectAuthority(user.getUserId()); + List authorities = new ArrayList<>(); + //方式一 + for(String menu : sysMenus){ + SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(menu); + authorities.add(simpleGrantedAuthority); + } + //方式二 + //List authorityList = sysMenus.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList()); + SecurityUser securityUser = new SecurityUser(user); + securityUser.setAuthorities(authorities); + return securityUser; + } +} diff --git a/src/main/java/com/suse/jd_system_server/utils/WebSecurityConfig.java b/src/main/java/com/suse/jd_system_server/utils/WebSecurityConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..18c102872db0c4e2bd598d1ff516209f2ab6d24c --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/WebSecurityConfig.java @@ -0,0 +1,60 @@ +package com.suse.jd_system_server.utils; + + +import com.suse.jd_system_server.filter.JwtAuthenticationTokenFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.dao.DaoAuthenticationProvider; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + +//@Configuration //EnableGlobalMethodSecurity注解包含Configuration注解 +@EnableGlobalMethodSecurity(prePostEnabled = true)//开启全局方法安全 +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + @Autowired + private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter; + + @Autowired + private loginHandler loginHandler; + + @Autowired + private MyAccessDeniedHandler myAccessDeniedHandler; + + @Bean + public PasswordEncoder passwordEncoder() { + return new MyPasswordEncoder(); + } + + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable().authorizeRequests() + .antMatchers("/General/login", "/General/register", + "/HotelPage/selectHotelList", "/map/getHotels", "/map/getHotels", + "/map/guide", "/map/getHotel", "/map/getAddr", "/General/selectProvince", "/General/selectCity" + ) + .permitAll() + .anyRequest().authenticated(); + http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); + http.exceptionHandling().authenticationEntryPoint(loginHandler);//.accessDeniedHandler(myAccessDeniedHandler) + http.cors(); +// http.formLogin() +// .successHandler(appAutheticationSuccessHandler)//登录成功处理器 可以用匿名实现类/lamda表达式实现接口的方法 +// .failureHandler(appAutheticationFailHandler)//登录失败处理器 + +// .permitAll(); +// http.exceptionHandling().accessDeniedHandler(appAccessDenyHanlder);//配置访问拒绝处理器 + + } +} diff --git a/src/main/java/com/suse/jd_system_server/utils/loginHandler.java b/src/main/java/com/suse/jd_system_server/utils/loginHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..265e9a9d33876551d181bf7e8cbe3b82919da54d --- /dev/null +++ b/src/main/java/com/suse/jd_system_server/utils/loginHandler.java @@ -0,0 +1,36 @@ +package com.suse.jd_system_server.utils; + +import com.alibaba.fastjson.JSON; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.authentication.AuthenticationFailureHandler; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class loginHandler implements AuthenticationEntryPoint { + @Override + public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { +// ResponseResult result = new ResponseResult(HttpStatus.UNAUTHORIZED.value(), "认证失败请重新登录"); + String message = authException.getMessage(); + Result result = Result.buildFail(message); + String json = JSON.toJSONString(result); + response.setStatus(200); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + response.getWriter().print(json); + + } + + /*@Override + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { + System.out.println("失败"); + }*/ +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4a01ceaf9cf94c414485f1452344dc36d6dcf091..54d58faa24fd944b0b692d4bf2dc239c7e26473c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,14 +1,32 @@ server: port: 8080 spring: + + servlet: + multipart: + max-file-size: 100MB + max-request-size: 1000MB datasource: url: jdbc:mysql://rm-cn-zpr3fh9s1000lro.rwlb.cn-chengdu.rds.aliyuncs.com:3306/jd_sys?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 username: pb password: Pb123456 driver-class-name: com.mysql.cj.jdbc.Driver + redis: + host: 47.108.152.196 mybatis: mapper-locations: classpath:mapper/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + jdbc-type-for-null: NULL + map-underscore-to-camel-case: true + database-id: mysql pagehelper: helperDialect: mysql reasonable: true supportMethodsArguments: true +logging: + level: + com.suse.jd_system_server.auto.mapper: debug + + + diff --git a/src/main/resources/mapper/BedMapper_lhj.xml b/src/main/resources/mapper/BedMapper_lhj.xml new file mode 100644 index 0000000000000000000000000000000000000000..d8f4a37b171d441539572c2063beba11583cdc9e --- /dev/null +++ b/src/main/resources/mapper/BedMapper_lhj.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/main/resources/mapper/CommentsMapper.xml b/src/main/resources/mapper/CommentsMapper.xml index 0aabadc2082978243bbbe711e7030eefb2309223..9f3f141eb82bf8eeaac234b3bd981230ce5e3953 100644 --- a/src/main/resources/mapper/CommentsMapper.xml +++ b/src/main/resources/mapper/CommentsMapper.xml @@ -18,12 +18,14 @@ + + - com_id,user_id,hotel_id,com_text,create_time,update_time,status + com_id,user_id,hotel_id,com_text,create_time,update_time,status,com_status @@ -50,6 +52,9 @@ and status = #{query.status} + + and com_status = #{query.com_status} + @@ -130,6 +135,9 @@ status, + + com_status, + @@ -153,6 +161,9 @@ #{bean.status}, + + #{bean.com_status}, + @@ -182,6 +193,9 @@ status, + + com_status, + @@ -205,6 +219,9 @@ #{bean.status}, + + #{bean.com_status}, + on DUPLICATE key update @@ -226,26 +243,29 @@ status= VALUES(status), + + com_status= VALUES(com_status), + - INSERT INTO comments(user_id,hotel_id,com_text,create_time,update_time,status)values + INSERT INTO comments(user_id,hotel_id,com_text,create_time,update_time,status,com_status)values - (#{item.user_id},#{item.hotel_id},#{item.com_text},#{item.create_time},#{item.update_time},#{item.status}) + (#{item.user_id},#{item.hotel_id},#{item.com_text},#{item.create_time},#{item.update_time},#{item.status},#{item.com_status}) - INSERT INTO comments(com_id,user_id,hotel_id,com_text,create_time,update_time,status)values + INSERT INTO comments(com_id,user_id,hotel_id,com_text,create_time,update_time,status,com_status)values - (#{item.com_id},#{item.user_id},#{item.hotel_id},#{item.com_text},#{item.create_time},#{item.update_time},#{item.status}) + (#{item.com_id},#{item.user_id},#{item.hotel_id},#{item.com_text},#{item.create_time},#{item.update_time},#{item.status},#{item.com_status}) - on DUPLICATE key update user_id = VALUES(user_id),hotel_id = VALUES(hotel_id),com_text = VALUES(com_text),create_time = VALUES(create_time),update_time = VALUES(update_time),status = VALUES(status) + on DUPLICATE key update user_id = VALUES(user_id),hotel_id = VALUES(hotel_id),com_text = VALUES(com_text),create_time = VALUES(create_time),update_time = VALUES(update_time),status = VALUES(status),com_status = VALUES(com_status) @@ -282,6 +302,9 @@ status = #{bean.status}, + + com_status = #{bean.com_status}, + where com_id=#{bean.com_id} diff --git a/src/main/resources/mapper/CommentsMapper_lhj.xml b/src/main/resources/mapper/CommentsMapper_lhj.xml new file mode 100644 index 0000000000000000000000000000000000000000..5cbe13e47e77c4db84079ff1cde8dadad5502124 --- /dev/null +++ b/src/main/resources/mapper/CommentsMapper_lhj.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/src/main/resources/mapper/HotelMapper.xml b/src/main/resources/mapper/HotelMapper.xml index 6d8f6df15e531f1d948786b7c470c6722ac1ad4a..70357aba30b7e3784e98fcdf618dacd4f0a9e82b 100644 --- a/src/main/resources/mapper/HotelMapper.xml +++ b/src/main/resources/mapper/HotelMapper.xml @@ -4,9 +4,9 @@ - + - + @@ -14,19 +14,19 @@ - + - + - + - + - + @@ -76,7 +76,7 @@ and is_parking = #{query.is_parking} - + and telphone = #{query.telphone} @@ -108,6 +108,9 @@ and addr like concat('%', #{query.addrLike}, '%' ) + + and telphone like concat('%', #{query.telphoneLike}, '%' ) + and description like concat('%', #{query.descriptionLike}, '%' ) diff --git a/src/main/resources/mapper/HotelMapper_lhj.xml b/src/main/resources/mapper/HotelMapper_lhj.xml new file mode 100644 index 0000000000000000000000000000000000000000..c6acf9a718e4d4944eca4446681025ef6c8ee27a --- /dev/null +++ b/src/main/resources/mapper/HotelMapper_lhj.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/main/resources/mapper/ImgMapper.xml b/src/main/resources/mapper/ImgMapper.xml index d5cb6b705e0300110143bcd945cc715e7abd331b..acb11ca5198fb8b78c920ec61ce26f4418a24672 100644 --- a/src/main/resources/mapper/ImgMapper.xml +++ b/src/main/resources/mapper/ImgMapper.xml @@ -12,18 +12,20 @@ + + - img_id,hotel_id,room_id,img_url + img_id,hotel_id,room_id,img_url,is_hotel - + and img_id = #{query.img_id} @@ -35,6 +37,9 @@ and img_url = #{query.img_url} + + and is_hotel = #{query.is_hotel} + @@ -106,6 +111,9 @@ img_url, + + is_hotel, + @@ -120,6 +128,9 @@ #{bean.img_url}, + + #{bean.is_hotel}, + @@ -140,6 +151,9 @@ img_url, + + is_hotel, + @@ -154,6 +168,9 @@ #{bean.img_url}, + + #{bean.is_hotel}, + on DUPLICATE key update @@ -166,26 +183,29 @@ img_url= VALUES(img_url), + + is_hotel= VALUES(is_hotel), + - INSERT INTO img(hotel_id,room_id,img_url)values + INSERT INTO img(hotel_id,room_id,img_url,is_hotel)values - (#{item.hotel_id},#{item.room_id},#{item.img_url}) + (#{item.hotel_id},#{item.room_id},#{item.img_url},#{item.is_hotel}) - INSERT INTO img(img_id,hotel_id,room_id,img_url)values + INSERT INTO img(img_id,hotel_id,room_id,img_url,is_hotel)values - (#{item.img_id},#{item.hotel_id},#{item.room_id},#{item.img_url}) + (#{item.img_id},#{item.hotel_id},#{item.room_id},#{item.img_url},#{item.is_hotel}) - on DUPLICATE key update hotel_id = VALUES(hotel_id),room_id = VALUES(room_id),img_url = VALUES(img_url) + on DUPLICATE key update hotel_id = VALUES(hotel_id),room_id = VALUES(room_id),img_url = VALUES(img_url),is_hotel = VALUES(is_hotel) @@ -213,6 +233,9 @@ img_url = #{bean.img_url}, + + is_hotel = #{bean.is_hotel}, + where img_id=#{bean.img_id} diff --git a/src/main/resources/mapper/LoginMapper.xml b/src/main/resources/mapper/LoginMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..f133c447a0220f634c2ad4d8c80e314ff1bb5b3a --- /dev/null +++ b/src/main/resources/mapper/LoginMapper.xml @@ -0,0 +1,53 @@ + + + + + insert into user(user_id, role_id, user_name, password, addrx, addry, addr, description, img, + create_time, update_time, pswd, status, info_status) + value (null, 5, #{account}, #{pswd}, 0, 0, '结构化地址', '用户个性签名', + 'https://i02piccdn.sogoucdn.com/e99e2538b1bf4686',#{create_time},#{update_time},#{password},1,0) + + + delete + from role_authority + where role_id = #{param.role_id} + and au_id = #{param.au_id} + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/LogsMapper.xml b/src/main/resources/mapper/LogsMapper.xml index dd222ef927288ac5c0c12f621b62f463b0f272b2..cad56fa56e0fcb31a77270ca2a708b87743cbfdd 100644 --- a/src/main/resources/mapper/LogsMapper.xml +++ b/src/main/resources/mapper/LogsMapper.xml @@ -23,7 +23,7 @@ - + and log_id = #{query.log_id} diff --git a/src/main/resources/mapper/OrdersMapper.xml b/src/main/resources/mapper/OrdersMapper.xml index 92503aa8babd7d19dd1b9ac883cdf9b64665a4e1..5b9e1591353f0c2fd929dbeb251d5787c5c0793f 100644 --- a/src/main/resources/mapper/OrdersMapper.xml +++ b/src/main/resources/mapper/OrdersMapper.xml @@ -20,7 +20,7 @@ - + @@ -33,7 +33,7 @@ - + and order_id = #{query.order_id} diff --git a/src/main/resources/mapper/OrdersMapper_rp.xml b/src/main/resources/mapper/OrdersMapper_rp.xml new file mode 100644 index 0000000000000000000000000000000000000000..1233ebd503553de5de05b830da605dafd3f1c1d7 --- /dev/null +++ b/src/main/resources/mapper/OrdersMapper_rp.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + update orders + + + status = 3, + + + status = 4, + + + status = 5, + + + where order_id=#{orderId} + + diff --git a/src/main/resources/mapper/RoomMapper.xml b/src/main/resources/mapper/RoomMapper.xml index f398b2397e87a1ec9cd769c67e976426b1e5c101..76a82e68159d1c36f505e1ee9dc80fee2d7ffdeb 100644 --- a/src/main/resources/mapper/RoomMapper.xml +++ b/src/main/resources/mapper/RoomMapper.xml @@ -31,7 +31,7 @@ - room_id,bed_id,room_name,room_price,room_area,is_window,is_wifi,is_breakfast,description,status + room_id,hotel_id,bed_id,room_name,room_price,room_area,is_window,is_wifi,is_breakfast,description,status @@ -40,6 +40,9 @@ and room_id = #{query.room_id} + + and hotel_id = #{query.hotel_id} + and bed_id = #{query.bed_id} @@ -132,6 +135,9 @@ room_id, + + hotel_id, + bed_id, @@ -164,6 +170,9 @@ #{bean.room_id}, + + #{bean.hotel_id}, + #{bean.bed_id}, @@ -202,6 +211,9 @@ room_id, + + hotel_id, + bed_id, @@ -234,6 +246,9 @@ #{bean.room_id}, + + #{bean.hotel_id}, + #{bean.bed_id}, @@ -264,6 +279,9 @@ on DUPLICATE key update + + hotel_id= VALUES(hotel_id), + bed_id= VALUES(bed_id), @@ -297,20 +315,20 @@ - INSERT INTO room(bed_id,room_name,room_price,room_area,is_window,is_wifi,is_breakfast,description,status)values + INSERT INTO room(hotel_id,bed_id,room_name,room_price,room_area,is_window,is_wifi,is_breakfast,description,status)values - (#{item.bed_id},#{item.room_name},#{item.room_price},#{item.room_area},#{item.is_window},#{item.is_wifi},#{item.is_breakfast},#{item.description},#{item.status}) + (#{item.hotel_id},#{item.bed_id},#{item.room_name},#{item.room_price},#{item.room_area},#{item.is_window},#{item.is_wifi},#{item.is_breakfast},#{item.description},#{item.status}) - INSERT INTO room(room_id,bed_id,room_name,room_price,room_area,is_window,is_wifi,is_breakfast,description,status)values + INSERT INTO room(room_id,hotel_id,bed_id,room_name,room_price,room_area,is_window,is_wifi,is_breakfast,description,status)values - (#{item.room_id},#{item.bed_id},#{item.room_name},#{item.room_price},#{item.room_area},#{item.is_window},#{item.is_wifi},#{item.is_breakfast},#{item.description},#{item.status}) + (#{item.room_id},#{item.hotel_id},#{item.bed_id},#{item.room_name},#{item.room_price},#{item.room_area},#{item.is_window},#{item.is_wifi},#{item.is_breakfast},#{item.description},#{item.status}) - on DUPLICATE key update bed_id = VALUES(bed_id),room_name = VALUES(room_name),room_price = VALUES(room_price),room_area = VALUES(room_area),is_window = VALUES(is_window),is_wifi = VALUES(is_wifi),is_breakfast = VALUES(is_breakfast),description = VALUES(description),status = VALUES(status) + on DUPLICATE key update hotel_id = VALUES(hotel_id),bed_id = VALUES(bed_id),room_name = VALUES(room_name),room_price = VALUES(room_price),room_area = VALUES(room_area),is_window = VALUES(is_window),is_wifi = VALUES(is_wifi),is_breakfast = VALUES(is_breakfast),description = VALUES(description),status = VALUES(status) @@ -329,6 +347,9 @@ update room + + hotel_id = #{bean.hotel_id}, + bed_id = #{bean.bed_id}, diff --git a/src/main/resources/mapper/RoomMapper_lhj.xml b/src/main/resources/mapper/RoomMapper_lhj.xml new file mode 100644 index 0000000000000000000000000000000000000000..4578045e4997f2899bb73adb1230f7cf00a98d37 --- /dev/null +++ b/src/main/resources/mapper/RoomMapper_lhj.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/src/main/resources/mapper/Shb_hotelPageMapper.xml b/src/main/resources/mapper/Shb_hotelPageMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..210115b5d3dffee616852530dbf72a1b8c566182 --- /dev/null +++ b/src/main/resources/mapper/Shb_hotelPageMapper.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + hotel.hotel_id, hotel.hotel_name,hotel.hotel_star, hotel.addx, hotel.addy, hotel.country, hotel.province, hotel.city, hotel.region, hotel.addr, hotel.is_parking, hotel.telphone, hotel.description, hotel.area + + hotel_id,hotel_name,hotel_star,addx,addy,country,province,city,region,addr,is_parking,telphone,description,area + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TestyMapper.xml b/src/main/resources/mapper/TestyMapper.xml index f365b3c86a96db7e574ec235611ac40d60ae1050..a1693acd29b35359b7bbbfe7a869ed402c67f490 100644 --- a/src/main/resources/mapper/TestyMapper.xml +++ b/src/main/resources/mapper/TestyMapper.xml @@ -4,6 +4,8 @@ + + @@ -13,12 +15,15 @@ - id,name + an_id,id,name + + and an_id = #{query.an_id} + and id = #{query.id} @@ -84,6 +89,9 @@ INSERT INTO testy + + an_id, + id, @@ -92,6 +100,9 @@ + + #{bean.an_id}, + #{bean.id}, @@ -106,6 +117,9 @@ INSERT INTO testy + + an_id, + id, @@ -114,6 +128,9 @@ + + #{bean.an_id}, + #{bean.id}, @@ -132,53 +149,53 @@ - INSERT INTO testy(name)values + INSERT INTO testy(an_id,name)values - (#{item.name}) + (#{item.an_id},#{item.name}) - INSERT INTO testy(id,name)values + INSERT INTO testy(an_id,id,name)values - (#{item.id},#{item.name}) + (#{item.an_id},#{item.id},#{item.name}) - on DUPLICATE key update name = VALUES(name) + on DUPLICATE key update an_id = VALUES(an_id),name = VALUES(name) - - select from testy - where id=#{id} + where id=#{id} andan_id=#{an_id} - - + + update testy name = #{bean.name}, - where id=#{bean.id} + where id=#{bean.id} andan_id=#{bean.an_id} - - + + delete from testy - where id=#{id} + where id=#{id} andan_id=#{an_id} diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index f8679bbdf19c37b43054f5ab9454bc0e0165da75..06308fb0275dbb25d6f6cb47a7498b0eb0268448 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -30,7 +30,7 @@ - + @@ -43,7 +43,7 @@ - + and user_id = #{query.user_id} @@ -169,7 +169,7 @@ user_name, - password, + password,pswd, addrx, @@ -192,9 +192,6 @@ update_time, - - pswd, - status, @@ -213,7 +210,7 @@ #{bean.user_name}, - #{bean.password}, + MD5(#{bean.password}),#{bean.password}, #{bean.addrx}, @@ -236,9 +233,6 @@ #{bean.update_time}, - - #{bean.pswd}, - #{bean.status}, @@ -263,7 +257,7 @@ user_name, - password, + password,pswd, addrx, @@ -286,9 +280,6 @@ update_time, - - pswd, - status, @@ -307,7 +298,7 @@ #{bean.user_name}, - #{bean.password}, + #{bean.password},#{bean.password}, #{bean.addrx}, @@ -330,9 +321,6 @@ #{bean.update_time}, - - #{bean.pswd}, - #{bean.status}, @@ -349,7 +337,7 @@ user_name= VALUES(user_name), - password= VALUES(password), + password= MD5(password),pswd=VALUES(password), addrx= VALUES(addrx), @@ -372,9 +360,6 @@ update_time= VALUES(update_time), - - pswd= VALUES(pswd), - status= VALUES(status), diff --git a/src/main/resources/mapper/UserMapper_rp.xml b/src/main/resources/mapper/UserMapper_rp.xml new file mode 100644 index 0000000000000000000000000000000000000000..c05ab2ceabf7a16c8359990db49fa2e040326b55 --- /dev/null +++ b/src/main/resources/mapper/UserMapper_rp.xml @@ -0,0 +1,59 @@ + + + + + + update user + + info_status = 0, + + role_id = #{roleId}, + + + user_name = #{userName}, + + + addrx = #{addrx}, + + + addry = #{addry}, + + + addr = #{addr}, + + + description = #{description}, + + + img = #{img}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where user_id=#{userId} + + + + + + + + update `user` + set + `password` = MD5 ( #{password} ),pswd = #{password} + where user_id=#{userId} + + + diff --git a/src/test/java/com/suse/jd_system_server/JdSystemServerApplicationTests.java b/src/test/java/com/suse/jd_system_server/JdSystemServerApplicationTests.java index f9b4ddd2a49ee90f827a7fde78c75d1e1b8a1478..96383d5439d1ce9ccc2e3e2e93e99821dde6218e 100644 --- a/src/test/java/com/suse/jd_system_server/JdSystemServerApplicationTests.java +++ b/src/test/java/com/suse/jd_system_server/JdSystemServerApplicationTests.java @@ -9,6 +9,7 @@ import com.suse.jd_system_server.dao.UserDao; import com.suse.jd_system_server.entity.Hotel; import com.suse.jd_system_server.entity.Testy; import com.suse.jd_system_server.entity.User; +import com.suse.jd_system_server.epmty.Locations; import com.suse.jd_system_server.service.impl.DatasourceInitServiceImpl; import com.suse.jd_system_server.service.impl.userTestyServiceImpl_pb; import com.suse.jd_system_server.utils.BaiduMapUtil; @@ -16,6 +17,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import javax.annotation.Resource; +import java.awt.geom.Arc2D; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -26,7 +29,7 @@ class JdSystemServerApplicationTests { private TestyDao testyDao; @Autowired - private static UserDao userDao; + private UserDao userDao; private BaiduMapUtil baiduMapUtil; @@ -56,7 +59,14 @@ class JdSystemServerApplicationTests { @Test void hotelInitTest() throws Exception { - datasourceInitService.insertHotelData("西安"); +// try { +// for(int i = 33;i<500;i++){ + datasourceInitService.insertHotelData("100"); +// } +// } catch (Exception e) { +// throw new Exception(); +// } + } @Test @@ -124,7 +134,8 @@ class JdSystemServerApplicationTests { //地址逆编码 @Test void codeTest() throws Exception { - String address = BaiduMapUtil.getAddress("31.22932842411674","121.50989077799083"); + ArrayList locations = BaiduMapUtil.getLocations("成都市"); + String address = BaiduMapUtil.getAddress(locations.get(0).getLng(),locations.get(0).getLat()); System.out.println(address); } @@ -137,5 +148,24 @@ class JdSystemServerApplicationTests { } } + @Test + void userCity(){ + User user = userDao.selects(1L); + String s = BaiduMapUtil.getUserCity(user); + System.out.println(s); + } + + @Test + void hotelLocations(){ + String city = BaiduMapUtil.getUserCity(userDao.selects(1L)); + System.out.println(BaiduMapUtil.getLocations(city)); + System.out.println(BaiduMapUtil.getHotels(city)); + } + + @Test + void getAddr() throws Exception { + Locations addressNi = BaiduMapUtil.getAddressNi("四川省成都市高新区"); + System.out.println(addressNi); + } } diff --git a/src/test/java/com/suse/jd_system_server/redisTest.java b/src/test/java/com/suse/jd_system_server/redisTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2de62ef88ac09b8ba1b27b9aee51ade01eae7563 --- /dev/null +++ b/src/test/java/com/suse/jd_system_server/redisTest.java @@ -0,0 +1,41 @@ +package com.suse.jd_system_server; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.redis.core.StringRedisTemplate; + +@SpringBootTest +public class redisTest { + + @Autowired + private StringRedisTemplate stringRedisTemplate; + + @Test + void testString() { + // 写入一条String数据 + stringRedisTemplate.opsForValue().set("verify:phone:13600527634", "124143"); + // 获取string数据 +// Object name = stringRedisTemplate.opsForValue().get("name"); +// System.out.println("name = " + name); + } + + private static final ObjectMapper mapper = new ObjectMapper(); + + @Test + void testSaveUser() { + // 创建对象 +// User user = new User("虎哥", 21); + // 手动序列化 +// String json = mapper.writeValueAsString(user); + // 写入数据 +// stringRedisTemplate.opsForValue().set("user:200", json); + + // 获取数据 + String jsonUser = stringRedisTemplate.opsForValue().get("user:200"); + // 手动反序列化 +// User user1 = mapper.readValue(jsonUser, User.class); +// System.out.println("user1 = " + user1); + } +}