1 Star 0 Fork 41

德古拉 / Mars

forked from yuye / Martian 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT


Declarative API programming (DAP) framework

Declarative API programming (DAP)

According to the traditional development method, if you want to develop a back-end interface, you need to divide into the following three steps

  1. Create controller
  2. Create a service
  3. Create dao (and even create xml to store sql)

However, when we write an interface, the focus should be on business logic, which means that our focus should be on the second step, but usually the repeated workload of the first and third steps suffocates us, so I Arranged a bit, formulated a new development method, this new set of development methods is called a declarative API

  1. Write business logic
  2. Declare an API to the front end
  3. Associate API with business logic

So we play like this

Write business logic

interface

public interface TestService {

    <Data type to return> selectList(TestDTO testDTO);
}

Implementation class

@MarsBean("testService")
public class TestServiceImpl implements TestService{

    <Data type to return> selectList(TestDTO testDTO){
        
        // Writing business logic
		
        return data(Just return directly, it will automatically become json);
    }
}

Add two annotations to the super interface of Service

@MarsApi
public interface TestService {

    @MarsReference(beanName = "testService")
    <Data type to return> selectList(TestDTO testDTO);
}

At the core of this set of ideas is to treat the back end as a separate entity and completely separate it from the front end.Back-end write back-end business logic. If the front end needs data, then we declare an interface

What to do next

Seeing this, everyone will definitely have questions, how to call the api on the front end, and how to operate the database on the back end? This requires you to move your fingers and check out my official website

What else can i do

First, the declarative API is a change to the front-end and back-end interaction methods, eliminating the need for a Controller.

In fact, this style is very common in microservices, such as Dubbo's api, Since the microservice interface can use interface to provide external services, we can also use it on the http interface.

In addition to the declarative API, we also provide the following features

  1. Single table operation and fixed sql operation, only one line of annotation is required
  2. Paging only needs to call one method, without any third-party dependencies
  3. Distributed lock requires only one line of annotations
  4. No sqlMapper.xml like Mybatis
  5. Support AOP, IOC, declarative transactions

Official website

http://mars-framework.com

Donation sponsorship

ko-fi

Go to the official website to sponsor

The MIT License (MIT) Copyright 2019, Yuye Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

声明式API编程(DAP) 框架,10秒钟就可以建立一个后端服务接口,我们甚至没有Controller的概念【本机测试,响应时间最低可达9毫秒,吐吞量最高可达1200】 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/voyllente/Mars.git
git@gitee.com:voyllente/Mars.git
voyllente
Mars
Mars
master

搜索帮助