Atitit code 范例 example code 范例 example 更好一些,将最佳实践融入其中。。目录第一章 Springboot 1第二章 Rest api 1第一节

Atitit code 范例 example  

 code 范例 example  更好一些,将最佳实践融入其中。。

目录

第一章 Springboot

第二章 Rest api

第一节 Atitit http rest php workman api rsps

第二节 Atitit recv https req post   code  接受https请求 nodejs

第三章 Db query insert updt

第一节 Sprbtjdbc insert

第二节 Hbnt demo

第三节 Mybatis demo

第四节 Db acc code mybatis jsdbtmeplte hbnt

第四章 Httpclient demo

第一节 Java http get

第二节 Jaa http post

第三节 Php http https post json

第四节 Nodejs https http post json

第五章 Io demo

第六章 Other

第一节 ExcelUtil    export json list

  • Springboot

Springboot test,,springboot lazy load

/miniCodePrj/src/main/java/sprbtPKg/Application.java

  • Rest api
    • Atitit http rest php workman api rsps

Php rest api

    • Atitit recv https req post   code  接受https请求 nodejs

  • Db query insert updt
    • Sprbtjdbc insert

public static void main(String[] args) {

// sqlSessionFactory=getSqlSessFctry(dataSource, UserMapper.class);

// tk_ini(sqlSessionFactory);

String driver = "com.mysql.jdbc.Driver";

String url = "jdbc:mysql://localhost:3306/mysql?allowMultiQueries=true"; // 创建一个表示数据库路径的字符串

String username = "root"; // 创建一个表示数据库用户名的字符串

String password = ""; // 创建一个表示数据库密码的字符串

DriverManagerDataSource dataSource = new DriverManagerDataSource(url, username, password);

String tableName = "user";

Map<String, Object> parameters_map = new HashMap<String, Object>(3);

parameters_map.put("id", 123);

parameters_map.put("first_name", "aaa");

int i = insert(dataSource, tableName, parameters_map);

System.out.println(i);

System.out.println("f");

}

private static int insert(DriverManagerDataSource dataSource, String tableName,

Map<String, Object> parameters_map) {

SimpleJdbcInsert SimpleJdbcInsert1 = new SimpleJdbcInsert(dataSource).withTableName(tableName);

Set st = parameters_map.keySet();

List<String> columnNames = new ArrayList<String>();

columnNames.addAll(st);

SimpleJdbcInsert1.setColumnNames(columnNames);

// SimpleJdbcInsert1.usingColumns(columnNames)

int i = SimpleJdbcInsert1.execute(parameters_map);

return i;

}

    • Hbnt demo
    • Mybatis demo
    • Db acc code mybatis jsdbtmeplte hbnt

Hibernate code demo

MybatisTest

  • Httpclient demo
    • Java http get

 

     String uri=rq.getRequestURI();

     String query=rq.getQueryString();     

          String newUrl = targetHost+uri+"?"+query;

CloseableHttpResponse response =HttpClients.createDefault().execute(new HttpGet(newUrl)) ;    

        return EntityUtils.toString(response.getEntity(), "UTF-8");

    • Jaa http post
    • Php http https post json

Atitit php http post jspn code

    • Nodejs https http post json

Nodejs.http post json

const args = process.argv.slice(2)

//var param=args[0];

var param = (new Buffer(args[0], 'base64').toString())

//var param={};

var fs = require('fs');

var cfgObj = JSON.parse(fs.readFileSync('a_cfg.json') + '');

console.log(cfgObj)

var $url = cfgObj['url'];

//"https://7398c09d63b0.ngrok.io/v1/api/order/build";

console.log($url);

console.log(param);

var prmObj = JSON.parse(param);

const axios = require('axios')

//zwajye cyifen json hesh txt...zosh yaosi obj shg json ,zo  head add app/json,,beir  txt ..

axios

    .post($url, prmObj)

    .then(res => {

        //  console.log(`statusCode: ${res.statusCode}`)   //statusCode: undefined

        console.log(res.data);

        //   console.log(res)

    })

    .catch(error => {

        console.error(error)

})

  • Io demo

Atitit 读取文件并处理

Ticyiutxt.php

<?php

$f="d:\ppl";

$con = file($f );

$data = array();

foreach($con as $line) {

    $posStart=stripos($line, "——");

     if($posStart){

        // $line = trim($line);

         $name=  substr($line, $posStart);

         echo $name;

     }else

     {

         echo $line;

     }

}

  • Other
    • ExcelUtil    export json list

Ref

Atitit mybatis helloworld

原文地址:https://www.cnblogs.com/attilax/p/15196792.html