removeBase64Image

master
zhangcl 2 years ago
parent a80e291df9
commit 5292c35a78

@ -29,6 +29,7 @@ import sun.misc.BASE64Decoder;
import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
@ -360,6 +361,40 @@ public class AppController extends BaseController
return jsonObject;
}
public JSONObject removeBase64Image(JSONObject jsonObject,Long recordId)
{
String []keys={"image_sz","image_sz_yudian","image_sz_yuban","image_sz_liewen","image_st","image_sx","image_sx_vein"};
List<JSONObject> parents=new ArrayList<>();
try
{
parents.add(jsonObject.getJSONObject("data").getJSONObject("shezhi").getJSONObject("shemian"));
parents.add(jsonObject.getJSONObject("data").getJSONObject("shezhi").getJSONObject("yudian"));
parents.add(jsonObject.getJSONObject("data").getJSONObject("shezhi").getJSONObject("yuban"));
parents.add(jsonObject.getJSONObject("data").getJSONObject("shezhi").getJSONObject("liewen"));
parents.add(jsonObject.getJSONObject("data").getJSONObject("shetai"));
parents.add(jsonObject.getJSONObject("data").getJSONObject("shexia"));
parents.add(jsonObject.getJSONObject("data").getJSONObject("shexia"));
for (int i=0;i<keys.length;i++)
{
String imageKey=keys[i];
String imgStr=parents.get(i).getJSONObject(imageKey).getString("v");
String path=GenerateImage(imgStr);
parents.get(i).getJSONObject(keys[i]).put("v",null);
//保存图片到数据库,thirdId(recordId),path,name(imageKey)
}
}
catch (Exception e)
{
throw new ServiceException("JSON解析错误:" + jsonObject.toJSONString());
}
return jsonObject;
}
public static String GenerateImage(String imgStr)
{

Loading…
Cancel
Save