• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

    CompanyManager: 年久失修的项目~

    原作者: [db:作者] 来自: 网络 收藏 邀请

    开源软件名称:

    CompanyManager

    开源软件地址:

    https://gitee.com/xi_fan/CompanyManager

    开源软件介绍:

    CompanyManager项目简介

    技术方案

    • 项目管理:maven
    • 框架:spring、springmvc、mybatis、easyui
    • 数据:mysql

    主要用途实现了用户管理、菜单管理、部门管理、理财管理、理财报表、待办管理、字典管理等多个功能,可作为有具体需要的朋友提供参考的demo,也可作为新手学习的demo。

    用户管理板块

    需求说明:

    • 该项目的使用角色可分为三个:分别为一般用户、系统管理员、超级管理员;
    • 权限管理:超级管理员具有所有的权限,包括添加、修改、删除系统管理员等权限,而系统管理员具有管理一般用户的权限,遵守现实中上级管理下级的原则。

    用户管理板块具体实现:

    • 1、先从dao层说起:在cn.springmvc.dao中搭建好UserInfoDao,该类是一个接口,中包含着对user相关信息的增删查改。具体的可看项目中cn.springmvc.dao.UserInfoDao的实现
    • 2 、在对应的目录下配置好UserInfoDao的Mapper映射文件,实现具体函数在mybatis中实现对Mysql的操作。具体的可看项目中cn.springmvc.dao.UserInfoMapper的实现
    • 3 、在cn.springmvc.service中搭建好对应的service接口,并在cn.springmvc.service.impl中实现具体的service层功能。具体的可看项目中cn.springmvc.service.impl.UserInfoServiceImpl的实现
    • 4 、在cn.springmvc.controller中实现对应的控制器具体的可看项目中cn.springmvc.service.controller.UserInfoController的实现

    菜单管理板块

    需求说明:

    • 该项目的菜单主要可以分为两种,一是项目系统的菜单,需要编写相应的代码进行连接,二是web的菜单,只要提供链接既可以点击后实现跳转。
    • 主要实现菜单的crud。

    菜单管理板块具体实现:

    • 项目的分层以及具体实现跟用户管理板块类似,可以直接查看源码。

    在这里我要谈谈我是如何进行mybatis的物理分页的:

    学过mybatis的都知道,mybatis使用RowBounds实现的分页是逻辑分页,也就是先把数据记录全部查询出来,然在再根据offset和limit截断记录返回为了在数据库层面上实现物理分页,如果我们不想改变原来MyBatis的函数逻辑,又实现物理分页,可以编写plugin截获MyBatis Executorstatementhandler,重写SQL来执行查询。

    那么我是如何在整个项目中进行实现的呢?

    我所做的就是在view层、controller层以及Model层三个层中传递一个PageInfo对象,该对象绑定着分页的信息。

    在controller层:

     @RequestMapping(value = "/queryUser") public String queryUser(Model    model,            @ModelAttribute(value = "pageInfo") PageInfo<UserInfo> pageInfo,@ModelAttribute(value = "user") UserInfo userInfo, @ModelAttribute(value = "dept") DeptInfo dept)  {     //实现业务 }

    在service层:将PageInfo打包成RowBounds对象后传给dao层

    public ArrayList<UserInfo> queryUsers(Map<String, String> map,PageInfo<UserInfo> pageInfo) {return userInfoDao.queryUsers(new     RowBounds(pageInfo.getFromRecord(),pageInfo.getPageSize()), map);}

    在mybatis配置文件中配置plugin:interceptor属性指向拦截器;

    <plugins>	<plugin interceptor="cn.springmvc.utildao.PaginationInterceptor" /></plugins>

    而PaginationInterceptor可以查看项目中cn.springmvc.utildao的源码,对于主要实现数据库的CRUD的mapper没有任何变化。

    Note: 其它板块和以上两个差不多,具体的可以查看源码!!!


    在ie以及360兼容模式下出现json数据被浏览器拦截并且直接请求保存的问题:

    在springmvc-servlet文件中添加:

    <!-- json格式配置 --><mvc:annotation-driven>    <mvc:message-converters register-defaults="true">        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">            <property name="supportedMediaTypes">                <list>                    <value>text/html;charset=UTF-8</value>                    <value>application/json;charset=UTF-8</value>                </list>            </property>            <property name="objectMapper">                <bean class="com.fasterxml.jackson.databind.ObjectMapper">                    <property name="serializationInclusion">                        <value type="com.fasterxml.jackson.annotation.JsonInclude.Include">NON_NULL</value>                    </property>                    <!--                     <property name="dateFormat">                        <bean class="java.text.SimpleDateFormat">                            <constructor-arg value="yyyy-MM-dd HH:mm:ss"/>                        </bean>                    </property> -->                </bean>            </property>        </bean>    </mvc:message-converters></mvc:annotation-driven>

    便可以解决该问题。


    Note: 欢迎有兴趣的小伙伴们一起为该项目添加不一样的色彩!!!


    鲜花

    握手

    雷人

    路过

    鸡蛋
    该文章已有0人参与评论

    请发表评论

    全部评论

    专题导读
    热门推荐
    阅读排行榜

    扫描微信二维码

    查看手机版网站

    随时了解更新最新资讯

    139-2527-9053

    在线客服(服务时间 9:00~18:00)

    在线QQ客服
    地址:深圳市南山区西丽大学城创智工业园
    电邮:jeky_zhao#qq.com
    移动电话:139-2527-9053

    Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap