办公系统

2018-12-22  本文已影响0人  磊_5d71

报销流程

图片.png

数据库设计

图片.png

项目创建

图片.png

包及全局配置

图片.png

dao配置

<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"
       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">



    <!--开启自动扫描-->
    <context:component-scan base-package="com.alan.oa.dao"></context:component-scan>

    <!--配置数据源-->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
        <property name="url" value="jdbc:mysql://localhost:3306/oa?characterEncoding=utf-8"></property>
        <property name="username" value="root"></property>
        <property name="password" value="root"></property>
    </bean>

    <!--配置session工厂-->
    <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!--关联声明的数据源-->
        <property name="dataSource" ref="dataSource"></property>
        <!--配置别名,entity下的类不需要配置包的全路径-->
        <property name="typeAliasesPackage" value="com.alan.oa.entity"></property>
    </bean>

    <!--配置映射器接口-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactoryBeanName" value="sessionFactory"></property>
        <!--配置接口与映射文件对应,需要放置在dao包里面-->
        <property name="basePackage" value="com.alan.oa.dao"></property>
    </bean>
</beans>

biz配置

<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">


    <!--将dao层的spring配置文件引入进来-->
    <import resource="spring-dao.xml"></import>

    <!--开启自动扫描-->
    <context:component-scan base-package="com.alan.oa.biz"></context:component-scan>
    <!--开启aspectj自动代理-->
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>


    <!--配置声明式事务-->
    <bean id="transationManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"></property>
    </bean>


    <!--声明通知-->
    <tx:advice id="txAdvice" transaction-manager="transationManager">
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
            <tx:method name="find*" read-only="true"/>
            <tx:method name="search*" read-only="true"/>
            <!--其他方法,强制开启事务-->
            <tx:method name="*" propagation="REQUIRED"/>
        </tx:attributes>
    </tx:advice>


    <!--将通知与切入点进行关联-->
    <aop:config>
        <aop:pointcut id="txpc" expression="execution(* com.alan.oa.biz.*.*(..))"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txpc"/>
    </aop:config>
</beans>

WEB配置

<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:mvc="http://www.springframework.org/schema/mvc"
       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/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <import resource="spring-biz.xml"/>
 
    <!--开启自动扫描-->
    <context:component-scan base-package="com.alan.oa.controller"/>
    <mvc:annotation-driven/>

    <!--静态资源交给servlet处理-->
    <mvc:default-servlet-handler/>

    <!--视图转换器-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <!--配置前缀和后缀-->
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
</beans>

部门管理

1、实体类
2、dao接口与sql映射文件
3、biz接口与其实现类
4、控制器
5、页面

通过Spring注解进行格式转换

    @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm")
    private Date dealTime;
上一篇 下一篇

猜你喜欢

热点阅读