Coder Social home page Coder Social logo

web-lancer's Introduction

web-lancer

What is web-lancer?

web-lancer is a lite framework that allows you to build web interfaces with the minimal work.

Features

  • The sqlTemplate syntax is inherited from mybatis, you can use it with nothing special.
  • Use standard jsonScmema as parameter validation, forget the ugly parameter validation code.
  • Vert.x based web application, you can gain all NIO benefits (however, JDBC with executeBlocking).
  • The web-lancer framework is only for query use, so the update operation is not supported.

Simple Example

application.json
{
  "serverPort": 8080, 
  "dataSources": [
    {
      "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/common_data?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull&useSSL=true",
      "username": "user",
      "password": "*****",
      "driverClassName": "com.mysql.cj.jdbc.Driver",
      "id": "default" // an explicted id is requied!
    }
  ],
  "interfaceDefinitionPath": [
    "/Users/fishzhao/IdeaProjects/web-lancer/conf/interface.json"
  ]
}
interface.json
{
  "dataSourceId": "default",
  "httpMethods": [
    "GET",
    "POST"
  ],
  "uri": "/getKaInfo",
  "parameterValidation": {
    "type": "object",
    "properties": {
      "kaId": {
        "type": "integer"
      },
      "chanWxappScene": {
        "type": "array",
        "items": {
          "type": "integer"
        }
      }
    }
  },
  "parameterScopes": [
    "BODY",
    "QUERY_STRING"
  ],
  // is set to "true", the reseult data will be a json object instead of an array 
  "unwrapArray": false,
  "sqlScriptsSegments": [
    "<script>",
    "select * from channel_wxapp",
    "<where>",
    "<if test=\"kaId != null\">",
    "ka_id = #{kaId}",
    "</if>",
    "<if test=\"chanWxappScene != null\">",
    "AND chan_wxapp_scene in",
    "<foreach item=\"item\" index=\"index\" collection=\"chanWxappScene\" open=\"(\" separator=\",\" close=\")\">",
    "#{item}",
    "</foreach>",
    "</if>",
    "</where>",
    "limit 100",
    "</script>"
  ]
}

To start the web server, use the following command line:

java -jar web-lancer-0.0.1-SNAPSHOT.jar application.json 

then you can make a request to the server:

curl 127.0.0.1:8080/getKaInfo -X POST -d '{"kaId":1106}'

web-lancer's People

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.