Java 实战范例之线上婚纱摄影预定系统的实现
程序员文章站
2022-03-24 08:52:07
一、项目简述功能: 前后用户的登录注册,婚纱照片分类,查看,摄影师预 订,后台订单管理,图片管理等等。二、项目运行环境配置: jdk1.8 + tomcat8.5 + mysql + eclispe...
一、项目简述
功能: 前后用户的登录注册,婚纱照片分类,查看,摄影师预 订,后台订单管理,图片管理等等。
二、项目运行
环境配置: jdk1.8 + tomcat8.5 + mysql + eclispe (intellij idea,eclispe,myeclispe,sts 都支持)
项目技术:html+css+javascript+jsp+mysql+spring+springmvc+mybatis+spring boot
用户登陆信息操作代码:
/** * 用户登陆信息操作 */ @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 实战项目锤炼之线上婚纱摄影预定系统的实现的文章就介绍到这了,更多相关java 婚纱摄影预定系统内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!