Giter Site home page Giter Site logo

l7518597 / mars Goto Github PK

View Code? Open in Web Editor NEW

This project forked from diffblue-benchmarks/yuyenews-mars-java

0.0 1.0 0.0 964 KB

:art: Mars-java is a simple, out-of-the-box Java framework that can help you quickly build a server

Home Page: http://mars-framework.com

License: MIT License

Java 100.00%

mars's Introduction



Declarative API programming (DAP) framework

Program features

1. the declarative API

You only need to add a annotation to the parent interface of your service to provide an interface to the outside world. We also support the traditional Controller

@MarsApi(refBean="The name of the bean to reference")
public interface TestService {

   `Return type` selectList(TestDTO testDTO);
}

2. Single table addition, deletion, modification, and select without SQL

// Query a piece of data based on the primary key
@MarsGet(tableName = "userinfo",primaryKey = "id")
public abstract `Return type` selectById(int id);

// Insert a piece of data
@MarsUpdate(tableName = "userinfo",operType = OperType.INSERT)
public abstract int insert(`Entity object parameter`);

// Delete a piece of data based on the primary key
@MarsUpdate(tableName = "userinfo",operType = OperType.DELETE,primaryKey = "id")
public abstract int delete(int id);

// Modify a piece of data based on the primary key
@MarsUpdate(tableName = "userinfo",operType = OperType.UPDATE,primaryKey = "id")
public abstract int update(`Entity object parameter`);

3. Parameter verification requires only one annotation

Just add a annotation to the field of VO

// Cannot be empty and is 2-3 digits long
@MarsDataCheck(notNull = true,maxLength = 3L,minLength = 2L, msg = "id不可为空且长度必须在2-3位之间")
private Integer id;

// Regular check
@MarsDataCheck(reg = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$",msg = "密码不可以为空且必须是6-12位数字字母组合")
private String password;

How does the front end get prompted?

Just request the API normally. If the verification fails, you will get such a json.

{"error_code":1128,"error_info":"提示文字"}

4. Exception listener

Usually when we write code, we need to add try {} catch () {} to each Controller method, which can be used to return the json string normally when the exception

Spring has an ExecptionHandler to solve this problem, and Mars-java also provides a corresponding solution

The solution is to do nothing, and if something goes wrong, it will automatically return the following json string to the front end

{"error_code":500,"error_info":"异常提示"}

5. One-line annotations to resolve distributed locks

Add RedisLock annotation on the method to be locked

@RedisLock(key = "Define a key yourself")
public int insert(){
  return 1;
}

Other components

At present, this project has its own microservice framework: Mars-cloud, more components will be launched later, and the ultimate goal is to create a useful closed ecosystem

Note: The closed ecology does not mean that it is not open source, but that most of the components are their own and can be well integrated.

Official website

http://mars-framework.com

mars's People

Contributors

erichetti avatar yuyenews avatar

Watchers

 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.