• 使用GIt小组分工完成积分商城系统-SSM


    一.项目需求分析:

    二.数据库设计 :

     三.个人分工之办卡业务具体实现:

    • 页面效果:
      • 分析:

        • 办卡业务,首先也在数据库当中查看新办的卡是否已经存在,存在的话需要给用户提示,然后就是必要的信息都不能空提交,在前端就要做好非空校验并给出友好的提示,再者就是支付功能,默认是办理普通卡,如要办理vip卡,需要先付款,付款后确认办卡,即可办理vip卡
        • 难点:主要在于前端的校验及提示,因为后端处理起来只有两条SQL语句,就是提交前的卡号校验以及提交时的非空校验,
        • 总结:这里遇到问题后,卡在jQuery里面挺久,但是后来发现有些校验其实可以放到控制层去做,比如卡号的重名校验,因为这里的卡号重名校验与非空校验都需要用到,所以在前端不太好做(我也是试了很多种方法都不太行)
      • 收获的新知识点:
        • 取表单数据,尤其注意单选框
            1. //取值
            2. var confirmTj = true;
            3. var cardNum = $('#cardNum').val();
            4. var name = $('#name').val();
            5. // alert(name);
            6. var sex = $("input[name='sex']:checked").val();
            7. // alert(sex);
            8. var tel = $('#tel').val();
            9. var address = $('#address').val();

        •  当表单数据不为空时,取消提示,主要注意单选框的消除
            1. //非空提示的消除
            2. $("input:radio[name='sex']").change(function () {
            3. $('#sexWarning').text("");
            4. });
            5. $('#cardNum').change(function () {
            6. $('#cardNumWarning').text("");
            7. })
            8. $('#name').change(function () {
            9. $('#nameWarning').text("");
            10. })
            11. $('#tel').change(function () {
            12. $('#telWarning').text("");
            13. })
            14. $('#address').change(function () {
            15. $('#addressWarning').text("");
            16. })

    •  所有代码:
    • AddCardMapper.xml
        1. "1.0" encoding="UTF-8" ?>
        2. mapper
        3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
        5. <mapper namespace="com.pro.Dao.AddCardDao">
        6. <select id="selectCardNum" parameterType="Card" resultType="Card">
        7. select * from card where cardNum=#{cardNum}
        8. select>
        9. <insert id="insertCard" parameterType="Card">
        10. insert into card set cardNum=#{cardNum},name=#{name},tel=#{tel},sex=#{sex},address=#{address},vip=#{vip}
        11. insert>
        12. mapper>
    • AddCardDao
        1. package com.pro.Dao;
        2. import com.pro.domain.Card;
        3. public interface AddCardDao {
        4. Card selectCardNum(Card card);
        5. void insertCard(Card card);
        6. }
    •  AddCardServiceImpl,接口就不写了
        1. package com.pro.service;
        2. import com.pro.Dao.AddCardDao;
        3. import com.pro.domain.Card;
        4. import org.springframework.beans.factory.annotation.Autowired;
        5. import org.springframework.stereotype.Service;
        6. @Service
        7. public class AddCardServiceImpl implements AddCardService {
        8. @Autowired
        9. private AddCardDao addCardDao;
        10. @Override
        11. public String checkCardNum(Card card) {
        12. Card card1 = addCardDao.selectCardNum(card);
        13. String mes = "该卡号已存在!";
        14. if(card1 == null){
        15. mes = "";
        16. }
        17. System.out.println(mes);
        18. return mes;
        19. }
        20. @Override
        21. public String saveCard(Card card) {
        22. addCardDao.insertCard(card);
        23. String mes = "恭喜您,办理成功!";
        24. return mes;
        25. }
        26. }
    • AddCardController--控制层
        1. package com.pro.Controller;
        2. import com.pro.domain.Card;
        3. import com.pro.service.AddCardService;
        4. import org.springframework.beans.factory.annotation.Autowired;
        5. import org.springframework.stereotype.Controller;
        6. import org.springframework.web.bind.annotation.RequestMapping;
        7. import org.springframework.web.bind.annotation.ResponseBody;
        8. @Controller
        9. public class AddCardController {
        10. @Autowired
        11. private AddCardService addCardService;
        12. //点击办卡,跳转到办卡界面(李俊)
        13. @RequestMapping("/ljAddCard")
        14. public String ljAddCard(){
        15. return "addCard";
        16. }
        17. //查询卡号是否已经存在(李俊)
        18. @RequestMapping("/ljCheckCardNum")
        19. @ResponseBody
        20. public String ljCheckCardNum(Card card){
        21. System.out.println(card);
        22. String mes = addCardService.checkCardNum(card);
        23. System.out.println(mes);
        24. return mes;
        25. }
        26. //办卡(李俊)
        27. @RequestMapping("/ljToAddCard")
        28. @ResponseBody
        29. public String ljToAddCard(Card card){
        30. String mes = addCardService.checkCardNum(card);
        31. if(mes.length() > 0){
        32. return "卡号已被占用,请重新输入!";
        33. }else{
        34. String mes1 = addCardService.saveCard(card);
        35. return mes1;
        36. }
        37. }
        38. }
    •  addCard.jsp
        1. <%--
        2. Created by IntelliJ IDEA.
        3. User: Administrator
        4. Date: 2022/8/27 0027
        5. Time: 10:46
        6. To change this template use File | Settings | File Templates.
        7. --%>
        8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
        9. <link href="css/bootstrap.css" rel="stylesheet">
        10. <script src="js/jquery-3.6.0.js">script>
        11. <script src="js/proper.mini.js">script>
        12. <script src="js/bootstrap.js">script>
        13. <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        14. <html>
        15. <head>
        16. <title>Titletitle>
        17. <style>
        18. #father {
        19. position: absolute;
        20. left: 5%;
        21. top: 5%;
        22. height: 200px;
        23. /*background-color: black;*/
        24. /*scale 缩放*/
        25. transform: scale(1);
        26. /*播放,绑定动画 */
        27. animation: beat 0.5s linear infinite alternate;
        28. }
        29. #father1 {
        30. position: absolute;
        31. right: 5%;
        32. top: 5%;
        33. height: 200px;
        34. /*background-color: black;*/
        35. /*scale 缩放*/
        36. transform: scale(1);
        37. /*播放,绑定动画 */
        38. animation: beat 0.5s linear infinite alternate;
        39. }
        40. /*css3动画 只需要关键的画面
        41. keyframes:关键帧(画面) 动画名称
        42. */
        43. @keyframes beat {
        44. /* 动画开始的画面 */
        45. 0% {
        46. /*缩放*/
        47. transform: scale(1);
        48. }
        49. /*动画结束的画面*/
        50. 100% {
        51. /*结束*/
        52. transform: scale(1.1);
        53. }
        54. }
        55. .left, .right {
        56. float: left;
        57. width: 100px;
        58. height: 160px;
        59. background-color: pink;
        60. border-radius: 50px 50px 0px 0px;
        61. }
        62. .left {
        63. transform: translateX(29px) rotate(-45deg);
        64. /*盒子-阴影 横向,纵向,模糊半径 影子扩展 */
        65. box-shadow: 0px 0px 30px 0px pink;
        66. }
        67. .right {
        68. /*translateX横向位移 rotate:旋转*/
        69. transform: translateX(-29px) rotate(45deg);
        70. /*盒子-阴影 横向,纵向,模糊半径 影子扩展 */
        71. box-shadow: 0px 0px 30px 0px pink;
        72. }
        73. #content {
        74. width: 500px;
        75. position: absolute;
        76. left: 50%;
        77. transform: translateX(-50%);
        78. }
        79. .pay {
        80. float: left;
        81. text-align: center;
        82. background-color: chartreuse;
        83. /*background-color: whitesmoke;*/
        84. }
        85. #Vip {
        86. display: none;
        87. width: 400px;
        88. position: absolute;
        89. left: 50%;
        90. transform: translateX(-50%);
        91. background-color: darkgray;
        92. }
        93. #vipStatusTr {
        94. display: none;
        95. }
        96. #paySuccess {
        97. position: relative;
        98. /* left: 50%;
        99. top: 50%;*/
        100. /*transform: translate(20%,180%);*/
        101. }
        102. #frm span{
        103. color: firebrick;
        104. }
        105. style>
        106. head>
        107. <script>
        108. $(function () {
        109. $('#buyVip').click(function () {
        110. $('#Vip').show();
        111. // alert("hhhhhh");
        112. // document.getElementById('Vip').style.display='block';
        113. })
        114. //付款成功后修改
        115. $('#paySuccess').click(function () {
        116. $('#Vip').hide();
        117. //支付成功后修改vip卡状态
        118. $('#vipStatus').val("1");
        119. //支
        120. $('#afterPay').html("您已购买Vip")
        121. })
        122. //确定提交
        123. $('#tj').click(function () {
        124. $('#checkCardNumResult').text("");
        125. //点击提交后提示置为空
        126. //取值
        127. var confirmTj = true;
        128. var cardNum = $('#cardNum').val();
        129. var name = $('#name').val();
        130. // alert(name);
        131. var sex = $("input[name='sex']:checked").val();
        132. // alert(sex);
        133. var tel = $('#tel').val();
        134. var address = $('#address').val();
        135. if (cardNum.length < 1) {
        136. confirmTj = false;
        137. $('#cardNumWarning').text("请输入新卡卡号!")
        138. }
        139. if (name.length < 1) {
        140. confirmTj = false;
        141. $('#nameWarning').text("请输入名字!")
        142. }
        143. if (sex != "男" && sex != "女") {
        144. confirmTj = false;
        145. $('#sexWarning').text("请选择性别")
        146. }
        147. if (tel.length < 1) {
        148. confirmTj = false;
        149. $('#telWarning').text("请输入手机号!")
        150. }
        151. if (address.length < 1) {
        152. confirmTj = false;
        153. $('#addressWarning').text("请输入地址!")
        154. }
        155. if (confirmTj == true) {
        156. $.ajax({
        157. url: 'ljToAddCard',
        158. type: 'post',
        159. // data: {},
        160. //另一种方式,序列化,就能拿到表单里面的数据,但是这样写需要注意传的数据要和User类能对上
        161. data: $('#frm').serialize(),
        162. //如果不需要返回数据,就不用写
        163. dataType: 'text',
        164. success: function (res) {
        165. //没写过滤器会乱码
        166. alert(res);
        167. }
        168. })
        169. $('#cardNum').val("");
        170. }
        171. })
        172. //非空提示的消除
        173. $("input:radio[name='sex']").change(function () {
        174. $('#sexWarning').text("");
        175. });
        176. $('#cardNum').change(function () {
        177. $('#cardNumWarning').text("");
        178. })
        179. $('#name').change(function () {
        180. $('#nameWarning').text("");
        181. })
        182. $('#tel').change(function () {
        183. $('#telWarning').text("");
        184. })
        185. $('#address').change(function () {
        186. $('#addressWarning').text("");
        187. })
        188. //查询新注册的卡号是否已经存在
        189. $('#cardNum').change(function () {
        190. var cardNum = $(this).val();
        191. checkCardNum(cardNum);
        192. })
        193. //关闭vip充值页面
        194. $('#closeVip').click(function () {
        195. $('#Vip').hide();
        196. })
        197. })
        198. function checkCardNum(v) {
        199. $.ajax({
        200. url: 'ljCheckCardNum',
        201. type: 'post',
        202. data: {cardNum: v},
        203. //另一种方式,序列化,就能拿到表单里面的数据,但是这样写需要注意传的数据要和User类能对上
        204. // data:$('#frm').serialize(),
        205. //如果不需要返回数据,就不用写
        206. dataType: 'text',
        207. success: function (res) {
        208. //没写过滤器会乱码
        209. $('#checkCardNumResult').text(res);
        210. }
        211. })
        212. }
        213. script>
        214. <body>
        215. <div id="father">
        216. <div class="left">
        217. <button type="button" class="btn btn-info" style="border-radius: 50px 50px 0px 0px">vip卡更多优惠哦!button>
        218. div>
        219. <div class="right">div>
        220. div>
        221. <div id="content">
        222. <form id="frm">
        223. <table class="table table-striped">
        224. <thead>
        225. <tr>
        226. <th scope="col" colspan="2" style="text-align: center"><b style="font-size: 20px">新卡办理b>th>
        227. tr>
        228. thead>
        229. <tbody style="margin-top: 5px">
        230. <tr>
        231. <th scope="row">卡号th>
        232. <td><input type="text" placeholder="请输入新卡卡号:" name="cardNum" id="cardNum">
        233.   <span id="checkCardNumResult" style="color: darkblue">span>
        234. <span id="cardNumWarning">span>
        235. td>
        236. tr>
        237. <tr>
        238. <th scope="row">姓名th>
        239. <td>
        240. <input type="text" placeholder="请输入办卡人姓名:" name="name" id="name">
        241.   <span id="nameWarning">span>td>
        242. td>
        243. tr>
        244. <tr>
        245. <th scope="row">手机号th>
        246. <td>
        247. <input type="text" placeholder="请输入手机号" name="tel" id="tel">
        248.   <span id="telWarning">span>td>
        249. td>
        250. tr>
        251. <tr>
        252. <th scope="row">性别th>
        253. <td>
        254. <input type="radio" name="sex" id="payVip" value="男">
        255. <input type="radio" name="sex" value="女">
        256.   <span id="sexWarning">span>td>
        257. td>
        258. tr>
        259. <tr>
        260. <th scope="row">地址th>
        261. <td>
        262. <input type="text" placeholder="请输入地址" name="address" id="address">
        263.   <span id="addressWarning">span>td>
        264. td>
        265. tr>
        266. <tr id="vipStatusTr">
        267. <th scope="row">Vip状态th>
        268. <td>
        269. <input type="text" name="vip" value="0" id="vipStatus">
        270. td>
        271. tr>
        272. <tr>
        273. <th scope="row">是否购买Vipth>
        274. <td id="afterPay">
        275. <a id="buyVip" style="border-radius: 10px">88元购买<b>Vipb>a>
        276. <%-- <button>測試button>--%>
        277. td>
        278. tr>
        279. tbody>
        280. table>
        281. form>
        282. <table>
        283. <tr>
        284. <td colspan="2" style="text-align: center;width: 500px" align="center">
        285. <button class="btn btn-success" id="tj">提交button>
        286. <button class="btn btn-info">返回button>
        287. td>
        288. tr>
        289. table>
        290. div>
        291. <div id="father1">
        292. <div class="left">div>
        293. <div class="right">
        294. <button type="button" class="btn btn-info" style="border-radius: 50px 50px 0px 0px">vip卡好礼不断!button>
        295. div>
        296. div>
        297. <div id="Vip">
        298. <div style="width: 100%" class="pay">
        299. <span>
        300. <b>微信支付b>
        301. <a href="#" style="float: right" id="closeVip">Xa>
        302. span>
        303. <div style="width: 80%;background-color: #17a2b8;height: 300px;margin-left: 10%">
        304. <img src="image/pay2.jpg" alt="" style="width: 100%">
        305. div>
        306. div>
        307. <div style="width: 100%" class="pay">
        308. <span><b>支付宝b>span>
        309. <div style="width: 80%;background-color: #17a2b8;height: 300px;margin-left: 10%">
        310. <img src="image/pay1.png" alt="" style="width: 100%">
        311. div>
        312. div>
        313. <div style="width: 100%;float: right" class="pay">
        314. <button id="paySuccess" style="border-radius: 10px">支付成功button>
        315. div>
        316. td>
        317. tr>
        318. div>
        319. body>
        320. html>

    •  以上就是在这个小组项目当中我完成的业务,当自己的业务写完以后,提交到本地仓库,push上传到git远程仓库当中,当小组其他成员也上传以后,就可以切换到主分支,逐个新建各分支的本地分支,然后合并到主分支当中,在本地运行无误以后,就可以上传到远程仓库了。
    • 还有就是自己在合并的时候遇到的一些问题,像诸如:找不到xxxcontroller,这种有可能是控制层当中存在相同的路由,因此会模糊不清
    • 还有可能小组成员在写各自分支的时候,使用的都是自己的数据库,然后提交到远程时们也没有改过来
    • 第三个也会存在小组成员之间目录名称大小写不一样
  • 相关阅读:
    C++11多线程thread使用详解
    javascript--async和defer的区别
    FFmpeg+SDL实时解码和渲染H264视频流
    内网穿透工具之花生壳(二)
    c++day5
    ARM PWN
    解锁数据分析的神器:ChatGPT引领人工智能革命
    《最新出炉》系列初窥篇-Python+Playwright自动化测试-16-处理模态对话框弹窗
    第3章-9 字符串转换成十进制整数
    SpringBoot:第一章JavaConfig、@ImportResource、@PropertyResource等总结(动力)
  • 原文地址:https://blog.csdn.net/qq_60555957/article/details/126669103