main
黄海 2 years ago
parent 0371824760
commit c5af72e8d8

@ -155,9 +155,9 @@ public class YpController extends Controller {
* @param tel
*/
@Before(POST.class)
@EmptyInterface({"sfzh"})
public void save(int task_id, String name, String xb, int bx_id, String address, String father_name, String mother_name, String sfzh, String tel) {
int result = model.save(task_id, name, xb, bx_id, address, father_name, mother_name, sfzh, tel);
@EmptyInterface({"name","xb","sfzh","address","father_name","mother_name","tel","uuid"})
public void save(int task_id, String name, String xb, int bx_id, String address, String father_name, String mother_name, String sfzh, String tel,String uuid) {
int result = model.save(task_id, name, xb, bx_id, address, father_name, mother_name, sfzh, tel,uuid);
Kv kv = Kv.by("success", result);
if (result == 1) kv.set("message", "获取成功!");
@ -216,26 +216,21 @@ public class YpController extends Controller {
renderJson(CommonUtil.returnMessageJson(false, "上传文件类型错误系统只允许上传jpg格式"));
return;
}
String sfzh = get("sfzh");
if (StrKit.isBlank(sfzh)) {
Kv kv = Kv.by("success", false);
kv.set("message", "没有传入sfzh数据");
renderJson(kv);
return;
}
String uuid=UUID.randomUUID().toString();
//判断目录是不是存在
File file = new File(PathKit.getWebRootPath() + "/upload");
if (!file.exists()) {
file.mkdirs();// 创建文件夹
}
String finalPic = PathKit.getWebRootPath() + "/upload/" + sfzh + ".jpg";
String finalPic = PathKit.getWebRootPath() + "/upload/" + uuid + ".jpg";
picFile.getFile().renameTo(new File(finalPic));
//输出base64编码的jpg文件
String base64 = Base64Util.fileToBase64(new File(finalPic));
Kv kv = Kv.by("success", true);
kv.set("message", "上传成功!");
kv.set("base64", base64);
kv.set("uuid",uuid);
renderJson(kv);
//path : /FengHuang/upload/sfzh+".jpg"
}

@ -132,7 +132,7 @@ public class YpModel {
* @param sfzh
* @param tel
*/
public int save(int task_id, String name, String xb, int bx_id, String address, String father_name, String mother_name, String sfzh, String tel) {
public int save(int task_id, String name, String xb, int bx_id, String address, String father_name, String mother_name, String sfzh, String tel,String uuid) {
//1、检查身份证号是不是已存在
String sql = "select count(1) as count from t_yp_record where sfzh=?";
int count = Db.findFirst(sql, sfzh).getInt("count");
@ -156,6 +156,7 @@ public class YpModel {
record.set("mother_name", mother_name);
record.set("sfzh", sfzh);
record.set("tel", tel);
record.set("pic","/upload/" + uuid + ".jpg");
Db.save("t_yp_record", "id", record);
return 1;
}

Loading…
Cancel
Save