精华内容
下载资源
问答
  • 基金前端代码和后端代码的区别 基金后端代码和基金前端代码区别 一、问题 在浏览基金网站的时候,发现一款基金【交银成长30混合】,发现基金代码有一个前端交易代码和一个后端交易代码,本着好奇的心态,了解了...

               基金前端代码和后端代码的区别 基金后端代码和基金前端代码区别

     

    一、问题

    在浏览基金网站的时候,发现一款基金【交银成长30混合】,发现基金代码有一个前端交易代码和一个后端交易代码,本着好奇的心态,了解了下。 好记性不如烂笔头,记录下!

     

     

    二、区别

    1、前端代码:申购基金时:直接扣除手续费。如:基金申购手续费为1%,申购1000元,申购成功后,基金金额变为990元,亏损1%。

    2、后端代码:申购基金时:不扣费。在赎回基金时,一次性扣除和申购费和赎回费用。 (出来混的,总是要还滴!)

     

    三、总结

    1、现在大部分基金都是前端收费的。如在支付宝中搜索 519727 前端代码,显示可以购买的;搜索 519728 后端代码,则显示“本平台暂不销售”。

     

     

     

    参考资料:https://www.wdzj.com/hjzs/wangdai/20171130/223400-168.html

     

     

     

    展开全文
  • 评估-生菌后端 后端代码
  • 后端代码规范

    2016-11-02 21:55:26
    后端代码规范
  • 限时特价php后端代码和前端代码
  • WebSocket后端代码

    2018-06-29 10:48:24
    WebSocket简易聊天室的后端代码,博客有代码了。建议取博客看。懒得写就直接下载吧
  • 视频网站后端代码

    2019-04-23 00:33:48
    用Golang写的后端代码,可以用作视频网站用,只希望用作学习、研究使用,请勿商用。
  • 断点续传后端代码.zip

    2021-05-12 16:50:09
    Webuploader大文件断点续传后端代码,经过线上完备测试,完整版后端代码,基于百度Webuploder组件对文件进行分割和上传,绝对可用。
  • 全文共2160字,预计学习...”· 你需要快速、安全地进行迭代· 不太了解后端代码、主机或DevOps· 专注于已经很复杂的前端开发工作那么,在没有任何后端代码的情况下,你能开发出一个可以工作的应用程序吗?小芯告诉...

    e06a5f6ea4b215d2368d36ac7f7619db.png
    全文共2160字,预计学习时长7分钟

    78250aa7a2f49274d811e67309395490.png
    来源:Pexels

    在一个一切都在加速的世界里,你需要快速迭代以避免被抛弃。

    技术有很多,但你不可能掌握每一项。你可能会问自己:“我怎么能在不了解后端代码的情况下构建应用程序呢?”

    · 你需要快速、安全地进行迭代

    · 不太了解后端代码、主机或DevOps

    · 专注于已经很复杂的前端开发工作

    那么,在没有任何后端代码的情况下,你能开发出一个可以工作的应用程序吗?小芯告诉你:可以的。

    下面我们就来一一介绍:

    后端作为服务(BaaS)进行救援

    作为服务的后端是一个远程工具箱,不需要一行代码,它就可以帮助你快速构建通用的应用程序功能,比如自动验证、数据库持久性、搜索和统计信息。

    有很多工具提供了这样的工具。

    · Firebase可能是最知名的,它是由谷歌和谷歌云平台支持的。

    它非常高效和酷,是作为一个云黑盒工具托管的。

    如果你需要本地工具,你可以使用自己的主机查看一些解决方案,比如

    · Kuzzle,一个基于NodeJS、弹性搜索和Redis的特别强大的物联网和高性能/流量应用服务(BaaS)。

    · FeatherJS,一个有各种连接器的NodeJS服务器,可用于MySQL, Postgres或MongoDB。

    · Strapi,一个帮助你快速建立CMS的NodeJS服务器。当使用Baas时,你需要稍微改变主意。

    681450307cadc2d1b840f0c7c95826d4.png
    来源:Pexels

    与调用将根据自定义逻辑更改数据的自己的端点不同,与根据自定义逻辑调用端点来更改数据不同,你通常会直接使用前端的格式化数据查询与数据库交互的服务端点,因为这些数据必须出现在数据库中。

    因此,前端代码被认为是安全的,惟一要做的就是在后端应用一些验证策略来保证某些场景中的数据完整性。

    请记住,当谈到“backendless”时,实际上它有一个正在运行的后端,只是你不需要为此编写任何(或只编写很少)代码。几乎一切都已为你准备好了。

    把后端作为服务的一个小例子

    假设你需要创建一个博客帖子,如果没有BaaS,你可能会调用一个名为post/blog/create的端点,并且可能会传递这样的对象

    056d158cbd06c716a48635899ad7cfe9.png

    然后在后端,你将添加一个postID、一个带有创建日期的服务器时间戳,可能还添加了一个字段,作者使用的是使用会话令牌找到的当前用户。

    使用BaaS,你可以像使用SDK这样直接在集合上进行调用(我将在下面向你展示一个FirebaseFirestore示例,在其他工具中类似)。

    71cd1b1536cf102992ccbe22f4db005d.png

    并且在后端添加一些限制策略,例如通过验证作者。

    6afd5f04e6d99b7230d36edea6aab47b.png

    这样,可以更快地编写代码,而且为安全策略定义自动化测试套件也比后端代码更容易。默认情况下,所有东西都是禁用的,可以一点一点地启用它们。

    这也可以定义一些后端函数来“挂钩”某些事件,如文档创建、编辑或删除。这样就可以定义一些副作用或额外验证。

    使用后端作为服务能创建什么?

    这就是问题所在……你可以构建的东西是没有限制的,如果遇到了限制,可以用其他工具甚至自定义后端来扩展这些工具。大多数情况下,在基于云的解决方案上有合理的免费层,所以开始构建时没有问题,当应用成功时你就要开始支付少量费用了。

    那很昂贵吗?

    6a91202505579442700fccfa4ac1ddc7.png
    来源:Pexels

    记住,任何帮助你更快、更安全的事情通常都有不利的一面。在使用内部包时,成本是关于开发人员支持和协助许可的。

    但是当使用云BaaS时,当它们扩展到一个非常大的数据集时,通常就很昂贵了,你还需要设计应用程序来大规模地使用它们,但是工程师最大的问题是花时间优化一些根本不应该存在的东西。

    使用BaaS进行快速迭代,如果你的产品获得了一些成功,请考虑稍后对其进行优化的方法,有可能的话切换到另一种技术。

    BaaS很酷的一点是,你可以很容易地迁移到其他工具。现在轮到你了,快来试试吧。

    3e770462ff3b91402fa0f87fc6054cd9.png

    留言 点赞 关注

    我们一起分享AI学习与发展的干货

    编译组:齐欣、高雪窈

    相关链接:

    https://medium.com/javascript-in-plain-english/can-i-make-an-app-without-any-backend-code-7ef22129e3d7

    如转载,请后台留言,遵守转载规范

    展开全文
  • 天天生鲜后端代码.zip

    2020-03-08 01:48:24
    天天生鲜后端代码.zip
  • 跨站辅种工具后端代码
  • 外卖带bmob后端代码.zip
  • 像打包前端代码一样打包后端代码,以便在创建 docker 镜像时过滤 node_modules,使镜像变小,加快 push 速度
  • sm2数据签名后端代码部分,主要是用于sm2签名时 后端验证签名以及添加签名使用方法.我主要是使用了sm2的签名方法
  • CSCapstone后端 FridgeFiller团队的后端代码
  • 微信小程序java后端代码
  • tesseract-job-分布式调度后端代码
  • 后端 snippet-io的后端代码
  • 茶叶商城小程序后端代码,适合用于电商模块。下来在传前端代码
  • 这是eduID的后端代码
  • 后端代码架构

    2018-04-11 11:50:00
    后端代码架构 CSDN发布时间:2018年03月19日 13:12:14 3月19日晚21时,小组在西区图书馆205研讨室举行了第六次项目组会议。 本次会议的主要内容为确定一部分后端代码架构,隆晋威组长给我们带来了...

    CSDN发布时间:2018年03月19日 13:12:14

     

    3月19日晚21时,小组在西区图书馆205研讨室举行了第六次项目组会议。

    本次会议的主要内容为确定一部分后端代码架构,隆晋威组长给我们带来了详细生动的解说。

    以下是第一部分后端架构的内容。(其中package为包,object为实例,class为类,/**/和//为注释内容)

    这部分后端架构主要负责用户申请游戏到开始游戏这两个节点之间后台的所有过程(匹配、设置游戏控制器、记录数据等等)

     

    Package game

     

    class GodActor
     /*
    *control the game
    *receive & send & loop control
    *1.All kinds of rule systems : Checker
    *2.hold all the states
    *God disappears after a game ends
    */  
    ​
    object UsersDB
    /*
    *long-lasting static database
    *hold players' information
    *1.auth
    *2.stats
    */  
    ​
    object MatcherActor 
    /*
    *match players
    *1.get info from SessionsManager
    *2.get info from PlayersDB
    *3.awakened by SessionManager
    */
    ​
    object SessionsManagerActor
    /*
    *1.interact with systems out of package game
    *2.send msg to other game system
    *contact with player
    */
    ​
    object SkillsChecker
    object MapChecker
    object GambleChecker
    object PlayerChecker
    /*
    *four static databases
    *checked by GodActor when needed
    */

     

    看不懂以上架构是如何工作的同学请看这里

     

     

    其中某些对象和类采用了Actor模型,该种对象和类以Actor作为命名后缀。

    该架构仅仅是对游戏系统的高度抽象,此后会向其中加入更多的细节。

     

    posted on 2018-04-11 11:50 NoWarningNoError队 阅读(...) 评论(...) 编辑 收藏

    转载于:https://www.cnblogs.com/NoWarningNoError/p/8794820.html

    展开全文
  • 大觅网后端代码-微服务spring boot
  • 疫防控后端代码接口编写练习,不收积分,纯粹是为了方便自己下载练习;里面包含的代码内容简单且没有注释。
  • 旅游系统 后端代码

    2020-11-09 23:28:54
    旅游系统(SSM框架+MySQL+Redis+VUE)后端代码 文章目录旅游系统(SSM框架+MySQL+Redis+VUE)后端代码Controller登录注册路线邮件退出头部信息路线详情收藏验证码验证码添加dao接口user路线信息收藏工具类分页...

    旅游系统(SSM框架+MySQL+Redis+VUE)后端代码

    Controller

    登录

    package org.island.controller;
    
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.Lian;
    import org.island.Utils.UuidUtil;
    import org.island.bean.ResultInfo;
    import org.island.bean.User;
    import org.island.dao.UserDao;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.Objects;
    
    @Controller
    @RequestMapping("/login")
    public class LoginController {
        @RequestMapping("/check_login")
        public void checkName(User g, HttpServletRequest request, HttpServletResponse response) {
            SqlSession sqlSession = Lian.getDao();
            UserDao userDao = sqlSession.getMapper(UserDao.class);
            User checkuser = userDao.find(g.getUsername());
            ResultInfo resultInfo = new ResultInfo();
            boolean flag = true;
                if (checkuser!=null) {
                    if(checkuser.getStatus().equals("Y")){
                        if(checkuser.getPassword().equals(g.getPassword())){
                            resultInfo.setFlag(true);
                            request.getSession().setAttribute("user", checkuser);
                        }else {
                            resultInfo.setErrorMsg("3");
                        }
                    }else {
                        resultInfo.setErrorMsg("2");
                    }
                }else {
                    resultInfo.setErrorMsg("1");
                }
            ObjectMapper mapper = new ObjectMapper();
            String json = null;
            try {
                json = mapper.writeValueAsString(resultInfo);
                response.setContentType("application/json;chartset=utf-8");
                response.getWriter().write(json);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        @RequestMapping("/check")
        public void check_code(String check, HttpServletRequest request, HttpServletResponse response) {
            String userCheckCode = String.valueOf(request.getSession().getAttribute("CHECKCODE_SERVER"));
            ObjectMapper mapper = new ObjectMapper();
            request.getSession().removeAttribute("CHECKCODE_SERVER");
            ResultInfo resultInfo = new ResultInfo();
            if (Objects.equals(userCheckCode, "") || !userCheckCode.equalsIgnoreCase(check)) {
                resultInfo.setFlag(false);
                resultInfo.setErrorMsg("验证码错误");
                String json = null;
                try {
                    json = mapper.writeValueAsString(resultInfo);
                    response.setContentType("application/json;chartset=utf-8");
                    response.getWriter().write(json);
                } catch (IOException e) {
                    e.printStackTrace();
                }
    
            } else {
                resultInfo.setFlag(true);
                String json = null;
                try {
                    json = mapper.writeValueAsString(resultInfo);
                    response.setContentType("application/json;chartset=utf-8");
                    response.getWriter().write(json);
                } catch (IOException e) {
                    e.printStackTrace();
                }
    
            }
    
    
        }
    
    }
    
    

    注册

    package org.island.controller;
    
    import com.fasterxml.jackson.core.JsonProcessingException;
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.MailUtils;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.island.dao.UserDao;
    import org.island.bean.ResultInfo;
    import org.island.bean.User;
    import org.island.Utils.Lian;
    import org.island.Utils.UuidUtil;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.List;
    
    @Controller
    @RequestMapping("/register")
    public class RegisterController {
        @RequestMapping("/add_user")
        public void checkName(User g, HttpServletRequest request, HttpServletResponse response) {
            SqlSession sqlSession = Lian.getDao();
            UserDao userDao = sqlSession.getMapper(UserDao.class);
            User checkuser = userDao.find(g.getUsername());
            boolean flag = true;
                if (checkuser!=null) {
                    flag = false;
                }
    
            ResultInfo resultInfo = new ResultInfo();
            if (flag) {
                String code = UuidUtil.getUuid();
                request.getSession().setAttribute("UUID_ONLY",code);
                g.setStatus("N");
                g.setCode(code);
                userDao.saveUser(g);
                sqlSession.commit();
                sqlSession.close();
                resultInfo.setFlag(true);
            } else {
                resultInfo.setFlag(false);
                resultInfo.setErrorMsg("注册失败");
            }
            ObjectMapper mapper = new ObjectMapper();
            String json = null;
            try {
                json = mapper.writeValueAsString(resultInfo);
                response.setContentType("application/json;chartset=utf-8");
                response.getWriter().write(json);
            } catch (IOException e) {
                e.printStackTrace();
            }
    
    
        }
    
        @RequestMapping("/check")
        public void check_code(String check, HttpServletRequest request, HttpServletResponse response) {
            String userCheckCode = String.valueOf(request.getSession().getAttribute("CHECKCODE_SERVER"));
            System.out.println(check);
            System.out.println(userCheckCode);
            ObjectMapper mapper = new ObjectMapper();
            request.getSession().removeAttribute("CHECKCODE_SERVER");
            if (userCheckCode == null || !userCheckCode.equalsIgnoreCase(check)) {
                ResultInfo resultInfo = new ResultInfo();
                resultInfo.setFlag(false);
                resultInfo.setErrorMsg("验证码错误");
                String json = null;
                try {
                    json = mapper.writeValueAsString(resultInfo);
                    response.setContentType("application/json;chartset=utf-8");
                    response.getWriter().write(json);
                } catch (IOException e) {
                    e.printStackTrace();
                }
    
            } else {
                ResultInfo resultInfo = new ResultInfo();
                resultInfo.setFlag(true);
                String json = null;
                try {
                    json = mapper.writeValueAsString(resultInfo);
                    response.setContentType("application/json;chartset=utf-8");
                    response.getWriter().write(json);
                } catch (IOException e) {
                    e.printStackTrace();
                }
    
            }
    
    
        }
    
    
    
    }
    
    

    路线

    package org.island.controller;
    
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.JedisUtil;
    import org.island.Utils.Lian;
    import org.island.bean.Category;
    import org.island.bean.PageBean_new;
    import org.island.bean.Route;
    import org.island.dao.ListDao;
    import org.island.dao.RouteDao;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import redis.clients.jedis.Jedis;
    import redis.clients.jedis.Tuple;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Set;
    
    @Controller
    @RequestMapping("/route")
    public class RouteController {
        @RequestMapping("/find_route")
        public void checkName(HttpServletRequest request, HttpServletResponse response) {
            String currentPageStr = request.getParameter("currentPage");
            String pageSizeStr = request.getParameter("pageSize");
            String cidStr = request.getParameter("cid");
            int currentPage = 1;
            if (currentPageStr != null && currentPageStr.length() > 0) {
                currentPage = Integer.parseInt(currentPageStr);
            }
            int pageSize = 5;
            if (pageSizeStr != null && pageSizeStr.length() > 0) {
                pageSize = Integer.parseInt(pageSizeStr);
            }
            int cid = 5;
            if (cidStr != null && cidStr.length() > 0) {
                cid = Integer.parseInt(cidStr);
            }
    
            SqlSession sqlSession = Lian.getDao();
            RouteDao routeDao = sqlSession.getMapper(RouteDao.class);
            Integer totalItem = routeDao.findCount(5);
            PageBean_new<Route> pageBean = new PageBean_new<>(totalItem, currentPage, pageSize);
            int start = (currentPage - 1) * pageSize;
            List<Route> list = routeDao.findPart(cid, start, pageSize);
            pageBean.setList(list);
    
            System.out.println("当前页数" + currentPageStr);
            System.out.println("条数" + pageSize);
            System.out.println("编号" + cid);
            System.out.println("集合" + list);
            System.out.println(pageBean);
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
                mapper.writeValue(response.getOutputStream(), pageBean);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        @RequestMapping("/find_list")
        public void find_list(HttpServletRequest request, HttpServletResponse response) {
            Jedis jedis = JedisUtil.getJedis();
            Set<Tuple> set = jedis.zrangeWithScores("category", 0, -1);
            List<Category> list = null;
            if (set == null || set.size() == 0) {
                SqlSession userDao = Lian.getDao();
                ListDao mapper = userDao.getMapper(ListDao.class);
                list = mapper.findAll();
                for (Category category : list) {
                    //cid作为分数,可以排序
                    jedis.zadd("category", category.getCid(), category.getCname());
                }
                System.out.println(list);
            } else {
    
                list = new ArrayList<Category>();
                for (Tuple tuple : set) {
                    Category category = new Category();   //把分数,强转成int类型
                    category.setCid((int) (tuple.getScore()));
                    category.setCname(tuple.getElement());
                    list.add(category);
                }
                System.out.println(list);
            }
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
                mapper.writeValue(response.getOutputStream(), list);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        @RequestMapping("/find_find")
        public void checkFind(HttpServletRequest request, HttpServletResponse response) {
            String currentPageStr = request.getParameter("currentPage");
            String pageSizeStr = request.getParameter("pageSize");
            String rname = request.getParameter("rname");
            String cidStr = request.getParameter("cid");
            int currentPage = 1;
            if (currentPageStr != null && currentPageStr.length() > 0) {
                currentPage = Integer.parseInt(currentPageStr);
            }
            int pageSize = 5;
            if (pageSizeStr != null && pageSizeStr.length() > 0) {
                pageSize = Integer.parseInt(pageSizeStr);
            }
            int cid = 5;
            if (cidStr != null && cidStr.length() > 0) {
                cid = Integer.parseInt(cidStr);
            }
    
            SqlSession sqlSession = Lian.getDao();
            RouteDao routeDao = sqlSession.getMapper(RouteDao.class);
            Integer totalItem = routeDao.findFind(cid, "%" + rname + "%");
            List<Route> list = routeDao.findF(5, "%" + rname + "%");
            PageBean_new<Route> pageBean = new PageBean_new<>(totalItem, currentPage, pageSize);
            int start = (currentPage - 1) * pageSize;
            pageBean.setList(list);
    
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
                mapper.writeValue(response.getOutputStream(), pageBean);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    
    

    邮件

    package org.island.controller;
    
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.Lian;
    import org.island.Utils.MailUtils;
    import org.island.Utils.UuidUtil;
    import org.island.bean.ResultInfo;
    import org.island.bean.User;
    import org.island.dao.UserDao;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.List;
    
    @Controller
    @RequestMapping("/email")
    public class EmailController {
        @RequestMapping("/send_email")
        public void send_email(String email, HttpServletRequest request, HttpServletResponse response) {
    
            String uuid = String.valueOf(request.getSession().getAttribute("UUID_ONLY"));
            String mailCotent = "<a href='http://localhost:8080/travel/email/check_email?code=" + uuid + "'>官方 </a>";
            MailUtils.sendMail(email, mailCotent, "测试邮件");
            ObjectMapper mapper = new ObjectMapper();
            ResultInfo resultInfo = new ResultInfo();
            resultInfo.setFlag(true);
            String json = null;
            try {
                json = mapper.writeValueAsString(resultInfo);
                response.setContentType("application/json;chartset=utf-8");
                response.getWriter().write(json);
            } catch (IOException e) {
                e.printStackTrace();
            }
    
    
        }
    
        @RequestMapping("/check_email")
        public void check_email(HttpServletRequest request, HttpServletResponse response) {
            String activeCode = request.getParameter("code");
            SqlSession sqlSession = Lian.getDao();
            UserDao userDao = sqlSession.getMapper(UserDao.class);
    
            if (activeCode != null) {
    
                User checkuser = userDao.findCode(activeCode);
                String msg = "";
                if (checkuser!=null) {
                    userDao.update("Y",checkuser.getUsername());
                    sqlSession.commit();
                    sqlSession.close();
                    msg = "激活成功请<a href='http://localhost:8080/travel/login.html'>登录</a>";
                } else {
                    msg = "<h1 style='color:red'>激活失败</h1>";
                }
                response.setContentType("text/html;charset=utf-8");
                try {
                    response.getWriter().write(msg);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    
    
    }
    
    
    
    

    退出

    package org.island.controller;
    
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.Lian;
    import org.island.bean.ResultInfo;
    import org.island.bean.User;
    import org.island.dao.UserDao;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.Objects;
    
    @Controller
    @RequestMapping("/exit")
    public class ExitController {
        @RequestMapping("/exit")
        public void checkName(User g, HttpServletRequest request, HttpServletResponse response) {
            request.getSession().invalidate();
            try {
                response.sendRedirect(request.getContextPath()+"/login.html");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
    
    }
    
    

    头部信息

    package org.island.controller;
    
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.JedisUtil;
    import org.island.Utils.Lian;
    import org.island.bean.Category;
    import org.island.bean.ResultInfo;
    import org.island.bean.User;
    import org.island.dao.ListDao;
    import org.island.dao.UserDao;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import redis.clients.jedis.Jedis;
    import redis.clients.jedis.Tuple;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Objects;
    import java.util.Set;
    
    @Controller
    @RequestMapping("/header")
    public class HeaderController {
        @RequestMapping("/find_name")
        public void checkName(HttpServletRequest request, HttpServletResponse response) {
            System.out.println("查找用户名的请求收到了");
            User user = (User) request.getSession().getAttribute("user");
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
                mapper.writeValue(response.getOutputStream(), user);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        @RequestMapping("/find_list")
        public void find_list(HttpServletRequest request, HttpServletResponse response) {
            Jedis jedis = JedisUtil.getJedis();
            Set<Tuple> set = jedis.zrangeWithScores("category", 0, -1);
            List<Category> list = null;
            if (set == null || set.size() == 0) {
                SqlSession userDao = Lian.getDao();
                ListDao mapper = userDao.getMapper(ListDao.class);
                list = mapper.findAll();
                //并把从数据库中查询的数据存入到redis中
                for (Category category : list) {
                    //cid作为分数,可以排序
                    jedis.zadd("category", category.getCid(), category.getCname());
                }
                System.out.println(list);
            }else{
                list =new ArrayList<Category>();
                for (Tuple tuple : set) {
                    Category category = new Category();   //把分数,强转成int类型
                    category.setCid((int)(tuple.getScore()));
                    category.setCname(tuple.getElement());
                    list.add(category);
                }
            }
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
               mapper.writeValue(response.getOutputStream(), list);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
    
    
    }
    
    

    路线详情

    package org.island.controller;
    
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.JedisUtil;
    import org.island.Utils.Lian;
    import org.island.bean.*;
    import org.island.dao.ListDao;
    import org.island.dao.RouteDao;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import redis.clients.jedis.Jedis;
    import redis.clients.jedis.Tuple;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Set;
    
    @Controller
    @RequestMapping("/shop")
    public class ShopController {
        @RequestMapping("/find_shop")
        public void checkName(HttpServletRequest request, HttpServletResponse response) {
            String cidStr = request.getParameter("rid");
            Integer rid = Integer.parseInt(cidStr);
            SqlSession sqlSession = Lian.getDao();
            RouteDao routeDao = sqlSession.getMapper(RouteDao.class);
            Route rount = routeDao.findRount(rid);
            List<RouteImg> image = routeDao.findImage(rid);
            Seller seller = routeDao.findSeller(rid);
            rount.setRouteImgList(image);
            rount.setSeller(seller);
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
                mapper.writeValue(response.getOutputStream(), rount);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
    }
    
    

    收藏

    package org.island.controller;
    
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.Lian;
    import org.island.bean.*;
    import org.island.dao.FavDao;
    import org.island.dao.RouteDao;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.Date;
    import java.util.List;
    
    @Controller
    @RequestMapping("/fav")
    public class FavController {
        @RequestMapping("/check")
        public void checkName(HttpServletRequest request, HttpServletResponse response) {
            String ridStr = request.getParameter("rid");
            System.out.println(ridStr);
            int rid = 0;
            if (ridStr != null && ridStr.length() > 0 && !ridStr.equals("undefined")) {
                rid = Integer.parseInt(ridStr);
            }
            User user = (User) request.getSession().getAttribute("user");
            System.out.println(user);
            int uid = 0;
            if (user != null) {
                uid = user.getUid();
            }
            SqlSession sqlSession = Lian.getDao();
            FavDao favDao = sqlSession.getMapper(FavDao.class);
            Favorite favorite = favDao.fAll(uid, rid);
            boolean flag = (favorite != null);
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
                mapper.writeValue(response.getOutputStream(), flag);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        @RequestMapping("/add_fav")
        public void add_fav(HttpServletRequest request, HttpServletResponse response) {
            String ridStr = request.getParameter("rid");
            int rid = 0;
            if (ridStr != null && ridStr.length() > 0 && !ridStr.equals("undefined")) {
                rid = Integer.parseInt(ridStr);
            }
            User user = (User) request.getSession().getAttribute("user");
            int uid = 0;
            if (user != null) {
                uid = user.getUid();
            } else {
                return;
            }
            SqlSession sqlSession = Lian.getDao();
            FavDao favDao = sqlSession.getMapper(FavDao.class);
            favDao.add(rid, new Date(), uid);
            sqlSession.commit();
            sqlSession.close();
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
                mapper.writeValue(response.getOutputStream(), true);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        @RequestMapping("/delete_fav")
        public void delete_fav(HttpServletRequest request, HttpServletResponse response) {
            String ridStr = request.getParameter("rid");
            int rid = 0;
            if (ridStr != null && ridStr.length() > 0 && !ridStr.equals("undefined")) {
                rid = Integer.parseInt(ridStr);
            }
            User user = (User) request.getSession().getAttribute("user");
            int uid = 0;
            if (user != null) {
                uid = user.getUid();
            } else {
                return;
            }
            SqlSession sqlSession = Lian.getDao();
            FavDao favDao = sqlSession.getMapper(FavDao.class);
            favDao.del(uid,rid );
            sqlSession.commit();
            sqlSession.close();
            ObjectMapper mapper = new ObjectMapper();
            response.setContentType("application/json;charset=utf-8");
            try {
                mapper.writeValue(response.getOutputStream(), true);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    
    

    验证码

    package org.island.controller;
    
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.apache.ibatis.session.SqlSession;
    import org.island.Utils.Lian;
    import org.island.bean.ResultInfo;
    import org.island.bean.User;
    import org.island.dao.UserDao;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.util.Objects;
    
    @Controller
    @RequestMapping("/frr")
    public class CheckController {
        @RequestMapping("/chec")
        public void checkName(User g, HttpServletRequest request, HttpServletResponse response) {
            boolean flag=true;
            User user = (User) request.getSession().getAttribute("user");
            if (user == null) {
                flag=false;
            }
            ObjectMapper mapper = new ObjectMapper();
            try {
                mapper.writeValue(response.getOutputStream(), flag);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        @RequestMapping("/check")
        public void check_code(String check, HttpServletRequest request, HttpServletResponse response) {
            String userCheckCode = String.valueOf(request.getSession().getAttribute("CHECKCODE_SERVER"));
            ObjectMapper mapper = new ObjectMapper();
            request.getSession().removeAttribute("CHECKCODE_SERVER");
            ResultInfo resultInfo = new ResultInfo();
            if (Objects.equals(userCheckCode, "") || !userCheckCode.equalsIgnoreCase(check)) {
                resultInfo.setFlag(false);
                resultInfo.setErrorMsg("验证码错误");
                String json = null;
                try {
                    json = mapper.writeValueAsString(resultInfo);
                    response.setContentType("application/json;chartset=utf-8");
                    response.getWriter().write(json);
                } catch (IOException e) {
                    e.printStackTrace();
                }
    
            } else {
                resultInfo.setFlag(true);
                String json = null;
                try {
                    json = mapper.writeValueAsString(resultInfo);
                    response.setContentType("application/json;chartset=utf-8");
                    response.getWriter().write(json);
                } catch (IOException e) {
                    e.printStackTrace();
                }
    
            }
    
    
        }
    
    }
    
    

    验证码添加

    package org.island.controller;
    
    import javax.imageio.ImageIO;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.util.Random;
    
    /**
     * 验证码
     */
    @WebServlet("/checkCode")
    public class CheckCodeServlet extends HttpServlet {
    	public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
    		
    		//服务器通知浏览器不要缓存
    		response.setHeader("pragma","no-cache");
    		response.setHeader("cache-control","no-cache");
    		response.setHeader("expires","0");
    		
    		//在内存中创建一个长80,宽30的图片,默认黑色背景
    		//参数一:长
    		//参数二:宽
    		//参数三:颜色
    		int width = 80;
    		int height = 30;
    		BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
    		
    		//获取画笔
    		Graphics g = image.getGraphics();
    		//设置画笔颜色为灰色
    		g.setColor(Color.GRAY);
    		//填充图片
    		g.fillRect(0,0, width,height);
    		
    		//产生4个随机验证码,12Ey
    		String checkCode = getCheckCode();
    		//将验证码放入HttpSession中
    		request.getSession().setAttribute("CHECKCODE_SERVER",checkCode);
    		
    		//设置画笔颜色为黄色
    		g.setColor(Color.YELLOW);
    		//设置字体的小大
    		g.setFont(new Font("黑体",Font.BOLD,24));
    		//向图片上写入验证码
    		g.drawString(checkCode,15,25);
    		
    		//将内存中的图片输出到浏览器
    		//参数一:图片对象
    		//参数二:图片的格式,如PNG,JPG,GIF
    		//参数三:图片输出到哪里去
    		ImageIO.write(image,"PNG",response.getOutputStream());
    	}
    	/**
    	 * 产生4位随机字符串 
    	 */
    	private String getCheckCode() {
    		String base = "0123456789ABCDEFGabcdefg";
    		int size = base.length();
    		Random r = new Random();
    		StringBuffer sb = new StringBuffer();
    		for(int i=1;i<=4;i++){
    			//产生0到size-1的随机值
    			int index = r.nextInt(size);
    			//在base字符串中获取下标为index的字符
    			char c = base.charAt(index);
    			//将c放入到StringBuffer中去
    			sb.append(c);
    		}
    		return sb.toString();
    	}
    	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		this.doGet(request,response);
    	}
    }
    
    
    
    
    

    dao接口

    user

    package org.island.dao;
    
    
    import org.apache.ibatis.annotations.Insert;
    import org.apache.ibatis.annotations.Param;
    import org.apache.ibatis.annotations.Select;
    import org.apache.ibatis.annotations.Update;
    import org.island.bean.User;
    
    
    import java.util.List;
    
    public interface UserDao {
        @Select("select * from tab_user")
        List<User> findAll();
    
        @Select("select * from tab_user where username=#{username}")
        User find(@Param("username") String username);
    
        @Select("select * from tab_user where code=#{code}")
        User findCode(@Param("code") String code);
    
        /*   uid,  username, password,name,birthday,sex,telephone,email,status,code*/
        @Insert("insert into tab_user(username, password,name,birthday,sex,telephone,email,status,code) values(#{username},#{password},#{name},#{birthday},#{sex},#{telephone},#{email},#{status},#{code})")
        void saveUser(User user);
    
    
    
        @Update("update tab_user set status=#{status} where username=#{username}")
        void update(@Param("status") String status, @Param("username") String username);
    }
    
    

    路线

    package org.island.dao;
    
    
    import org.apache.ibatis.annotations.Param;
    import org.apache.ibatis.annotations.Select;
    import org.island.bean.Category;
    import org.island.bean.Route;
    import org.island.bean.RouteImg;
    import org.island.bean.Seller;
    
    import java.util.List;
    
    public interface RouteDao {
        @Select("select * from tab_route")
        List<Route> findAll();
    
    
        @Select("select count(*) from tab_route where cid=#{cid}")
        Integer findCount(@Param("cid") Integer cid);
    
        @Select("select count(*) from tab_route where cid=#{cid}  and rname like #{rname}")
        Integer findFind(@Param("cid") Integer cid,@Param("rname") String rname);
    
        @Select("select * from tab_route where rid=#{rid}")
        Route findRount(@Param("rid") Integer rid);
    
        @Select("select * from tab_route_img where rid=#{rid}")
        List<RouteImg>  findImage(@Param("rid") Integer rid);
    
        @Select("select * from tab_seller where sid=#{sid}")
        Seller findSeller(@Param("sid") Integer sid);
    
        @Select("select * from tab_route  where cid=#{cid}  and rname like #{rname}")
        List<Route> findF(@Param("cid") Integer cid,@Param("rname") String rname);
    
        @Select("select * from tab_route where cid=#{cid} limit #{first},#{last}")
        List<Route> findPart(@Param("cid") Integer id,@Param("first") Integer first,@Param("last") Integer last);
    }
    
    

    信息

    package org.island.dao;
    
    
    import org.apache.ibatis.annotations.Insert;
    import org.apache.ibatis.annotations.Param;
    import org.apache.ibatis.annotations.Select;
    import org.apache.ibatis.annotations.Update;
    import org.island.bean.Category;
    import org.island.bean.User;
    
    import java.util.List;
    
    public interface ListDao {
        @Select("select * from tab_category")
        List<Category> findAll();
    
    
    }
    
    

    收藏

    package org.island.dao;
    
    
    import org.apache.ibatis.annotations.Delete;
    import org.apache.ibatis.annotations.Insert;
    import org.apache.ibatis.annotations.Param;
    import org.apache.ibatis.annotations.Select;
    import org.island.bean.Category;
    import org.island.bean.Favorite;
    
    import java.util.Date;
    import java.util.List;
    
    public interface FavDao {
        @Select("select * from tab_favorite where uid=#{uid} and rid=#{rid}")
        Favorite fAll(@Param("uid") Integer uid,@Param("rid") Integer rid);
    
        @Delete("delete  from tab_favorite where uid=#{uid} and rid=#{rid}")
        void del(@Param("uid") Integer uid,@Param("rid") Integer rid);
    
        @Select("select count(*) from tab_favorite where rid=#{rid}")
        Integer favR(@Param("rid") Integer rid);
    
        @Insert( "insert into tab_favorite values(#{rid},#{date},#{uid})")
        void add(@Param("rid") Integer rid, @Param("date") Date date, @Param("uid") Integer uid);
    }
    
    

    工具类

    分页

    package org.island.bean;
    
    import java.util.List;
    
    public class PageBean_new<T> {
        //private List<T> pageData;
        private List<T> list; //对象记录结果集
        private int total = 0; // 总记录数
        private int limit = 10; // 每页显示记录数
        private int pages = 1; // 总页数
        private int pageNumber = 1; // 当前页
    
        private boolean isFirstPage = false;        //是否为第一页
        private boolean isLastPage = false;         //是否为最后一页
        private boolean hasPreviousPage = false;   //是否有前一页
        private boolean hasNextPage = false;       //是否有下一页
    
        private int navigatePages = 10; //导航页码数
        private int[] navigatePageNumbers;  //所有导航页号
    
        public PageBean_new(int total, int pageNumber) {
            init(total, pageNumber, limit);
        }
    
        public PageBean_new(int total, int pageNumber, int limit) {
            init(total, pageNumber, limit);
        }
    
        private void init(int total, int pageNumber, int limit) {
            //设置基本参数
            this.total = total;
            this.limit = limit;
            this.pages = (this.total - 1) / this.limit + 1;
    
            //根据输入可能错误的当前号码进行自动纠正
            if (pageNumber < 1) {
                this.pageNumber = 1;
            } else if (pageNumber > this.pages) {
                this.pageNumber = this.pages;
            } else {
                this.pageNumber = pageNumber;
            }
    
            //基本参数设定之后进行导航页面的计算
            calcNavigatePageNumbers();
    
            //以及页面边界的判定
            judgePageBoudary();
        }
    
        /**
         * 计算导航页
         */
        private void calcNavigatePageNumbers() {
            //当总页数小于或等于导航页码数时
            if (pages <= navigatePages) {
                navigatePageNumbers = new int[pages];
                for (int i = 0; i < pages; i++) {
                    navigatePageNumbers[i] = i + 1;
                }
            } else { //当总页数大于导航页码数时
                navigatePageNumbers = new int[navigatePages];
                int startNum = pageNumber - navigatePages / 2;
                int endNum = pageNumber + navigatePages / 2;
    
                if (startNum < 1) {
                    startNum = 1;
                    //(最前navigatePages页
                    for (int i = 0; i < navigatePages; i++) {
                        navigatePageNumbers[i] = startNum++;
                    }
                } else if (endNum > pages) {
                    endNum = pages;
                    //最后navigatePages页
                    for (int i = navigatePages - 1; i >= 0; i--) {
                        navigatePageNumbers[i] = endNum--;
                    }
                } else {
                    //所有中间页
                    for (int i = 0; i < navigatePages; i++) {
                        navigatePageNumbers[i] = startNum++;
                    }
                }
            }
        }
    
        /**
         * 判定页面边界
         */
        private void judgePageBoudary() {
            isFirstPage = pageNumber == 1;
            isLastPage = pageNumber == pages && pageNumber != 1;
            hasPreviousPage = pageNumber > 1;
            hasNextPage = pageNumber < pages;
        }
    
    
        public void setList(List<T> list) {
            this.list = list;
        }
    
        /**
         * 得到当前页的内容
         *
         * @return {List}
         */
        public List<T> getList() {
            return list;
        }
    
        /**
         * 得到记录总数
         *
         * @return {int}
         */
        public int getTotal() {
            return total;
        }
    
        /**
         * 得到每页显示多少条记录
         *
         * @return {int}
         */
        public int getLimit() {
            return limit;
        }
    
        /**
         * 得到页面总数
         *
         * @return {int}
         */
        public int getPages() {
            return pages;
        }
    
        /**
         * 得到当前页号
         *
         * @return {int}
         */
        public int getPageNumber() {
            return pageNumber;
        }
    
    
        /**
         * 得到所有导航页号
         *
         * @return {int[]}
         */
        public int[] getNavigatePageNumbers() {
            return navigatePageNumbers;
        }
    
        public boolean isFirstPage() {
            return isFirstPage;
        }
    
        public boolean isLastPage() {
            return isLastPage;
        }
    
        public boolean hasPreviousPage() {
            return hasPreviousPage;
        }
    
        public boolean hasNextPage() {
            return hasNextPage;
        }
    
        public String toString() {
            StringBuffer sb = new StringBuffer();
            sb.append("[")
                    .append("total=").append(total)
                    .append(",pages=").append(pages)
                    .append(",pageNumber=").append(pageNumber)
                    .append(",limit=").append(limit)
                    .append(",isFirstPage=").append(isFirstPage)
                    .append(",isLastPage=").append(isLastPage)
                    .append(",hasPreviousPage=").append(hasPreviousPage)
                    .append(",hasNextPage=").append(hasNextPage)
                    .append(",navigatePageNumbers=");
            int len = navigatePageNumbers.length;
            if (len > 0) sb.append(navigatePageNumbers[0]);
            for (int i = 1; i < len; i++) {
                sb.append(" " + navigatePageNumbers[i]);
            }
            sb.append(",list.size=" + list.size());
            sb.append("]");
            return sb.toString();
        }
    }
    
    
    /*
    * 关于用法:使用步骤如下:
    1).不管是否用了条件查询,首先count出相应的总条数
    2).构造一个Pager类(关于limit参数可根据自身前台进行取舍)
    3).根据构造好的Pager类获取已经自动纠正过的pageNumber参数,-1再乘个limit,做为实际要查询的第一条记录的位置
    4).设置要查从起始位置开始,直到第limit条的所有记录.(如果手工分页,则也有可能第二个参数是结尾记录的位置偏移,具体情况视数据库而定)
    5).将[条件]查询出的list设置入pager对象中并返回.
    6).在展现层通过Servlet或Action或直接拿到这个pager对象即可使用,具体如何拼接url的事情,也应该交由展现层来完成即可。
    *
    * */
    

    JedisUtils

    package org.island.Utils;
    
    import redis.clients.jedis.Jedis;
    import redis.clients.jedis.JedisPool;
    import redis.clients.jedis.JedisPoolConfig;
    
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Properties;
    
    /**
     * Jedis工具类
     */
    public final class JedisUtil {
        private static JedisPool jedisPool;
    
        static {
            //读取配置文件
            InputStream is = JedisPool.class.getClassLoader().getResourceAsStream("jedis.properties");
            //创建Properties对象
            Properties pro = new Properties();
            //关联文件
            try {
                pro.load(is);
            } catch (IOException e) {
                e.printStackTrace();
            }
            //获取数据,设置到JedisPoolConfig中
            JedisPoolConfig config = new JedisPoolConfig();
            config.setMaxTotal(Integer.parseInt(pro.getProperty("maxTotal")));
            config.setMaxIdle(Integer.parseInt(pro.getProperty("maxIdle")));
    
            //初始化JedisPool
            jedisPool = new JedisPool(config, pro.getProperty("host"), Integer.parseInt(pro.getProperty("port")));
    
    
        }
    
    
        /**
         * 获取连接方法
         */
        public static Jedis getJedis() {
            return jedisPool.getResource();
        }
    
        /**
         * 关闭Jedis
         */
        public static void close(Jedis jedis) {
            if (jedis != null) {
                jedis.close();
            }
        }
    }
    
    

    sqlsession

    package org.island.Utils;
    
    import org.apache.ibatis.io.Resources;
    import org.apache.ibatis.session.SqlSession;
    import org.apache.ibatis.session.SqlSessionFactory;
    import org.apache.ibatis.session.SqlSessionFactoryBuilder;
    
    import java.io.IOException;
    import java.io.InputStream;
    
    public class Lian {
        public static SqlSession getDao() {
            InputStream in = null;
            try {
                in = Resources.getResourceAsStream("SqlMapConfig.xml");
            } catch (IOException e) {
                e.printStackTrace();
            }
            SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(in);
            SqlSession sqlSession = factory.openSession();
            return sqlSession;
        }
    }
    
    

    MD5

    package org.island.Utils;
    
    import java.security.MessageDigest;
    
    /**
     * 写一个MD5算法,运行结果与MySQL的md5()函数相同
     * 将明文密码转成MD5密码
     * 123456->e10adc3949ba59abbe56e057f20f883e
     */
    public final class Md5Util {
    	private Md5Util(){}
    	/**
    	 * 将明文密码转成MD5密码 
    	 */
    	public static String encodeByMd5(String password) throws Exception{
    		//Java中MessageDigest类封装了MD5和SHA算法,今天我们只要MD5算法
    		MessageDigest md5 = MessageDigest.getInstance("MD5");
    		//调用MD5算法,即返回16个byte类型的值
    		byte[] byteArray = md5.digest(password.getBytes());
    		//注意:MessageDigest只能将String转成byte[],接下来的事情,由我们程序员来完成
    		return byteArrayToHexString(byteArray);
    	}
    	/**
    	 * 将byte[]转在16进制字符串 
    	 */
    	private static String byteArrayToHexString(byte[] byteArray) {
    		StringBuffer sb = new StringBuffer();
    		//遍历
    		for(byte b : byteArray){//16次
    			//取出每一个byte类型,进行转换
    			String hex = byteToHexString(b);
    			//将转换后的值放入StringBuffer中
    			sb.append(hex);
    		}
    		return sb.toString();
    	}
    	/**
    	 * 将byte转在16进制字符串 
    	 */
    	private static String byteToHexString(byte b) {//-31转成e1,10转成0a,。。。
    		//将byte类型赋给int类型
    		int n = b;
    		//如果n是负数
    		if(n < 0){
    			//转正数
    			//-31的16进制数,等价于求225的16进制数 
    			n = 256 + n;
    		}
    		//商(14),数组的下标
    		int d1 = n / 16;
    		//余(1),数组的下标
    		int d2 = n % 16;
    		//通过下标取值
    		return hex[d1] + hex[d2];
    	}
    	private static String[] hex = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
    	/**
    	 * 测试
    	 */
    	public static void main(String[] args) throws Exception{
    		String password = "123456";
    		String passwordMD5 = Md5Util.encodeByMd5(password);
    		System.out.println(password);
    		System.out.println(passwordMD5);
    	}
    }
    
    

    UUID

    package org.island.Utils;
    
    import java.util.UUID;
    
    /**
     * 产生UUID随机字符串工具类
     */
    public final class UuidUtil {
    	private UuidUtil(){}
    	public static String getUuid(){
    		return UUID.randomUUID().toString().replace("-","");
    	}
    	/**
    	 * 测试
    	 */
    	public static void main(String[] args) {
    		System.out.println(UuidUtil.getUuid());
    		System.out.println(UuidUtil.getUuid());
    		System.out.println(UuidUtil.getUuid());
    		System.out.println(UuidUtil.getUuid());
    	}
    }
    
    

    实体类

    旅游分类

    package org.island.bean;
    
    import java.io.Serializable;
    
    /**
     * 分类实体类
     */
    public class Category implements Serializable {
    
        private int cid;//分类id
        private String cname;//分类名称
    
        public Category() {
        }
    
        public Category(int cid, String cname) {
            this.cid = cid;
            this.cname = cname;
        }
    
        @Override
        public String toString() {
            return "Category{" +
                    "cid=" + cid +
                    ", cname='" + cname + '\'' +
                    '}';
        }
    
        public int getCid() {
            return cid;
        }
    
        public void setCid(int cid) {
            this.cid = cid;
        }
    
        public String getCname() {
            return cname;
        }
    
        public void setCname(String cname) {
            this.cname = cname;
        }
    }
    
    

    收藏

    package org.island.bean;
    
    import java.io.Serializable;
    
    /**
     * 收藏实体类
     */
    public class Favorite implements Serializable {
        private Route route;//旅游线路对象
        private String date;//收藏时间
        private User user;//所属用户
    
        /**
         * 无参构造方法
         */
        public Favorite() {
        }
    
        /**
         * 有参构造方法
         * @param route
         * @param date
         * @param user
         */
        public Favorite(Route route, String date, User user) {
                this.route = route;
                this.date = date;
                this.user = user;
        }
    
        public Route getRoute() {
            return route;
        }
    
        public void setRoute(Route route) {
            this.route = route;
        }
    
        public String getDate() {
            return date;
        }
    
        public void setDate(String date) {
            this.date = date;
        }
    
        public User getUser() {
            return user;
        }
    
        public void setUser(User user) {
            this.user = user;
        }
    }
    
    

    前端结果集

    package org.island.bean;
    
    import java.io.Serializable;
    
    /**
     * 用于封装后端返回前端数据对象
     */
    public class ResultInfo implements Serializable {
        private boolean flag;//后端返回结果正常为true,发生异常返回false
        private Object data;//后端返回结果数据对象
        private String errorMsg;//发生异常的错误消息
    
        //无参构造方法
        public ResultInfo() {
        }
        public ResultInfo(boolean flag) {
            this.flag = flag;
        }
        /**
         * 有参构造方法
         * @param flag
         * @param errorMsg
         */
        public ResultInfo(boolean flag, String errorMsg) {
            this.flag = flag;
            this.errorMsg = errorMsg;
        }
        /**
         * 有参构造方法
         * @param flag
         * @param data
         * @param errorMsg
         */
        public ResultInfo(boolean flag, Object data, String errorMsg) {
            this.flag = flag;
            this.data = data;
            this.errorMsg = errorMsg;
        }
    
        public boolean isFlag() {
            return flag;
        }
    
        public void setFlag(boolean flag) {
            this.flag = flag;
        }
    
        public Object getData() {
            return data;
        }
    
        public void setData(Object data) {
            this.data = data;
        }
    
        public String getErrorMsg() {
            return errorMsg;
        }
    
        public void setErrorMsg(String errorMsg) {
            this.errorMsg = errorMsg;
        }
    }
    
    

    路线

    package org.island.bean;
    
    import java.io.Serializable;
    import java.util.List;
    
    /**
     * 旅游线路商品实体类
     */
    public class Route implements Serializable {
    
        private int rid;//线路id,必输
        private String rname;//线路名称,必输
        private double price;//价格,必输
        private String routeIntroduce;//线路介绍
        private String rflag;   //是否上架,必输,0代表没有上架,1代表是上架
        private String rdate;   //上架时间
        private String isThemeTour;//是否主题旅游,必输,0代表不是,1代表是
        private int count;//收藏数量
        private int cid;//所属分类,必输
        private String rimage;//缩略图
        private int sid;//所属商家
        private String sourceId;//抓取数据的来源id
    
        private Category category;//所属分类
        private Seller seller;//所属商家
        private List<RouteImg> routeImgList;//商品详情图片列表
    
        /**
         * 无参构造方法
         */
        public Route() {
        }
    
        /**
         * 有参构造方法
         *
         * @param rid
         * @param rname
         * @param price
         * @param routeIntroduce
         * @param rflag
         * @param rdate
         * @param isThemeTour
         * @param count
         * @param cid
         * @param rimage
         * @param sid
         * @param sourceId
         */
        public Route(int rid, String rname, double price, String routeIntroduce, String rflag, String rdate, String isThemeTour, int count, int cid, String rimage, int sid, String sourceId) {
            this.rid = rid;
            this.rname = rname;
            this.price = price;
            this.routeIntroduce = routeIntroduce;
            this.rflag = rflag;
            this.rdate = rdate;
            this.isThemeTour = isThemeTour;
            this.count = count;
            this.cid = cid;
            this.rimage = rimage;
            this.sid = sid;
            this.sourceId = sourceId;
        }
    
        @Override
        public String toString() {
            return "Route{" +
                    "rid=" + rid +
                    ", rname='" + rname + '\'' +
                    ", price=" + price +
                    ", routeIntroduce='" + routeIntroduce + '\'' +
                    ", rflag='" + rflag + '\'' +
                    ", rdate='" + rdate + '\'' +
                    ", isThemeTour='" + isThemeTour + '\'' +
                    ", count=" + count +
                    ", cid=" + cid +
                    ", rimage='" + rimage + '\'' +
                    ", sid=" + sid +
                    ", sourceId='" + sourceId + '\'' +
                    ", category=" + category +
                    ", seller=" + seller +
                    ", routeImgList=" + routeImgList +
                    '}';
        }
    
        public List<RouteImg> getRouteImgList() {
            return routeImgList;
        }
    
        public void setRouteImgList(List<RouteImg> routeImgList) {
            this.routeImgList = routeImgList;
        }
    
        public Category getCategory() {
            return category;
        }
    
        public void setCategory(Category category) {
            this.category = category;
        }
    
        public Seller getSeller() {
            return seller;
        }
    
        public void setSeller(Seller seller) {
            this.seller = seller;
        }
    
        public String getSourceId() {
            return sourceId;
        }
    
        public void setSourceId(String sourceId) {
            this.sourceId = sourceId;
        }
    
        public int getRid() {
            return rid;
        }
    
        public void setRid(int rid) {
            this.rid = rid;
        }
    
        public String getRname() {
            return rname;
        }
    
        public void setRname(String rname) {
            this.rname = rname;
        }
    
        public double getPrice() {
            return price;
        }
    
        public void setPrice(double price) {
            this.price = price;
        }
    
        public String getRouteIntroduce() {
            return routeIntroduce;
        }
    
        public void setRouteIntroduce(String routeIntroduce) {
            this.routeIntroduce = routeIntroduce;
        }
    
        public String getRflag() {
            return rflag;
        }
    
        public void setRflag(String rflag) {
            this.rflag = rflag;
        }
    
        public String getRdate() {
            return rdate;
        }
    
        public void setRdate(String rdate) {
            this.rdate = rdate;
        }
    
        public String getIsThemeTour() {
            return isThemeTour;
        }
    
        public void setIsThemeTour(String isThemeTour) {
            this.isThemeTour = isThemeTour;
        }
    
        public int getCount() {
            return count;
        }
    
        public void setCount(int count) {
            this.count = count;
        }
    
        public int getCid() {
            return cid;
        }
    
        public void setCid(int cid) {
            this.cid = cid;
        }
    
        public String getRimage() {
            return rimage;
        }
    
        public void setRimage(String rimage) {
            this.rimage = rimage;
        }
    
        public int getSid() {
            return sid;
        }
    
        public void setSid(int sid) {
            this.sid = sid;
        }
    }
    
    

    路线图

    package org.island.bean;
    
    import java.io.Serializable;
    
    /**
     * 旅游线路图片实体类
     */
    public class RouteImg implements Serializable {
        private int rgid;//商品图片id
        private int rid;//旅游商品id
        private String bigPic;//详情商品大图
        private String smallPic;//详情商品小图
    
        @Override
        public String toString() {
            return "RouteImg{" +
                    "rgid=" + rgid +
                    ", rid=" + rid +
                    ", bigPic='" + bigPic + '\'' +
                    ", smallPic='" + smallPic + '\'' +
                    '}';
        }
    
        /**
         * 无参构造方法
         */
        public RouteImg() {
        }
    
        /**
         * 有参构造方法
         * @param rgid
         * @param rid
         * @param bigPic
         * @param smallPic
         */
        public RouteImg(int rgid, int rid, String bigPic, String smallPic) {
            this.rgid = rgid;
            this.rid = rid;
            this.bigPic = bigPic;
            this.smallPic = smallPic;
        }
    
        public int getRgid() {
            return rgid;
        }
    
        public void setRgid(int rgid) {
            this.rgid = rgid;
        }
    
        public int getRid() {
            return rid;
        }
    
        public void setRid(int rid) {
            this.rid = rid;
        }
    
        public String getBigPic() {
            return bigPic;
        }
    
        public void setBigPic(String bigPic) {
            this.bigPic = bigPic;
        }
    
        public String getSmallPic() {
            return smallPic;
        }
    
        public void setSmallPic(String smallPic) {
            this.smallPic = smallPic;
        }
    }
    
    

    旅游社

    package org.island.bean;
    
    import java.io.Serializable;
    
    /**
     * 商家实体类
     */
    public class Seller implements Serializable {
        private int sid;//商家id
        private String sname;//商家名称
        private String consphone;//商家电话
        private String address;//商家地址
    
        @Override
        public String toString() {
            return "Seller{" +
                    "sid=" + sid +
                    ", sname='" + sname + '\'' +
                    ", consphone='" + consphone + '\'' +
                    ", address='" + address + '\'' +
                    '}';
        }
    
        /**
         * 无参构造方法
         */
        public Seller(){}
    
        /**
         * 构造方法
         * @param sid
         * @param sname
         * @param consphone
         * @param address
         */
        public Seller(int sid, String sname, String consphone, String address) {
            this.sid = sid;
            this.sname = sname;
            this.consphone = consphone;
            this.address = address;
        }
    
        public int getSid() {
            return sid;
        }
    
        public void setSid(int sid) {
            this.sid = sid;
        }
    
        public String getSname() {
            return sname;
        }
    
        public void setSname(String sname) {
            this.sname = sname;
        }
    
        public String getConsphone() {
            return consphone;
        }
    
        public void setConsphone(String consphone) {
            this.consphone = consphone;
        }
    
        public String getAddress() {
            return address;
        }
    
        public void setAddress(String address) {
            this.address = address;
        }
    }
    
    

    用户

    package org.island.bean;
    
    import java.io.Serializable;
    
    /**
     * 用户实体类
     */
    public class User implements Serializable {
        private int uid;//用户id
        private String username;//用户名,账号
        private String password;//密码
        private String name;//真实姓名
        private String birthday;//出生日期
        private String sex;//男或女
        private String telephone;//手机号
        private String email;//邮箱
        private String status;//激活状态,Y代表激活,N代表未激活
        private String code;//激活码(要求唯一)
    
        /**
         * 无参构造方法
         */
        public User() {
        }
    
        /**
         * 有参构方法
         *
         * @param uid
         * @param username
         * @param password
         * @param name
         * @param birthday
         * @param sex
         * @param telephone
         * @param email
         * @param status
         * @param code
         */
        public User(int uid, String username, String password, String name, String birthday, String sex, String telephone, String email, String status, String code) {
            this.uid = uid;
            this.username = username;
            this.password = password;
            this.name = name;
            this.birthday = birthday;
            this.sex = sex;
            this.telephone = telephone;
            this.email = email;
            this.status = status;
            this.code = code;
        }
    
        @Override
        public String toString() {
            return "User{" +
                    "uid=" + uid +
                    ", username='" + username + '\'' +
                    ", password='" + password + '\'' +
                    ", name='" + name + '\'' +
                    ", birthday='" + birthday + '\'' +
                    ", sex='" + sex + '\'' +
                    ", telephone='" + telephone + '\'' +
                    ", email='" + email + '\'' +
                    ", status='" + status + '\'' +
                    ", code='" + code + '\'' +
                    '}';
        }
    
        public int getUid() {
            return uid;
        }
    
        public void setUid(int uid) {
            this.uid = uid;
        }
    
        public String getUsername() {
            return username;
        }
    
        public void setUsername(String username) {
            this.username = username;
        }
    
        public String getPassword() {
            return password;
        }
    
        public void setPassword(String password) {
            this.password = password;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public String getBirthday() {
            return birthday;
        }
    
        public void setBirthday(String birthday) {
            this.birthday = birthday;
        }
    
        public String getSex() {
            return sex;
        }
    
        public void setSex(String sex) {
            this.sex = sex;
        }
    
        public String getTelephone() {
            return telephone;
        }
    
        public void setTelephone(String telephone) {
            this.telephone = telephone;
        }
    
        public String getEmail() {
            return email;
        }
    
        public void setEmail(String email) {
            this.email = email;
        }
    
        public String getStatus() {
            return status;
        }
    
        public void setStatus(String status) {
            this.status = status;
        }
    
        public String getCode() {
            return code;
        }
    
        public void setCode(String code) {
            this.code = code;
        }
    }
    
    

    资源文件配置

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd    http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd">
        <!--开启注解扫描-->
        <context:component-scan base-package="org.island">
            <!--配置要忽略的注解扫描,要扫描的是service和dao层的注解,要忽略web层注解,因为web层让SpringMVC框架
    去管理 -->
            <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        </context:component-scan>
        <!--配置连接池,我这里用的c3p0,也可以用其他的连接池-->
        <bean id="dataSource"
              class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.mysql.jdbc.Driver" />
            <property name="url" value="jdbc:mysql://localhost:3309/luodedao" />
            <property name="username" value="root" />
            <property name="password" value="131427" />
        </bean>
        <!--配置SqlSession的工厂 注入连接池-->
        <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sessionFactory">
            <property name="dataSource" ref="dataSource"></property>
            <!--配置实体类的别名扫描 可选-->
            <property name="typeAliasesPackage" value="org.island.bean"/>
        </bean>
        <!--配置AccountDao 所在的包-->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="org.island.dao"></property>
        </bean>
    
        <!--配置事务管理器,传入连接池-->
        <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">
            <property name="dataSource" ref="dataSource"></property>
        </bean>
        <!--配置事务通知-->
        <tx:advice transaction-manager="transactionManager" id="tx">
            <tx:attributes>
                <!--以find开头的方法,用于指定事务是否只读。只有查询方法才能设置为true-->
                <tx:method name="find*" read-only="true"/>
                <!--isolation用于指定事务的隔离级别。默认值是DEFAULT * 表示所有方法-->
                <tx:method name="*" isolation="DEFAULT"></tx:method>
            </tx:attributes>
        </tx:advice>
        <!-- 配置AOP切面产生代理 -->
        <aop:config>
            <aop:advisor advice-ref="tx" pointcut="execution(public * org.island.dao.*.*(..))"/>
        </aop:config>
    </beans>
    
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd">
        <!--只扫描Controller注解,别的注解不扫描-->
        <context:component-scan base-package="org.island">
            <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        </context:component-scan>
    
        <!--    &lt;!&ndash;配置视图解析器&ndash;&gt;
            <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="viewResolver">
                &lt;!&ndash; JSP文件所在的目录 &ndash;&gt;
                <property name="prefix" value="/WEB-INF/main/"></property>
                &lt;!&ndash; 文件的后缀名 &ndash;&gt;
                <property name="suffix" value=".jsp"></property>
            </bean>-->
    
        <!-- 设置静态资源不过滤 -->
        <mvc:resources location="/css/" mapping="/css/**"/>
        <mvc:resources location="/images/" mapping="/images/**"/>
        <mvc:resources location="/img/" mapping="/img/**"/>
        <mvc:resources location="/js/" mapping="/js/**"/>
        <!--<mvc:resources location="/main/" mapping="/main/**"/>
        <mvc:resources location="/WEB-INF/main/" mapping="/WEB-INF/main/**"/>-->
        <!-- 开启对SpringMVC注解的支持 -->
        <mvc:annotation-driven/>
    </beans>
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE configuration
            PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
        <!--   配置properties-->
    <!--    <properties resource="jdbcConfig.properties">
        </properties>-->
        <typeAliases>
            <package name="org.san.bean"/>
        </typeAliases>
        <!--配置环境-->
        <environments default="mysql">
            <!-- 配置mysql的环境-->
            <environment id="mysql">
                <!-- 配置事务 -->
                <transactionManager type="JDBC"/>
    
                <!--配置连接池-->
       <!--         <dataSource type="POOLED">
                    <property name="driver" value="${jdbc.DriverClassName}" />
                    <property name="url" value="${jdbc.url}" />
                    <property name="username" value="${jdbc.username}" />
                    <property name="password" value="${jdbc.password}" />
                </dataSource>-->
                <dataSource type="POOLED">
                    <property name="driver" value="com.mysql.jdbc.Driver" />
                    <property name="url" value="jdbc:mysql://localhost:3309/travel" />
                    <property name="username" value="root" />
                    <property name="password" value="131427" />
                </dataSource>
            </environment>
        </environments>
        <!-- 配置映射文件的位置 -->
        <mappers>
            <package name="org.island.dao"/>
        </mappers>
    </configuration>
    
    展开全文
  • 名师详解大众点评后端代码,Java SSM开发大众点评后端,找了挺久的,可以选择下载
  • 常用后端代码结构

    2021-04-03 12:59:15
    常用后端代码结构 项目常用后端代码结构也就是Controller+Service+Dao,如图所示: 功能 Controller层(流程控制层):接收客户端的请求,然后调用Service层业务逻辑,获取到数据,传递数据给视图层(客户端)用于...
  • **项目常用后端代码结构** 常用后端代码结构 项目常用后端代码结构也就是Controller+Service+Dao 三层的功能划分: Controller层(流程控制层)主要负责具体的业务模块流程的控制 Service层(业务逻辑层)主要负责...
  • 主要介绍了Python生成并下载文件后端代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
  • 跨域问题在开发过程中比较常见,我们可以通过前端使用jsonp来解决,也可以通过后端代码解决。通过后端代码解决方式如下所示: public static void setAllowOrigin(HttpServletRequest request, HttpServletResponse ...
  • 项目常用后端代码

    2021-04-05 14:43:11
    项目常用后端代码 如图所示: Controller 流程控制层:负责业务模块流程控制 Service 业务逻辑层:负责业务逻辑设计 Dao 数据操作层:负责与数据库联系 后面为了方便数据传输,引入常用的entity(实体)和vo(视图)...
  • 主要介绍了基于JavaScript实现大文件上传后端代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 36,521
精华内容 14,608
关键字:

后端代码