2018-01-30 小程序读取数据库显示二维码

小程序列表参考:http://blog.csdn.net/yelin042/article/details/72625094
Java获取小程序openid:http://blog.csdn.net/bronna/article/details/75347468
小程序微信登录:https://www.jianshu.com/p/6be259f355ee

录取字符串规则

学号+录取编号+姓名首字母
例14020721120180001lsn

Java获取中文拼音、中文首字母缩写和中文首字母:http://blog.csdn.net/u013043346/article/details/50131341
需要的jar:pinyin4j-2.5.0.jar
int转string补0:http://blog.csdn.net/u013991521/article/details/55819876
更正String.format("%06d",12);//其中0表示补零而不是补空格,6表示至少6位
java向数据库中添加数据,更新数据,删除数据:https://www.cnblogs.com/biehongli/p/5988246.html
javaweb请求与响应:http://blog.csdn.net/qq_27602093/article/details/52424001
Markdown 简明教程:https://www.jianshu.com/p/7bd23251da0a

测试代码段Test.java

  • 测试生成二维码QRcode.encode()
QRcode.encode("喵喵喵", "./qr/", "testQR", 400, 400, "png");
  • 测试批量生成二维码QRcode.encode()
        LinkedList list = StuMysql.getStuInfo("0");

        for (int i = 0; i < list.size(); i++)
        {
            String admStr = String.format("%09d", list.get(i).stuId) + String.format("%08d", list.get(i).stuWelNum)
                    + StringHandle.getPinYinHeadChar(list.get(i).stuName);
            System.out.println(admStr);
            String encryptStr = MD5.encrypt(admStr);
            System.out.println(encryptStr);

            String decipherStr = MD5.decipher(encryptStr);
            String stuId = decipherStr.substring(0, 9);
            String enrollId = decipherStr.substring(9, 17);
            String stuName = decipherStr.substring(17, decipherStr.length());
            System.out.println("学号:" + stuId + " 录取编号:" + enrollId + " 姓名:" + stuName);

            QRcode.encode(encryptStr, "./qr/", stuId, 400, 400, "png");

            System.out.println();
        }
  • 测试更新方法StuMysql.updateStuInfo(map)
         Map map = new HashMap();
         map.put("stu_admissionqr",
         "http://localhost:8080/cuz_welcome/qr/140207201.png");
         map.put("stu_homeland", "河南省");
         map.put("stu_id", "140207201");
         int result = StuMysql.updateStuInfo(map);
         if (result == 1)
         {
         System.out.println("update successed!");
         }
         else
         {
         System.out.println("update failed.");
         }
  • 测试添加方法StuMysql.addStu()
        int result = StuMysql.addStu("180207201", "18第一只", "男", 20180001);
        if (result == 1)
        {
            System.out.println("update successed!");
        }
        else
        {
            System.out.println("update failed.");
        }
  • 测试删除方法 StuMysql.delStu()
        int result = StuMysql.delStu("180207201");
        if (result == 1)
        {
            System.out.println("delete successed!");
        }
        else
        {
            System.out.println("delete failed.");
        }

表格示例:

水果 价格 数量
香蕉 $1 5
苹果 $1 6
草莓 $1 7

你可能感兴趣的:(2018-01-30 小程序读取数据库显示二维码)