• Java项目:SSM的KTV管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    主要功能包括:

    登陆页,房间信息,房间管理,开取房间,房间查询,会员管理,食物管理,查看订单,查询订单,查看房间消费使用情况等功能。

    由于本程序规模不大,可供课程设计,毕业设计学习演示之用

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

    5.数据库:MySql 5.7版本;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:HTML+CSS+JavaScript+jsp

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
    3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

    4. 运行项目,输入localhost:8080/ 登录

    运行截图

     

     

     

     

     

     

    代码相关

    首页管理控制器

    1. //定义为控制器
    2. @Controller
    3. // 设置路径
    4. @RequestMapping("/index")
    5. public class IndexAction extends BaseAction {
    6. @Autowired
    7. @Resource
    8. private UsersService usersService;
    9. @Autowired
    10. @Resource
    11. private ArticleService articleService;
    12. @Autowired
    13. @Resource
    14. private CateService cateService;
    15. @Autowired
    16. @Resource
    17. private CityService cityService;
    18. @Autowired
    19. @Resource
    20. private PeihuoService peihuoService;
    21. @Autowired
    22. @Resource
    23. private JiancaiService jiancaiService;
    24. @Autowired
    25. @Resource
    26. private CartService cartService;
    27. @Autowired
    28. @Resource
    29. private OrdersService ordersService;
    30. @Autowired
    31. @Resource
    32. private DetailsService detailsService;
    33. @Autowired
    34. @Resource
    35. private TopicService topicService;
    36. // 公共方法 提供公共查询数据
    37. private void front() {
    38. this.getRequest().setAttribute("title", "汽车维修预约系统");
    39. List cateList = this.cateService.getAllCate();
    40. this.getRequest().setAttribute("cateList", cateList);
    41. List hotList = this.jiancaiService.getJiancaiByHot();
    42. Collections.shuffle(hotList);
    43. this.getRequest().setAttribute("hotList", hotList);
    44. }
    45. // 首页显示
    46. @RequestMapping("index.action")
    47. public String index() {
    48. this.front();
    49. List cateList = this.cateService.getCateFront();
    50. List frontList = new ArrayList();
    51. for (Cate cate : cateList) {
    52. List flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
    53. cate.setFlimList(flimList);
    54. frontList.add(cate);
    55. }
    56. this.getRequest().setAttribute("frontList", frontList);
    57. return "users/index";
    58. }
    59. // 首页显示
    60. @RequestMapping("network.action")
    61. public String network() {
    62. this.front();
    63. List cateList = this.cateService.getCateFront();
    64. List frontList = new ArrayList();
    65. for (Cate cate : cateList) {
    66. List flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
    67. cate.setFlimList(flimList);
    68. frontList.add(cate);
    69. }
    70. this.getRequest().setAttribute("frontList", frontList);
    71. return "users/network";
    72. }
    73. // 公告
    74. @RequestMapping("article.action")
    75. public String article(String number) {
    76. this.front();
    77. List
      articleList = new ArrayList
      ();
    78. List
      tempList = this.articleService.getAllArticle();
    79. int pageNumber = tempList.size();
    80. int maxPage = pageNumber;
    81. if (maxPage % 12 == 0) {
    82. maxPage = maxPage / 12;
    83. } else {
    84. maxPage = maxPage / 12 + 1;
    85. }
    86. if (number == null) {
    87. number = "0";
    88. }
    89. int start = Integer.parseInt(number) * 12;
    90. int over = (Integer.parseInt(number) + 1) * 12;
    91. int count = pageNumber - over;
    92. if (count <= 0) {
    93. over = pageNumber;
    94. }
    95. for (int i = start; i < over; i++) {
    96. Article x = tempList.get(i);
    97. articleList.add(x);
    98. }
    99. String html = "";
    100. StringBuffer buffer = new StringBuffer();
    101. buffer.append("  共为");
    102. buffer.append(maxPage);
    103. buffer.append("页  共有");
    104. buffer.append(pageNumber);
    105. buffer.append("条  当前为第");
    106. buffer.append((Integer.parseInt(number) + 1));
    107. buffer.append("页  ");
    108. if ((Integer.parseInt(number) + 1) == 1) {
    109. buffer.append("首页");
    110. } else {
    111. buffer.append("首页");
    112. }
    113. buffer.append("  ");
    114. if ((Integer.parseInt(number) + 1) == 1) {
    115. buffer.append("上一页");
    116. } else {
    117. }
    118. buffer.append("  ");
    119. if (maxPage <= (Integer.parseInt(number) + 1)) {
    120. buffer.append("下一页");
    121. } else {
    122. }
    123. buffer.append("  ");
    124. if (maxPage <= (Integer.parseInt(number) + 1)) {
    125. buffer.append("尾页");
    126. } else {
    127. }
    128. html = buffer.toString();
    129. this.getRequest().setAttribute("html", html);
    130. this.getRequest().setAttribute("articleList", articleList);
    131. return "users/article";
    132. }
    133. // 阅读公告
    134. @RequestMapping("read.action")
    135. public String read(String id) {
    136. this.front();
    137. Article article = this.articleService.getArticleById(id);
    138. article.setHits("" + (Integer.parseInt(article.getHits()) + 1));
    139. this.articleService.updateArticle(article);
    140. this.getRequest().setAttribute("article", article);
    141. return "users/read";
    142. }
    143. // 准备登录
    144. @RequestMapping("preLogin.action")
    145. public String prelogin() {
    146. this.front();
    147. return "users/login";
    148. }
    149. // 用户登录
    150. @RequestMapping("login.action")
    151. public String login() {
    152. this.front();
    153. String username = this.getRequest().getParameter("username");
    154. String password = this.getRequest().getParameter("password");
    155. Users u = new Users();
    156. u.setUsername(username);
    157. List usersList = this.usersService.getUsersByCond(u);
    158. if (usersList.size() == 0) {
    159. this.getSession().setAttribute("message", "用户名不存在");
    160. return "redirect:/index/preLogin.action";
    161. } else {
    162. Users users = usersList.get(0);
    163. if (password.equals(users.getPassword())) {
    164. this.getSession().setAttribute("userid", users.getUsersid());
    165. this.getSession().setAttribute("username", users.getUsername());
    166. this.getSession().setAttribute("users", users);
    167. return "redirect:/index/index.action";
    168. } else {
    169. this.getSession().setAttribute("message", "密码错误");
    170. return "redirect:/index/preLogin.action";
    171. }
    172. }
    173. }
    174. // 准备注册
    175. @RequestMapping("preReg.action")
    176. public String preReg() {
    177. this.front();
    178. return "users/register";
    179. }
    180. // 用户注册
    181. @RequestMapping("register.action")
    182. public String register(Users users) {
    183. this.front();
    184. Users u = new Users();
    185. u.setUsername(users.getUsername());
    186. List usersList = this.usersService.getUsersByCond(u);
    187. if (usersList.size() == 0) {
    188. users.setRegdate(VeDate.getStringDateShort());
    189. this.usersService.insertUsers(users);
    190. } else {
    191. this.getSession().setAttribute("message", "用户名已存在");
    192. return "redirect:/index/preReg.action";
    193. }
    194. return "redirect:/index/preLogin.action";
    195. }
    196. // 退出登录
    197. @RequestMapping("exit.action")
    198. public String exit() {
    199. this.front();
    200. this.getSession().removeAttribute("userid");
    201. this.getSession().removeAttribute("username");
    202. this.getSession().removeAttribute("users");
    203. return "index";
    204. }
    205. // 准备修改密码
    206. @RequestMapping("prePwd.action")
    207. public String prePwd() {
    208. this.front();
    209. if (this.getSession().getAttribute("userid") == null) {
    210. return "redirect:/index/preLogin.action";
    211. }
    212. return "users/editpwd";
    213. }
    214. // 修改密码
    215. @RequestMapping("editpwd.action")
    216. public String editpwd() {
    217. this.front();
    218. if (this.getSession().getAttribute("userid") == null) {
    219. return "redirect:/index/preLogin.action";
    220. }
    221. String userid = (String) this.getSession().getAttribute("userid");
    222. String password = this.getRequest().getParameter("password");
    223. String repassword = this.getRequest().getParameter("repassword");
    224. Users users = this.usersService.getUsersById(userid);
    225. if (password.equals(users.getPassword())) {
    226. users.setPassword(repassword);
    227. this.usersService.updateUsers(users);
    228. } else {
    229. this.getSession().setAttribute("message", "旧密码错误");
    230. return "redirect:/index/prePwd.action";
    231. }
    232. return "redirect:/index/prePwd.action";
    233. }
    234. @RequestMapping("usercenter.action")
    235. public String usercenter() {
    236. this.front();
    237. if (this.getSession().getAttribute("userid") == null) {
    238. return "redirect:/index/preLogin.action";
    239. }
    240. return "users/usercenter";
    241. }
    242. @RequestMapping("userinfo.action")
    243. public String userinfo() {
    244. this.front();
    245. if (this.getSession().getAttribute("userid") == null) {
    246. return "redirect:/index/preLogin.action";
    247. }
    248. String userid = (String) this.getSession().getAttribute("userid");
    249. this.getSession().setAttribute("users", this.usersService.getUsersById(userid));
    250. return "users/userinfo";
    251. }
    252. @RequestMapping("personal.action")
    253. public String personal(Users users) {
    254. this.front();
    255. if (this.getSession().getAttribute("userid") == null) {
    256. return "redirect:/index/preLogin.action";
    257. }
    258. this.usersService.updateUsers(users);
    259. return "redirect:/index/userinfo.action";
    260. }
    261. // 添加产品到购物车
    262. @RequestMapping("addcart.action")
    263. public String addcart() {
    264. this.front();
    265. if (this.getSession().getAttribute("userid") == null) {
    266. return "redirect:/index/preLogin.action";
    267. }
    268. String userid = (String) this.getSession().getAttribute("userid");
    269. Cart cart = new Cart();
    270. cart.setJiancaiid(getRequest().getParameter("goodsid"));
    271. cart.setNum(getRequest().getParameter("num"));
    272. cart.setPrice(getRequest().getParameter("price"));
    273. cart.setUsersid(userid);
    274. this.cartService.insertCart(cart);
    275. return "redirect:/index/cart.action";
    276. }
    277. // 查看购物车
    278. @RequestMapping("cart.action")
    279. public String cart() {
    280. this.front();
    281. if (this.getSession().getAttribute("userid") == null) {
    282. return "redirect:/index/preLogin.action";
    283. }
    284. String userid = (String) this.getSession().getAttribute("userid");
    285. Cart cart = new Cart();
    286. cart.setUsersid(userid);
    287. List cartList = this.cartService.getCartByCond(cart);
    288. this.getRequest().setAttribute("cartList", cartList);
    289. return "users/cart";
    290. }
    291. // 删除购物车中的产品
    292. @RequestMapping("deletecart.action")
    293. public String deletecart(String id) {
    294. this.front();
    295. if (this.getSession().getAttribute("userid") == null) {
    296. return "redirect:/index/preLogin.action";
    297. }
    298. this.cartService.deleteCart(id);
    299. return "redirect:/index/cart.action";
    300. }
    301. // 准备结算
    302. @RequestMapping("preCheckout.action")
    303. public String preCheckout() {
    304. this.front();
    305. if (this.getSession().getAttribute("userid") == null) {
    306. return "redirect:/index/preLogin.action";
    307. }
    308. String userid = (String) this.getSession().getAttribute("userid");
    309. Cart cart = new Cart();
    310. cart.setUsersid(userid);
    311. List cartList = this.cartService.getCartByCond(cart);
    312. if (cartList.size() == 0) {
    313. this.getRequest().setAttribute("message", "请选购配件");
    314. return "redirect:/index/cart.action";
    315. }
    316. List cityList = this.cityService.getAllCity();
    317. this.getRequest().setAttribute("cityList", cityList);
    318. return "users/checkout";
    319. }
    320. // 结算
    321. @RequestMapping("checkout.action")
    322. public String checkout() {
    323. this.front();
    324. if (this.getSession().getAttribute("userid") == null) {
    325. return "redirect:/index/preLogin.action";
    326. }
    327. String userid = (String) this.getSession().getAttribute("userid");
    328. Cart cart1 = new Cart();
    329. cart1.setUsersid(userid);
    330. List cartList = this.cartService.getCartByCond(cart1);
    331. if (cartList.size() == 0) {
    332. this.getRequest().setAttribute("message", "请选购配件");
    333. return "redirect:/index/cart.action";
    334. } else {
    335. // 获取一个1200-9999的随机数 防止同时提交
    336. String ordercode = "PD" + VeDate.getStringDatex();
    337. double total = 0;
    338. for (Cart cart : cartList) {
    339. Details details = new Details();
    340. details.setDetailsid(VeDate.getStringDatex() + (Math.random() * 9 + 1) * 1200);
    341. details.setJiancaiid(cart.getJiancaiid());
    342. details.setNum(cart.getNum());
    343. details.setOrdercode(ordercode);
    344. details.setPrice(cart.getPrice());
    345. details.setPeihuoid(this.getRequest().getParameter("peihuoid"));
    346. details.setCityid(this.getRequest().getParameter("cityid"));
    347. details.setViewdate(this.getRequest().getParameter("viewdate"));
    348. this.detailsService.insertDetails(details);
    349. Jiancai goods = this.jiancaiService.getJiancaiById(cart.getJiancaiid());
    350. goods.setSellnum("" + (Integer.parseInt(goods.getSellnum()) + Integer.parseInt(cart.getNum())));
    351. this.jiancaiService.updateJiancai(goods);
    352. total += Double.parseDouble(cart.getPrice()) * Double.parseDouble(cart.getNum());
    353. this.cartService.deleteCart(cart.getCartid());
    354. }
    355. Orders orders = new Orders();
    356. orders.setAddtime(VeDate.getStringDateShort());
    357. orders.setOrdercode(ordercode);
    358. orders.setStatus("未付款");
    359. orders.setTotal("" + total);
    360. orders.setUsersid(userid);
    361. this.ordersService.insertOrders(orders);
    362. }
    363. return "redirect:/index/showOrders.action";
    364. }
    365. // 查看订购
    366. @RequestMapping("showOrders.action")
    367. public String showOrders(String number) {
    368. this.front();
    369. if (this.getSession().getAttribute("userid") == null) {
    370. return "redirect:/index/preLogin.action";
    371. }
    372. String userid = (String) this.getSession().getAttribute("userid");
    373. Orders orders = new Orders();
    374. orders.setUsersid(userid);
    375. List ordersList = new ArrayList();
    376. List tempList = this.ordersService.getOrdersByCond(orders);
    377. int pageNumber = tempList.size();
    378. int maxPage = pageNumber;
    379. if (maxPage % 12 == 0) {
    380. maxPage = maxPage / 12;
    381. } else {
    382. maxPage = maxPage / 12 + 1;
    383. }
    384. if (number == null) {
    385. number = "0";
    386. }
    387. int start = Integer.parseInt(number) * 12;
    388. int over = (Integer.parseInt(number) + 1) * 12;
    389. int count = pageNumber - over;
    390. if (count <= 0) {
    391. over = pageNumber;
    392. }
    393. for (int i = start; i < over; i++) {
    394. Orders o = tempList.get(i);
    395. ordersList.add(o);
    396. }
    397. String html = "";
    398. StringBuffer buffer = new StringBuffer();
    399. buffer.append("  共为");
    400. buffer.append(maxPage);
    401. buffer.append("页  共有");
    402. buffer.append(pageNumber);
    403. buffer.append("条  当前为第");
    404. buffer.append((Integer.parseInt(number) + 1));
    405. buffer.append("页  ");
    406. if ((Integer.parseInt(number) + 1) == 1) {
    407. buffer.append("首页");
    408. } else {
    409. buffer.append("首页");
    410. }
    411. buffer.append("  ");
    412. if ((Integer.parseInt(number) + 1) == 1) {
    413. buffer.append("上一页");
    414. } else {
    415. }
    416. buffer.append("  ");
    417. if (maxPage <= (Integer.parseInt(number) + 1)) {
    418. buffer.append("下一页");
    419. } else {
    420. }
    421. buffer.append("  ");
    422. if (maxPage <= (Integer.parseInt(number) + 1)) {
    423. buffer.append("尾页");
    424. } else {
    425. }
    426. html = buffer.toString();
    427. this.getRequest().setAttribute("html", html);
    428. this.getRequest().setAttribute("ordersList", ordersList);
    429. return "users/orderlist";
    430. }
    431. // 准备付款
    432. @RequestMapping("prePay.action")
    433. public String prePay(String id) {
    434. this.front();
    435. if (this.getSession().getAttribute("userid") == null) {
    436. return "redirect:/index/preLogin.action";
    437. }
    438. this.getRequest().setAttribute("id", id);
    439. return "users/pay";
    440. }
    441. // 付款
    442. @RequestMapping("pay.action")
    443. public String pay(String id) {
    444. this.front();
    445. if (this.getSession().getAttribute("userid") == null) {
    446. return "redirect:/index/preLogin.action";
    447. }
    448. Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
    449. orders.setStatus("已付款");
    450. this.ordersService.updateOrders(orders);
    451. return "redirect:/index/showOrders.action";
    452. }
    453. // 确认收货
    454. @RequestMapping("over.action")
    455. public String over(String id) {
    456. this.front();
    457. if (this.getSession().getAttribute("userid") == null) {
    458. return "redirect:/index/preLogin.action";
    459. }
    460. Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
    461. orders.setStatus("已收货");
    462. this.ordersService.updateOrders(orders);
    463. return "redirect:/index/showOrders.action";
    464. }
    465. // 取消订单
    466. @RequestMapping("cancel.action")
    467. public String cancel(String id) {
    468. this.front();
    469. if (this.getSession().getAttribute("userid") == null) {
    470. return "redirect:/index/preLogin.action";
    471. }
    472. Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
    473. orders.setStatus("已取消");
    474. this.ordersService.updateOrders(orders);
    475. return "redirect:/index/showOrders.action";
    476. }
    477. // 订单明细
    478. @RequestMapping("orderdetail.action")
    479. public String orderdetail(String id) {
    480. this.front();
    481. if (this.getSession().getAttribute("userid") == null) {
    482. return "redirect:/index/preLogin.action";
    483. }
    484. Details details = new Details();
    485. details.setOrdercode(id);
    486. List
      detailsList = this.detailsService.getDetailsByCond(details);
    487. this.getRequest().setAttribute("detailsList", detailsList);
    488. return "users/orderdetail";
    489. }
    490. // 按分类查询
    491. @RequestMapping("cate.action")
    492. public String cate(String id, String number) {
    493. this.front();
    494. Jiancai goods = new Jiancai();
    495. goods.setCateid(id);
    496. List flimList = new ArrayList();
    497. List tempList = this.jiancaiService.getJiancaiByCond(goods);
    498. int pageNumber = tempList.size();
    499. int maxPage = pageNumber;
    500. if (maxPage % 12 == 0) {
    501. maxPage = maxPage / 12;
    502. } else {
    503. maxPage = maxPage / 12 + 1;
    504. }
    505. if (number == null) {
    506. number = "0";
    507. }
    508. int start = Integer.parseInt(number) * 12;
    509. int over = (Integer.parseInt(number) + 1) * 12;
    510. int count = pageNumber - over;
    511. if (count <= 0) {
    512. over = pageNumber;
    513. }
    514. for (int i = start; i < over; i++) {
    515. Jiancai x = tempList.get(i);
    516. flimList.add(x);
    517. }
    518. String html = "";
    519. StringBuffer buffer = new StringBuffer();
    520. buffer.append("  共为");
    521. buffer.append(maxPage);
    522. buffer.append("页  共有");
    523. buffer.append(pageNumber);
    524. buffer.append("条  当前为第");
    525. buffer.append((Integer.parseInt(number) + 1));
    526. buffer.append("页  ");
    527. if ((Integer.parseInt(number) + 1) == 1) {
    528. buffer.append("首页");
    529. } else {
    530. buffer.append("首页");
    531. }
    532. buffer.append("  ");
    533. if ((Integer.parseInt(number) + 1) == 1) {
    534. buffer.append("上一页");
    535. } else {
    536. }
    537. buffer.append("  ");
    538. if (maxPage <= (Integer.parseInt(number) + 1)) {
    539. buffer.append("下一页");
    540. } else {
    541. }
    542. buffer.append("  ");
    543. if (maxPage <= (Integer.parseInt(number) + 1)) {
    544. buffer.append("尾页");
    545. } else {
    546. }
    547. html = buffer.toString();
    548. this.getRequest().setAttribute("html", html);
    549. this.getRequest().setAttribute("flimList", flimList);
    550. return "users/list";
    551. }
    552. // 推荐产品
    553. @RequestMapping("recommend.action")
    554. public String recommend(String number) {
    555. this.front();
    556. Jiancai goods = new Jiancai();
    557. goods.setRecommend("是");
    558. List flimList = new ArrayList();
    559. List tempList = this.jiancaiService.getJiancaiByCond(goods);
    560. int pageNumber = tempList.size();
    561. int maxPage = pageNumber;
    562. if (maxPage % 12 == 0) {
    563. maxPage = maxPage / 12;
    564. } else {
    565. maxPage = maxPage / 12 + 1;
    566. }
    567. if (number == null) {
    568. number = "0";
    569. }
    570. int start = Integer.parseInt(number) * 12;
    571. int over = (Integer.parseInt(number) + 1) * 12;
    572. int count = pageNumber - over;
    573. if (count <= 0) {
    574. over = pageNumber;
    575. }
    576. for (int i = start; i < over; i++) {
    577. Jiancai x = tempList.get(i);
    578. flimList.add(x);
    579. }
    580. String html = "";
    581. StringBuffer buffer = new StringBuffer();
    582. buffer.append("  共为");
    583. buffer.append(maxPage);
    584. buffer.append("页  共有");
    585. buffer.append(pageNumber);
    586. buffer.append("条  当前为第");
    587. buffer.append((Integer.parseInt(number) + 1));
    588. buffer.append("页  ");
    589. if ((Integer.parseInt(number) + 1) == 1) {
    590. buffer.append("首页");
    591. } else {
    592. buffer.append("首页");
    593. }
    594. buffer.append("  ");
    595. if ((Integer.parseInt(number) + 1) == 1) {
    596. buffer.append("上一页");
    597. } else {
    598. }
    599. buffer.append("  ");
    600. if (maxPage <= (Integer.parseInt(number) + 1)) {
    601. buffer.append("下一页");
    602. } else {
    603. }
    604. buffer.append("  ");
    605. if (maxPage <= (Integer.parseInt(number) + 1)) {
    606. buffer.append("尾页");
    607. } else {
    608. }
    609. html = buffer.toString();
    610. this.getRequest().setAttribute("html", html);
    611. this.getRequest().setAttribute("flimList", flimList);
    612. return "users/list";
    613. }
    614. // 推荐产品
    615. @RequestMapping("hot.action")
    616. public String getHost(String number) {
    617. this.front();
    618. Jiancai goods = new Jiancai();
    619. goods.setRecommend("是");
    620. List flimList = new ArrayList();
    621. List tempList = this.jiancaiService.getJiancaiByHot();
    622. int pageNumber = tempList.size();
    623. int maxPage = pageNumber;
    624. if (maxPage % 12 == 0) {
    625. maxPage = maxPage / 12;
    626. } else {
    627. maxPage = maxPage / 12 + 1;
    628. }
    629. if (number == null) {
    630. number = "0";
    631. }
    632. int start = Integer.parseInt(number) * 12;
    633. int over = (Integer.parseInt(number) + 1) * 12;
    634. int count = pageNumber - over;
    635. if (count <= 0) {
    636. over = pageNumber;
    637. }
    638. for (int i = start; i < over; i++) {
    639. Jiancai x = tempList.get(i);
    640. flimList.add(x);
    641. }
    642. String html = "";
    643. StringBuffer buffer = new StringBuffer();
    644. buffer.append("  共为");
    645. buffer.append(maxPage);
    646. buffer.append("页  共有");
    647. buffer.append(pageNumber);
    648. buffer.append("条  当前为第");
    649. buffer.append((Integer.parseInt(number) + 1));
    650. buffer.append("页  ");
    651. if ((Integer.parseInt(number) + 1) == 1) {
    652. buffer.append("首页");
    653. } else {
    654. buffer.append("首页");
    655. }
    656. buffer.append("  ");
    657. if ((Integer.parseInt(number) + 1) == 1) {
    658. buffer.append("上一页");
    659. } else {
    660. }
    661. buffer.append("  ");
    662. if (maxPage <= (Integer.parseInt(number) + 1)) {
    663. buffer.append("下一页");
    664. } else {
    665. }
    666. buffer.append("  ");
    667. if (maxPage <= (Integer.parseInt(number) + 1)) {
    668. buffer.append("尾页");
    669. } else {
    670. }
    671. html = buffer.toString();
    672. this.getRequest().setAttribute("html", html);
    673. this.getRequest().setAttribute("flimList", flimList);
    674. return "users/list";
    675. }
    676. // 全部产品
    677. @RequestMapping("all.action")
    678. public String all(String number) {
    679. this.front();
    680. List flimList = new ArrayList();
    681. List tempList = this.jiancaiService.getAllJiancai();
    682. int pageNumber = tempList.size();
    683. int maxPage = pageNumber;
    684. if (maxPage % 12 == 0) {
    685. maxPage = maxPage / 12;
    686. } else {
    687. maxPage = maxPage / 12 + 1;
    688. }
    689. if (number == null) {
    690. number = "0";
    691. }
    692. int start = Integer.parseInt(number) * 12;
    693. int over = (Integer.parseInt(number) + 1) * 12;
    694. int count = pageNumber - over;
    695. if (count <= 0) {
    696. over = pageNumber;
    697. }
    698. for (int i = start; i < over; i++) {
    699. Jiancai x = tempList.get(i);
    700. flimList.add(x);
    701. }
    702. String html = "";
    703. StringBuffer buffer = new StringBuffer();
    704. buffer.append("  共为");
    705. buffer.append(maxPage);
    706. buffer.append("页  共有");
    707. buffer.append(pageNumber);
    708. buffer.append("条  当前为第");
    709. buffer.append((Integer.parseInt(number) + 1));
    710. buffer.append("页  ");
    711. if ((Integer.parseInt(number) + 1) == 1) {
    712. buffer.append("首页");
    713. } else {
    714. buffer.append("首页");
    715. }
    716. buffer.append("  ");
    717. if ((Integer.parseInt(number) + 1) == 1) {
    718. buffer.append("上一页");
    719. } else {
    720. }
    721. buffer.append("  ");
    722. if (maxPage <= (Integer.parseInt(number) + 1)) {
    723. buffer.append("下一页");
    724. } else {
    725. }
    726. buffer.append("  ");
    727. if (maxPage <= (Integer.parseInt(number) + 1)) {
    728. buffer.append("尾页");
    729. } else {
    730. }
    731. html = buffer.toString();
    732. this.getRequest().setAttribute("html", html);
    733. this.getRequest().setAttribute("flimList", flimList);
    734. return "users/list";
    735. }
    736. // 查询配件
    737. @RequestMapping("query.action")
    738. public String query(String name) {
    739. this.front();
    740. Jiancai goods = new Jiancai();
    741. goods.setJiancainame(name);
    742. List flimList = this.jiancaiService.getJiancaiByLike(goods);
    743. this.getRequest().setAttribute("flimList", flimList);
    744. return "users/list";
    745. }
    746. // 配件详情
    747. @RequestMapping("detail.action")
    748. public String detail(String id) {
    749. this.front();
    750. Jiancai goods = this.jiancaiService.getJiancaiById(id);
    751. goods.setHits("" + (Integer.parseInt(goods.getHits()) + 1));
    752. this.jiancaiService.updateJiancai(goods);
    753. this.getRequest().setAttribute("goods", goods);
    754. if (this.getSession().getAttribute("userid") == null) {
    755. return "redirect:/index/preLogin.action";
    756. }
    757. String userid = (String) this.getSession().getAttribute("userid");
    758. Topic topic = new Topic();
    759. topic.setJiancaiid(id);
    760. List topicList = this.topicService.getTopicByCond(topic);
    761. this.getRequest().setAttribute("topicList", topicList);
    762. this.getRequest().setAttribute("tnum", topicList.size());
    763. return "users/detail";
    764. }
    765. @RequestMapping("addTopic.action")
    766. public String addTopic(Topic topic) {
    767. this.front();
    768. if (this.getSession().getAttribute("userid") == null) {
    769. return "redirect:/index/preLogin.action";
    770. }
    771. String userid = (String) this.getSession().getAttribute("userid");
    772. topic.setAddtime(VeDate.getStringDateShort());
    773. topic.setContents(this.getRequest().getParameter("contents"));
    774. topic.setJiancaiid(this.getRequest().getParameter("goodsid"));
    775. topic.setNum(this.getRequest().getParameter("num"));
    776. topic.setUsersid(userid);
    777. this.topicService.insertTopic(topic);
    778. return "redirect:/index/detail.action?id=" + topic.getJiancaiid();
    779. }
    780. }

     订单管理控制器

    1. //定义为控制器
    2. @Controller
    3. // 设置路径
    4. @RequestMapping(value = "/orders" , produces = "text/plain;charset=utf-8")
    5. public class OrdersAction extends BaseAction {
    6. // 注入Service 由于标签的存在 所以不需要getter setter
    7. @Autowired
    8. @Resource
    9. private OrdersService ordersService;
    10. @Autowired
    11. @Resource
    12. private UsersService usersService;
    13. // 准备添加数据
    14. @RequestMapping("createOrders.action")
    15. public String createOrders() {
    16. List usersList = this.usersService.getAllUsers();
    17. this.getRequest().setAttribute("usersList", usersList);
    18. return "admin/addorders";
    19. }
    20. // 添加数据
    21. @RequestMapping("addOrders.action")
    22. public String addOrders(Orders orders) {
    23. this.ordersService.insertOrders(orders);
    24. return "redirect:/orders/createOrders.action";
    25. }
    26. // 通过主键删除数据
    27. @RequestMapping("deleteOrders.action")
    28. public String deleteOrders(String id) {
    29. this.ordersService.deleteOrders(id);
    30. return "redirect:/orders/getAllOrders.action";
    31. }
    32. // 批量删除数据
    33. @RequestMapping("deleteOrdersByIds.action")
    34. public String deleteOrdersByIds() {
    35. String[] ids = this.getRequest().getParameterValues("ordersid");
    36. for (String ordersid : ids) {
    37. this.ordersService.deleteOrders(ordersid);
    38. }
    39. return "redirect:/orders/getAllOrders.action";
    40. }
    41. // 更新数据
    42. @RequestMapping("updateOrders.action")
    43. public String updateOrders(Orders orders) {
    44. this.ordersService.updateOrders(orders);
    45. return "redirect:/orders/getAllOrders.action";
    46. }
    47. // 显示全部数据
    48. @RequestMapping("getAllOrders.action")
    49. public String getAllOrders(String number) {
    50. List ordersList = this.ordersService.getAllOrders();
    51. PageHelper.getPage(ordersList, "orders", null, null, 10, number, this.getRequest(), null);
    52. return "admin/listorders";
    53. }
    54. // 按条件查询数据 (模糊查询)
    55. @RequestMapping("queryOrdersByCond.action")
    56. public String queryOrdersByCond(String cond, String name, String number) {
    57. Orders orders = new Orders();
    58. if(cond != null){
    59. if ("ordercode".equals(cond)) {
    60. orders.setOrdercode(name);
    61. }
    62. if ("username".equals(cond)) {
    63. orders.setUsername(name);
    64. }
    65. if ("total".equals(cond)) {
    66. orders.setTotal(name);
    67. }
    68. if ("status".equals(cond)) {
    69. orders.setStatus(name);
    70. }
    71. if ("addtime".equals(cond)) {
    72. orders.setAddtime(name);
    73. }
    74. }
    75. List nameList = new ArrayList();
    76. List valueList = new ArrayList();
    77. nameList.add(cond);
    78. valueList.add(name);
    79. PageHelper.getPage(this.ordersService.getOrdersByLike(orders), "orders", nameList, valueList, 10, number, this.getRequest(), "query");
    80. name = null;
    81. cond = null;
    82. return "admin/queryorders";
    83. }
    84. // 按主键查询数据
    85. @RequestMapping("getOrdersById.action")
    86. public String getOrdersById(String id ) {
    87. Orders orders = this.ordersService.getOrdersById(id);
    88. this.getRequest().setAttribute("orders", orders);
    89. List usersList = this.usersService.getAllUsers();
    90. this.getRequest().setAttribute("usersList", usersList);
    91. return "admin/editorders";
    92. }
    93. public OrdersService getOrdersService() { return ordersService; }
    94. public void setOrdersService(OrdersService ordersService) { this.ordersService = ordersService; }
    95. }

    如果也想学习本系统,下面领取。关注并回复:070ssm 

  • 相关阅读:
    Python编程从入门到实践 第七章:用户输入和while循环 练习答案记录
    【SQL实用技巧】-- 分组内求topN问题
    PAT甲级:1055 The World‘s Richest |Python
    第五十七章 学习常用技能 - 查看Globals
    RabbitMQ(十)【高级 - 集群】
    C和指针 第15章 输入/输出函数 15.13 改变缓冲方式
    NeurIPS 2023 | FedFed:特征蒸馏应对联邦学习中的数据异构
    Vue组件之间传值
    android AudioRecord
    vue2技能树(6)-事件处理和表单输入绑定
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126714050