## 记录图片镶嵌微信小程序码生成的过程
小程序码的生成和二维码差不多,不过需要由微信官方生成
Controller
@RequestMapping("/generatedEQpic")
public ResultInfo generatedEQpic(@RequestBody JSONObject js){
ResultInfo res = new ResultInfo();
try {
res = sDictionaryService.generatedEQpic(js);
}catch (Exception e){
e.printStackTrace();
}
return res;
}
我使用的二维码背景图都在mogo中取得地址,非本地,网上有很多本地图片生成的文章
service
@Override
public ResultInfo generatedEQpic(JSONObject json) {
String s = new String();
String postersurl =null; //背景图片的mogo地址
int xcoordinates = 0; //二维码x轴坐标
int ycoordinates= 0; //二维码Y轴坐标
int mcoordinates= 0; //二维码的边长
//查询数据库存入的二维码的X,Y,边长,还有背景图的地址
StringBuffer sql = new StringBuffer("select postersurl,xcoordinates,ycoordinates,mcoordinates,postertype FROM s_online_goods where id=:id");
Query nativeQuery = entityManager.createNativeQuery(sql.toString());
nativeQuery.setParameter("id",json.getString("id"));
List<Map<String, Object>> list= nativeQuery.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).getResultList();
if (list.size(