阅读 25 SEO

Java 实战范例之线上婚纱摄影预定系统的实现

读万卷书不如行万里路,只学书上的理论是远远不够的,只有在实战中才能获得能力的提升,本篇文章手把手带你用java+javaweb+SSM+springboot+mysql实现一个线上婚纱摄影预定系统,大家可以在过程中查缺补漏,提升水平

一、项目简述

功能: 前后用户的登录注册,婚纱照片分类,查看,摄影师预 订,后台订单管理,图片管理等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术:HTML+CSS+JavaScript+jsp+mysql+Spring+SpringMVC+mybatis+Spring boot


用户登陆信息操作代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**
 * 用户登陆信息操作
 */
@Controller
@RequestMapping("/user")
@Scope("prototype")
public class UserController {
  
    private static final Logger logger = LoggerFactory.getLogger(UserController.class);
    private ReturnResult returnResult = new ReturnResult();
  
    @Resource(name = "userService")
    private IUserService userService;
  
    /**
     * 登录
     * @param user
     * @param session
     * @return
     */
    @RequestMapping(value = "login")
    @ResponseBody
    public ReturnResult login(TUser user, HttpSession session) {
        returnResult.setStatus(ReturnCodeType.FAILURE);
  
        try {
            user = userService.login(user);
            if (user != null) {
                user.setPassword(null);
                session.setAttribute("user", user);
                returnResult.setStatus(ReturnCodeType.SUCCESS);
  
            }
        } catch (Exception e) {
            logger.error("登录失败" + e);
  
        }
        return returnResult;
  
    }
  
    /**
     * 从session中获取用户信息
     * @param session
     * @return
     */
    @RequestMapping("getUserInfo")
    @ResponseBody
    public ReturnResult getUserInfo(HttpSession session) {
        returnResult.setStatus(ReturnCodeType.FAILURE);
        TUser user = (TUser) session.getAttribute("user");
        if (user != null) {
            returnResult.setStatus(ReturnCodeType.SUCCESS).setData(user);
        } else {
            logger.info("获取用户信息失败:用户未登录");
        }
        return returnResult;
    }
  
    /**
     * 注册用户
     * @param user
     * @return
     */
    @RequestMapping(value = "register")
    @ResponseBody
    public ReturnResult register(TUser user) {
        returnResult.setStatus(ReturnCodeType.FAILURE);
        try {
            if (userService.checkUserByName(user.getName())) {
                if (userService.register(user) >= 0) {
                    returnResult.setStatus(ReturnCodeType.SUCCESS);
                }
            }
  
        } catch (Exception e) {
            logger.error("注册失败" + e);
        }
  
        return returnResult;
  
    }
  
    /**
     * 检测用户名是否存在
     * @param name
     * @return
     */
    @RequestMapping(value = "checkUserName")
    @ResponseBody
    public ReturnResult checkUserName(String name) {
        returnResult.setStatus(ReturnCodeType.FAILURE);
        try {
            if (userService.checkUserByName(name)) {
                returnResult.setStatus(ReturnCodeType.SUCCESS);
            }
  
        } catch (Exception e) {
            logger.error("检测用户名是否存在失败:" + e);
        }
  
        return returnResult;
  
    }
  
    /**
     * 管理员查看所有的用户信息
     * @param session
     * @return
     */
    @RequestMapping("getAllUserInfo")
    @ResponseBody
    public ReturnResult getAllUserInfo(HttpSession session,PageVO page,String name) {
        returnResult.setStatus(ReturnCodeType.FAILURE);
        try {
            if (session.getAttribute("admin") != null) {
                Map<String, Object> resultMap = new HashMap<String, Object>();
                StringBuffer sql = new StringBuffer("SELECT DISTINCT * FROM t_user WHERE 1=1");
                if(StringUtils.isNotBlank(name)){
                    sql.append(" AND name="+name);
                }
                 
                List<Map<String, Object>> results = userService.selectPageBySQL(sql.toString(), page.getPage() - 1,
                        page.getRows());
                if (!results.isEmpty() && results != null) {
                    int total = userService.selectCount(new TUser());
                    int rows = page.getRows();
                    rows = rows == 0 ? 10 : rows;
                    resultMap.put("total", (total % rows != 0 ? (total / rows + 1) : (total / rows)));
                    resultMap.put("page", page.getPage());
                    resultMap.put("records", total);
                    resultMap.put("rows", results);
                    returnResult.setStatus(ReturnCodeType.SUCCESS).setData(resultMap);
                }
            } else {
                logger.info("获取所有的用户信息失败:管理员未登录");
            }
        } catch (Exception e) {
            logger.error("获取所有的用户信息失败:" + e);
  
        }
        return returnResult;
    }
  
    /**
     * 退出
     * @param session
     * @return
     */
    @RequestMapping("logout")
    @ResponseBody
    public ReturnResult logout(HttpSession session) {
        session.invalidate();
        return returnResult.setStatus(ReturnCodeType.SUCCESS);
    }
  
    /**
     * 修改密码
     * @param oldPassword
     * @param password
     * @param session
     * @return
     */
    @RequestMapping("updatePassword")
    @ResponseBody
    public ReturnResult updatePassword(TUser user) {
        returnResult.setStatus(ReturnCodeType.FAILURE);
        try {
                if (userService.updatePassword(user) > 0) {
                    returnResult.setStatus(ReturnCodeType.SUCCESS);
                }
        } catch (Exception e) {
            logger.error("修改密码失败:" + e);
        }
        return returnResult;
    }
     
}

到此这篇关于Java 实战项目锤炼之线上婚纱摄影预定系统的实现的文章就介绍到这了

原文链接:https://blog.csdn.net/m0_59687645/article/details/121204024


文章分类
代码人生
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 gxwowoo@163.com 举报,一经查实,本站将立刻删除。
相关推荐