• 【无标题】


    作者主页:编程指南针

    作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

    主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

    文末获取源码 

    项目编号:BS-PT-063

    • 项目简介

        本项目基于SSM框架开发实现了一个旅游管理平台,主要包含管理员和前端用户两种身份。前端用户注册登陆后可以进行旅游景点和酒店信息的查看,在线评论,参与论坛讨论,并对个人信息和发表的贴子进行管理。管理员主要对基础数据进行管理,用户管理,旅游景点管理,酒店管理,评论管理,论坛管理等功能。

    二,环境介绍

    语言环境:Java:  jdk1.8

    数据库:Mysql: mysql5.7

    应用服务器:Tomcat:  tomcat8.5.31

    开发工具:IDEA或eclipse

    后台开发技术:SSM框架

    前端开发技术:Bootstrap+Ajax+Jquery

    三,系统展示

    前端页面展示:

     注册

    登陆

    评论与回复

    论坛功能

    后台用户登陆

    用户管理

    景点管理

    酒店管理

    论坛管理

    评论管理

    交通管理

    四,核心代码展示

    1. package cn.zm.trip.web.controller;
    2. import cn.zm.trip.web.commons.Msg;
    3. import cn.zm.trip.web.commons.TimeStampUtil;
    4. import cn.zm.trip.web.dao.*;
    5. import cn.zm.trip.web.domain.*;
    6. import cn.zm.trip.web.service.AdminService;
    7. import cn.zm.trip.web.service.UserService;
    8. import cn.zm.trip.web.service.ViewPointService;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.stereotype.Controller;
    11. import org.springframework.ui.Model;
    12. import org.springframework.web.bind.annotation.*;
    13. import javax.servlet.http.HttpServletRequest;
    14. import javax.servlet.http.HttpSession;
    15. import java.text.ParseException;
    16. import java.text.SimpleDateFormat;
    17. import java.util.Arrays;
    18. import java.util.Date;
    19. import java.util.List;
    20. @Controller
    21. @RequestMapping(value = "admin")
    22. public class AdminController {
    23. @Autowired
    24. private AdminService adminService;
    25. @Autowired
    26. private UserService userService;
    27. @Autowired
    28. private HttpSession session;
    29. @Autowired
    30. private ViewPointService viewPointService;
    31. @Autowired
    32. private HotelDao hotelDao;
    33. @Autowired
    34. private ViewPointDao viewPointDao;
    35. @Autowired
    36. private ForumDao forumDao;
    37. @Autowired
    38. private TrafficDao trafficDao;
    39. @Autowired
    40. private WordsDao wordsDao;
    41. @Autowired
    42. private ReplyDao replyDao;
    43. /**
    44. * **********login start***************
    45. * 从前端跳转到后台登录
    46. */
    47. @RequestMapping(value = "login", method = RequestMethod.GET)
    48. public String login() {
    49. return "admin/login";
    50. }
    51. /**
    52. * 登录逻辑
    53. * handle
    54. *
    55. * @param aemail 用户邮箱
    56. * @param apwd 密码
    57. * @return String
    58. */
    59. @RequestMapping(value = "login", method = RequestMethod.POST)
    60. // @RequestParam(required = true) 为true时意思为不可缺省
    61. public String login(String aemail, String apwd, HttpSession session) {
    62. Admin admin = adminService.login(aemail, apwd);
    63. String timestamp = TimeStampUtil.getTimeFormat();
    64. //登录失败
    65. if (admin == null) {
    66. session.setAttribute("msg", Msg.fail("邮箱或者密码错误!"));
    67. return login();
    68. }
    69. //登录成功
    70. else {
    71. // 将登录信息放入session
    72. session.setAttribute("msg", Msg.success());
    73. session.setAttribute("timestamp", timestamp);
    74. session.setAttribute("admin", admin);
    75. // 明日任务,获取域对象传送user信息
    76. return "redirect:main";
    77. }
    78. }
    79. /**
    80. * 后台注销
    81. */
    82. @RequestMapping(value = "loginout", method = RequestMethod.GET)
    83. public String loginOut(HttpSession session) {
    84. //销毁session
    85. session.invalidate();
    86. return login();
    87. }
    88. //**********login end***************
    89. /**
    90. * **********main start***************
    91. * 登录成功后跳转管理主界面
    92. *
    93. * @return
    94. */
    95. @RequestMapping(value = "main", method = RequestMethod.GET)
    96. public String main() {
    97. return "admin/main";
    98. }
    99. //**********main end***************
    100. /**********user start***************
    101. * 查看用户列表
    102. */
    103. @RequestMapping(value = "userlist", method = RequestMethod.GET)
    104. public String userList() {
    105. String prefix = "/static/upload/useravatar/";
    106. List users = userService.selectAll();
    107. for (User user : users) {
    108. String suffix = user.getUpic();
    109. user.setUpic(prefix + suffix);
    110. }
    111. session.setAttribute("users", users);
    112. return "admin/user_list";
    113. }
    114. /**
    115. * 用户模糊搜索
    116. */
    117. @RequestMapping(value = "usersearch", method = RequestMethod.GET)
    118. public String userSearch(String keyword, HttpSession session) {
    119. System.out.println(keyword);
    120. String prefix = "/static/upload/useravatar/";
    121. List users = userService.search(keyword);
    122. for (User user : users){
    123. String imgUrl = user.getUpic();
    124. user.setUpic(prefix + imgUrl);
    125. }
    126. session.setAttribute("users", users);
    127. session.setAttribute("msg", Msg.success("用户查询成功!"));
    128. return "admin/user_list";
    129. }
    130. /**
    131. * 景点模糊搜索
    132. */
    133. @RequestMapping(value = "viewPointSearch", method = RequestMethod.GET)
    134. public String viewPointSearch(String keyword, Model model) {
    135. String prefix = "/static/upload/viewavatar/";
    136. ViewPoint viewPoint = new ViewPoint();
    137. viewPoint.setTpVname(keyword);
    138. viewPoint.setTpVtype(keyword);
    139. viewPoint.setTpLocation(keyword);
    140. List viewPoints = viewPointDao.viewPointSearch(viewPoint);
    141. for (ViewPoint vp : viewPoints){
    142. String imgUrl = vp.getTpVpic();
    143. vp.setTpVpic(prefix + imgUrl);
    144. }
    145. model.addAttribute("viewPoints", viewPoints);
    146. model.addAttribute("msg", Msg.success("景点查询成功!"));
    147. return "admin/view_list";
    148. }
    149. /**
    150. * 后台酒店模糊搜索
    151. */
    152. @RequestMapping(value = "hotelPointSearch", method = RequestMethod.GET)
    153. public String hotelPointSearch(String keyword, Model model) {
    154. String prefix = "/static/upload/hotelAvatar/";
    155. Hotel hotel = new Hotel();
    156. hotel.setLocal(keyword);
    157. hotel.setHouseType(keyword);
    158. hotel.setBedType(keyword);
    159. List hotels = hotelDao.hotelPointSearch(hotel);
    160. for (Hotel hotelForEach : hotels){
    161. String imgUrl = hotelForEach.getImgUrl();
    162. hotelForEach.setImgUrl(prefix + imgUrl);
    163. }
    164. model.addAttribute("hotels", hotels);
    165. model.addAttribute("msg", Msg.success("酒店查询成功!"));
    166. return "admin/hotel_list";
    167. }
    168. /**
    169. * 后台论坛模糊搜索
    170. */
    171. @RequestMapping(value = "forumPointSearch", method = RequestMethod.GET)
    172. public String forumPointSearch(String keyword, Model model) {
    173. Forum forum = new Forum();
    174. forum.setTpTag(keyword);
    175. forum.setTpTitle(keyword);
    176. forum.setTpSubTitle(keyword);
    177. forum.setTpAuthor(keyword);
    178. List forums = forumDao.forumPointSearch(forum);
    179. model.addAttribute("forums", forums);
    180. model.addAttribute("msg", Msg.success("论坛查询成功!"));
    181. return "admin/forum_list";
    182. }
    183. /**
    184. * 后台交通列表模糊搜索
    185. */
    186. @RequestMapping(value = "trafficPointSearch", method = RequestMethod.GET)
    187. public String trafficPointSearch(String keyword, Model model) {
    188. Traffic traffic = new Traffic();
    189. traffic.setTpType(keyword);
    190. traffic.setTpCurrent(keyword);
    191. traffic.setTpDestination(keyword);
    192. List traffics = trafficDao.trafficPointSearch(traffic);
    193. model.addAttribute("traffics", traffics);
    194. model.addAttribute("msg", Msg.success("交通查询成功!"));
    195. return "admin/traffic_list";
    196. }
    197. /**
    198. * 用户单个单击删除
    199. */
    200. @RequestMapping(value = "userdelete", method = RequestMethod.GET)
    201. public String userDelete(String uid) {
    202. System.out.println(uid);
    203. String prefix = "/static/upload/useravatar/";
    204. userService.userDelete(uid);
    205. List users = userService.selectAll();
    206. for (User user : users){
    207. String imgUrl = user.getUpic();
    208. user.setUpic(prefix + imgUrl);
    209. }
    210. session.setAttribute("users", users);
    211. session.setAttribute("msg", Msg.success(uid + "号用户删除成功!"));
    212. return "admin/user_list";
    213. }
    214. /**
    215. * 用户新增表单跳转
    216. */
    217. @RequestMapping(value = "userform", method = RequestMethod.GET)
    218. public String userForm() {
    219. return "admin/user_form";
    220. }
    221. /**
    222. * 用户新增
    223. */
    224. @RequestMapping(value = "userinsert", method = RequestMethod.POST)
    225. public String userInsert(String uname, String uemail, String upwd) {
    226. userService.insertUser(uname, uemail, upwd);
    227. session.setAttribute("msg", Msg.success("新增用户成功"));
    228. return "redirect:userlist";
    229. }
    230. /**
    231. * 用户批量删除功能
    232. */
    233. @RequestMapping(value = "usersectiondelete", method = RequestMethod.GET)
    234. @ResponseBody//返回给前端
    235. public String userSectionDelete(String[] uids) {
    236. for (String uid : uids) {
    237. userService.userDelete(uid);
    238. }
    239. session.setAttribute("msg", Msg.success(Arrays.toString(uids) + "号用户批量删除成功!"));
    240. return "1";
    241. }
    242. /**
    243. * 跳转用户编辑更新界面
    244. */
    245. @RequestMapping(value = "useredit", method = RequestMethod.GET)
    246. public String userEdit(String uid) {
    247. User user = userService.userGet(uid);
    248. System.out.println(user);
    249. session.setAttribute("user", user);
    250. return "admin/user_edit";
    251. }
    252. /**
    253. * 跳转用户更新业务
    254. */
    255. @RequestMapping(value = "useredithandle", method = RequestMethod.POST)
    256. public String userEditHandle(User user) {
    257. userService.updataUserInfo(user);
    258. session.setAttribute("msg", Msg.success("用户信息保存成功!"));
    259. return "redirect:userlist";
    260. }
    261. //**********user start***************
    262. /************view start***************
    263. * 跳转内容管理 景点列表
    264. */
    265. @RequestMapping(value = "viewlist", method = RequestMethod.GET)
    266. public String viewPoint(ViewPointExample example, Model model, HttpServletRequest request) {
    267. example.setOrderByClause("tp_vid desc");
    268. String prefix = "/static/upload/viewavatar/";
    269. List viewPoints = viewPointService.selectByExample(example);
    270. for (ViewPoint viewPoint : viewPoints) {
    271. String suffix = viewPoint.getTpVpic();
    272. //前端img标签路径
    273. viewPoint.setTpVpic(prefix + suffix);
    274. }
    275. //存储信息转发
    276. model.addAttribute("viewPoints", viewPoints);
    277. return "admin/view_list";
    278. }
    279. /**
    280. * 用户批量删除功能
    281. */
    282. @RequestMapping(value = "viewsectiondelete", method = RequestMethod.GET)
    283. @ResponseBody//返回给前端
    284. public String viewSectionDelete(Integer[] tpVids) {
    285. for (Integer tpVid : tpVids) {
    286. viewPointService.deleteviews(tpVid);
    287. }
    288. session.setAttribute("msg", Msg.success(Arrays.toString(tpVids) + "号景点批量删除成功!"));
    289. return "1";
    290. }
    291. /**
    292. * 景点查看
    293. */
    294. @RequestMapping(value = "viewcontent", method = RequestMethod.GET)
    295. public String viewcontent(Integer tpVid, Model model) {
    296. ViewPoint viewPoint = viewPointService.selectByPrimaryKey(tpVid);
    297. String prefix = "/static/upload/viewavatar/";
    298. String suffix = viewPoint.getTpVpic();
    299. //前端img标签路径
    300. viewPoint.setTpVpic(prefix + suffix);
    301. model.addAttribute("viewPoint", viewPoint);
    302. return "admin/view_content";
    303. }
    304. /**
    305. * 用户单个单击删除
    306. */
    307. @RequestMapping(value = "viewdelete", method = RequestMethod.GET)
    308. public String viewDelete(Integer tpVid) {
    309. viewPointService.deleteviews(tpVid);
    310. session.setAttribute("msg", Msg.success(tpVid + "号用户删除成功!"));
    311. return "redirect:viewlist";
    312. }
    313. /**
    314. * 景点新增表单跳转
    315. */
    316. @RequestMapping(value = "viewform", method = RequestMethod.GET)
    317. public String viewForm() {
    318. return "admin/view_form";
    319. }
    320. /**
    321. * 景点新增
    322. */
    323. @RequestMapping(value = "viewinsert", method = RequestMethod.POST)
    324. public String viewInsert(ViewPoint viewPoint) {
    325. if (viewPoint.getTpVid() == null) {
    326. viewPointService.insertView(viewPoint);
    327. session.setAttribute("msg", Msg.success("新增景点成功!"));
    328. return "redirect:viewlist";
    329. }
    330. session.setAttribute("msg", Msg.fail("新增景点失败!"));
    331. return "redirect:viewlist";
    332. }
    333. /**
    334. * 跳转景点编辑更新界面
    335. */
    336. @RequestMapping(value = "viewedit", method = RequestMethod.GET)
    337. public String viewEdit(Integer tpVid, Model model) {
    338. ViewPoint viewPoint = viewPointService.selectByPrimaryKey(tpVid);
    339. model.addAttribute("viewPoint", viewPoint);
    340. return "admin/view_edit";
    341. }
    342. /**
    343. * 跳转景点更新业务
    344. */
    345. @RequestMapping(value = "viewedithandle", method = RequestMethod.POST)
    346. public String viewEditHandle(ViewPoint viewPoint) {
    347. viewPointService.updateByPrimaryKeySelective(viewPoint);
    348. session.setAttribute("msg", Msg.success("景点信息保存成功!"));
    349. return "redirect:viewlist";
    350. }
    351. //**********view end***************
    352. /*************hotel ************
    353. * 跳转
    354. * 酒店管理列表
    355. */
    356. @RequestMapping(value = "hotellist", method = RequestMethod.GET)
    357. public String hotelList(Model model) {
    358. HotelExample example = new HotelExample();
    359. String prefix = "/static/upload/hotelAvatar/";
    360. example.setOrderByClause("hid desc");
    361. List hotels = hotelDao.selectByExample(example);
    362. for (Hotel hotel : hotels) {
    363. String suffix = hotel.getImgUrl();
    364. //前端img标签路径
    365. hotel.setImgUrl(prefix + suffix);
    366. }
    367. model.addAttribute("hotels", hotels);
    368. return "admin/hotel_list";
    369. }
    370. /**
    371. * 跳转
    372. * 酒店管理列表
    373. */
    374. @RequestMapping(value = "hotelcontent", method = RequestMethod.GET)
    375. public String hotelContent(Integer hid, Model model) {
    376. Hotel hotel = hotelDao.selectByPrimaryKey(hid);
    377. String prefix = "/static/upload/hotelAvatar/";
    378. String suffix = hotel.getImgUrl();
    379. //前端img标签路径
    380. hotel.setImgUrl(prefix + suffix);
    381. model.addAttribute("hotel", hotel);
    382. return "admin/hotel_content";
    383. }
    384. /**
    385. * 跳转
    386. * 酒店编辑
    387. */
    388. @RequestMapping(value = "hoteledit", method = RequestMethod.GET)
    389. public String hotelEdit(Integer hid, Model model) {
    390. Hotel hotel = hotelDao.selectByPrimaryKey(hid);
    391. model.addAttribute("hotel", hotel);
    392. return "admin/hotel_edit";
    393. }
    394. /**
    395. * 跳转景点更新业务
    396. */
    397. @RequestMapping(value = "hoteledithandle", method = RequestMethod.POST)
    398. public String hotelEditHandle(Hotel hotel) {
    399. hotelDao.updateByPrimaryKeySelective(hotel);
    400. session.setAttribute("msg", Msg.success("酒店信息保存成功!"));
    401. return "redirect:hotellist";
    402. }
    403. /**
    404. * 跳转景点更新业务
    405. */
    406. @RequestMapping(value = "hoteldelete", method = RequestMethod.GET)
    407. public String hotelDelete(Integer hid) {
    408. hotelDao.deleteByPrimaryKey(hid);
    409. session.setAttribute("msg", Msg.success("删除酒店成功!"));
    410. return "redirect:hotellist";
    411. }
    412. /**
    413. * 酒店
    414. * 批量删除
    415. */
    416. @RequestMapping(value = "hotelMutiDelete", method = RequestMethod.GET)
    417. @ResponseBody//返回给前端
    418. public String hotelMutiDelete(Integer[] hids) {
    419. for (Integer hid : hids) {
    420. hotelDao.deleteByPrimaryKey(hid);
    421. }
    422. session.setAttribute("msg", Msg.success(Arrays.toString(hids) + "号景点批量删除成功!"));
    423. return "1";
    424. }
    425. /**
    426. * 酒店
    427. * 新增表单跳转
    428. */
    429. @RequestMapping(value = "hotelInsertForm", method = RequestMethod.GET)
    430. public String hotelInsertForm() {
    431. return "admin/hotel_insert";
    432. }
    433. /**
    434. * 酒店新增
    435. */
    436. @RequestMapping(value = "hotelInsert", method = RequestMethod.POST)
    437. public String hotelInsert(Hotel hotel, Model model) {
    438. if (hotel.getHid() == null) {
    439. hotelDao.insertSelective(hotel);
    440. model.addAttribute("msg", Msg.success("新增景点成功!"));
    441. return "redirect:hotellist";
    442. }
    443. model.addAttribute("msg", Msg.fail("新增景点失败!"));
    444. return "redirect:hoteledit";
    445. }
    446. /**
    447. * content
    448. */
    449. @RequestMapping(value = "forumList", method = RequestMethod.GET)
    450. public String forumList(Model model) {
    451. ForumExample example = new ForumExample();
    452. example.setOrderByClause("tp_fid desc");
    453. List forums = forumDao.selectByExample(example);
    454. model.addAttribute("forums", forums);
    455. return "admin/forum_list";
    456. }
    457. /**
    458. *
    459. * @param tpFids
    460. * @param model
    461. * @return
    462. */
    463. @ResponseBody//返回给前端
    464. @RequestMapping(value = "forumMutiDelete", method = RequestMethod.GET)
    465. public String forumMutiDelete(Integer[] tpFids, Model model) {
    466. for (Integer tpFid : tpFids) {
    467. forumDao.deleteByPrimaryKey(tpFid);
    468. }
    469. session.setAttribute("msg", Msg.success(Arrays.toString(tpFids) + "号批量删除成功!"));
    470. return "1";
    471. }
    472. /**
    473. * forummutidelete
    474. */
    475. @RequestMapping(value = "forumDelete", method = RequestMethod.GET)
    476. public String forumDelete(Integer tpFid, Model model) {
    477. forumDao.deleteByPrimaryKey(tpFid);
    478. model.addAttribute("msg", Msg.success(tpFid + "号批量删除成功!"));
    479. return "redirect:forumList";
    480. }
    481. /**
    482. * 酒店
    483. * 新增表单跳转
    484. */
    485. @RequestMapping(value = "forumInsertForm", method = RequestMethod.GET)
    486. public String forumInsertForm() {
    487. return "admin/forum_insert";
    488. }
    489. /**
    490. * 酒店新增
    491. */
    492. @RequestMapping(value = "forumInsert", method = RequestMethod.POST)
    493. public String forumInsert(Forum forum, Model model) {
    494. if (forum.getTpFid() == null) {
    495. forumDao.insert(forum);
    496. model.addAttribute("msg", Msg.success("新帖子成功!"));
    497. return "redirect:forumList";
    498. }
    499. model.addAttribute("msg", Msg.fail("新增帖子失败!"));
    500. return "redirect:forumList";
    501. }
    502. /**
    503. * 酒店新增
    504. */
    505. @RequestMapping(value = "forumEditForm", method = RequestMethod.GET)
    506. public String forumEditForm(Integer tpFid, Model model) {
    507. Forum forum = forumDao.selectByPrimaryKey(tpFid);
    508. model.addAttribute("forum", forum);
    509. return "admin/forum_edit";
    510. }
    511. /**
    512. * 景点新增
    513. */
    514. @RequestMapping(value = "forumEdit", method = RequestMethod.POST)
    515. public String forumEdit(Forum forum, Model model) {
    516. forumDao.updateByPrimaryKeySelective(forum);
    517. model.addAttribute("msg", Msg.success("更新成功!"));
    518. return "redirect:forumList";
    519. }
    520. /**Traffic**
    521. * 跳转交通列表页面
    522. */
    523. @RequestMapping(value = "trafficList", method = RequestMethod.GET)
    524. public String trafficList(Model model) {
    525. TrafficExample example = new TrafficExample();
    526. example.setOrderByClause("tp_Tid desc");
    527. List traffics = trafficDao.selectByExample(example);
    528. model.addAttribute("traffics", traffics);
    529. return "admin/traffic_list";
    530. }
    531. /**
    532. * 跳转交通新增页面
    533. * @return
    534. */
    535. @RequestMapping(value = "trafficInsert", method = RequestMethod.GET)
    536. public String trafficInsert() {
    537. return "admin/traffic_insert";
    538. }
    539. /**
    540. * 提交新增信息
    541. * @return
    542. */
    543. @RequestMapping(value = "trafficInsertHandler", method = RequestMethod.POST)
    544. public String trafficInsertHandler(Traffic traffic, String currentTime, String arriveTime, Model model) {
    545. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    546. try {
    547. // String parseCurrent = simpleDateFormat.format(currentTime);
    548. // String parseArriveTime = simpleDateFormat.format(arriveTime);
    549. // traffic.setTpCurrentTime(currentTime);
    550. // traffic.setTpArriveTime(arriveTime);
    551. } catch (Exception e) {
    552. e.printStackTrace();
    553. }
    554. trafficDao.insertSelective(traffic);
    555. model.addAttribute("msg",Msg.success("新增交通信息成功!"));
    556. return "redirect:trafficList";
    557. }
    558. /**
    559. * 交通删除
    560. * @return
    561. */
    562. @RequestMapping(value = "trafficDelete", method = RequestMethod.GET)
    563. public String trafficDelete(Integer tpTid, Model model) {
    564. trafficDao.deleteByPrimaryKey(tpTid);
    565. model.addAttribute("msg", Msg.success(tpTid + "号删除成功!"));
    566. return "redirect:trafficList";
    567. }
    568. /**
    569. * 批量删除
    570. * @return
    571. */
    572. @ResponseBody
    573. @RequestMapping(value = "trafficMutiDelete", method = RequestMethod.GET)
    574. public String trafficsMutiDelete(Integer[] tpTids, Model model) {
    575. for (Integer tpTid : tpTids){
    576. trafficDao.deleteByPrimaryKey(tpTid);
    577. }
    578. model.addAttribute("msg", Msg.success(Arrays.toString(tpTids) + "号删除成功!"));
    579. return "1";
    580. }
    581. /**
    582. * 跳转交通编辑页面
    583. * @return String
    584. */
    585. @RequestMapping(value = "trafficEdit", method = RequestMethod.GET)
    586. public String trafficEdit(Integer tpTid, Model model) {
    587. Traffic traffic = trafficDao.selectByPrimaryKey(tpTid);
    588. model.addAttribute("traffic", traffic);
    589. return "admin/traffic_edit";
    590. }
    591. /**
    592. * 交通编辑
    593. * @return
    594. */
    595. @RequestMapping(value = "trafficEditHandle", method = RequestMethod.POST)
    596. public String trafficEditHandle(Traffic traffic, String currentTime, String arriveTime, Model model) {
    597. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    598. try {
    599. // String parseCurrent = simpleDateFormat.format(currentTime);
    600. // String parseArriveTime = simpleDateFormat.format(arriveTime);
    601. traffic.setTpCurrentTime(currentTime);
    602. traffic.setTpArriveTime(arriveTime);
    603. } catch (Exception e) {
    604. e.printStackTrace();
    605. }
    606. trafficDao.updateByPrimaryKeySelective(traffic);
    607. model.addAttribute("msg",Msg.success("更新成功!"));
    608. return "redirect:trafficList";
    609. }
    610. /**
    611. * 跳转评论列表
    612. * @return
    613. */
    614. @RequestMapping(value = "wordsList", method = RequestMethod.GET)
    615. public String wordsList(Model model) {
    616. List byWords = viewPointService.findByWords();
    617. model.addAttribute("byWords", byWords);
    618. return "admin/words_list";
    619. }
    620. /**
    621. * 留言批量删除
    622. * @return
    623. */
    624. @ResponseBody
    625. @RequestMapping(value = "wordsMutiDelete", method = RequestMethod.GET)
    626. public String wordsMutiDelete(Integer[] lw_ids, Model model) {
    627. for (Integer lw_id : lw_ids){
    628. wordsDao.deleteByPrimaryKey(lw_id);
    629. }
    630. model.addAttribute("msg", Msg.success(Arrays.toString(lw_ids) + "号删除成功!"));
    631. return "1";
    632. }
    633. /**
    634. * 单击删除
    635. * @return
    636. */
    637. @RequestMapping(value = "wordsDelete", method = RequestMethod.GET)
    638. public String wordsDelete(Integer lw_id, Model model) {
    639. wordsDao.deleteByPrimaryKey(lw_id);
    640. model.addAttribute("msg", Msg.success(lw_id + "号删除成功!"));
    641. return "redirect:wordsList";
    642. }
    643. /**
    644. * 跳转回复列表
    645. * @return
    646. */
    647. @RequestMapping(value = "replyList", method = RequestMethod.GET)
    648. public String ReplyList(Model model) {
    649. List replys = viewPointService.findByReply();
    650. model.addAttribute("replys", replys);
    651. return "admin/reply_list";
    652. }
    653. /**
    654. * 回复批量删除
    655. * @return
    656. */
    657. @ResponseBody
    658. @RequestMapping(value = "replyMutiDelete", method = RequestMethod.GET)
    659. public String replyMutiDelete(Integer[] lr_ids, Model model) {
    660. for (Integer lr_id : lr_ids){
    661. replyDao.deleteByPrimaryKey(lr_id);
    662. }
    663. model.addAttribute("msg", Msg.success(Arrays.toString(lr_ids) + "号删除成功!"));
    664. return "1";
    665. }
    666. /**
    667. * 单击删除
    668. * @return
    669. */
    670. @RequestMapping(value = "replyDelete", method = RequestMethod.GET)
    671. public String replyDelete(Integer lr_id, Model model) {
    672. replyDao.deleteByPrimaryKey(lr_id);
    673. model.addAttribute("msg", Msg.success(lr_id + "号删除成功!"));
    674. return "redirect:replyList";
    675. }
    676. }

    1. package cn.zm.trip.web.controller;
    2. import cn.zm.trip.web.commons.Msg;
    3. import cn.zm.trip.web.dao.HotelDao;
    4. import cn.zm.trip.web.domain.*;
    5. import cn.zm.trip.web.service.ViewPointService;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.ui.Model;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.RequestMethod;
    11. import java.util.List;
    12. @Controller
    13. @RequestMapping(value = "hotel")
    14. public class HotelController {
    15. @Autowired
    16. private HotelDao hotelDao;
    17. @Autowired
    18. private ViewPointService viewPointService;
    19. /**
    20. * 跳转首页
    21. */
    22. @RequestMapping(value = "index", method = RequestMethod.GET)
    23. public String index(Model model) {
    24. //实例化hotel examle
    25. HotelExample example = new HotelExample();
    26. example.setOrderByClause("hid desc");
    27. String prefix = "/static/upload/hotelAvatar/";
    28. List hotels = hotelDao.selectByExample(example);
    29. for (Hotel hotel : hotels) {
    30. //图片名
    31. String suffix = hotel.getImgUrl();
    32. //全路径
    33. hotel.setImgUrl(prefix + suffix);
    34. }
    35. //传送景点
    36. model.addAttribute("hotels", hotels);
    37. return "proscenium/hotel/index";
    38. }
    39. /**
    40. * 跳转首页
    41. */
    42. @RequestMapping(value = "content", method = RequestMethod.GET)
    43. public String content(Integer hid, Model model) {
    44. //封装留言信息
    45. List lw_list = viewPointService.findByWords();
    46. model.addAttribute("lw_list",lw_list);
    47. //封装回复信息
    48. List lr_list = viewPointService.findByReply();
    49. model.addAttribute("lr_list",lr_list);
    50. Hotel hotel = hotelDao.selectByPrimaryKey(hid);
    51. model.addAttribute("hotel", hotel);
    52. return "proscenium/hotel/content";
    53. }
    54. /**
    55. * 钱台酒店模糊搜索
    56. */
    57. @RequestMapping(value = "hotelPointSearch", method = RequestMethod.GET)
    58. public String hotelPointSearch(String keyword, Model model) {
    59. String prefix = "/static/upload/hotelAvatar/";
    60. Hotel hotel = new Hotel();
    61. hotel.setLocal(keyword);
    62. hotel.setHouseType(keyword);
    63. hotel.setBedType(keyword);
    64. List hotels = hotelDao.hotelPointSearch(hotel);
    65. for (Hotel hotelForEach : hotels){
    66. String imgUrl = hotelForEach.getImgUrl();
    67. hotelForEach.setImgUrl(prefix + imgUrl);
    68. }
    69. model.addAttribute("hotels", hotels);
    70. model.addAttribute("msg", Msg.success("酒店查询成功!"));
    71. return "proscenium/hotel/index";
    72. }
    73. }

    五,项目总结

         本项目整体设计结构清晰,易于修改,适合做毕业设计或课程设计使用。

  • 相关阅读:
    3D数字孪生:从3D数据采集到3D内容分析
    【计算机网络】HTTP 重定向
    C++_pen_类
    LayUI-----动态选项卡
    计算机出现msvcr110.dll丢失是什么意思?七种方法解决msvcr110.dll丢失
    在windows操作系统上安装MariaDB
    vue2+elementUI,vue3+elementPlus解决form中的下拉列表回写显示id,不显示label
    【GAMES101】作业7 Path Tracing 关于Renderer::Render()中相机射线方向dir的疑惑&解答
    Latex数学符号查表
    本地离线模型搭建指南-中文大语言模型底座选择依据
  • 原文地址:https://blog.csdn.net/whirlwind526/article/details/126089466