GithubHelp home page GithubHelp logo

workbei-main's Introduction

功倍后台api

基于日事清api后台原有功能扩展的接口,主要扩展的接口有两类:

  1. 日事清api后台未实现的功能
  2. 日事清api后台性能有问题的接口

分层设计

参数传递

  1. VO:客户端自动装箱的对象,对应于页面传值的json,字段一般与客户端请求过来的参数保持一致

  2. DO:service层与dao层进行数据传递的对象,字段一般与数据库表记录严格保持一致

分层

  1. controller(listener)层:
  • controller层接收客户端发送过来的数据,自动封装成VO
  • controller层调用service层时,通过VO进行参数传递。
  • controller层返回VO对象,并自动转换为json格式返回给客户端
  1. service层
  • service接收上层传递的VO参数,进行业务逻辑的判断
  • service调用dao层时,通过DO进行参数传递
  • 返回上层只能返回VO
  1. dao层
  • dao层进行数据库操作时,通过DO进行

注意

  1. 功倍扩展api使用的是springMVC + myBatis的架构,不同于日事清api中grails(springMVC + Hibernate)的架构,因此在日事清api后台中不能开启二级缓存,防止数据库的直接更改不能获取到。

测试

JUnit

使用jUnit4作为基本的测试框架。需要的注释有:

  • @RunWith(SpringJUnit4ClassRunner.class):注明使用的Runner
  • @ContextConfiguration(locations = {"classpath:spring-context.xml"}):注明使用的xml路径
  • @Transactional(transactionManager = "transactionManager"):注明测试时基于事务的
  • @Rollback:注明测试完成后,不保存数据库,而直接回滚数据

其中,可以直接将Test继承BaseUnitTest,这样就继承了@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = {"classpath:spring-context.xml"})

AssertJ

作为语句框架

Mockito

一般情况下,可以直接对数据库操作,不需要mock,如果遇到需要mock的情况,那么就使用Mockito

workbei-main's People

Contributors

wallacemao avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.