main
黄海 1 year ago
parent a23a8b1891
commit aa26b968c8

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 KiB

@ -309,29 +309,6 @@ public class HuiYaController extends Controller {
renderJson(res);
return;
}
//将上传的图片进行检测
/**
for (String s : source_img_url.split(",")) {
var ret = AliYunCheckImageUtil.Check(s);
if (ret.getConfidence() != null && ret.getConfidence() > 0) {
res.set("success", false);
res.set("message", "上传的图片中存在违反网络内容传播相关规定的内容,无法创建任务!");
renderJson(res);
return;
}
}*/
//记录到数据库中
// var imgUrlList = source_img_url.split(",");
// var md5List = images_md5.split(",");
// for (int i = 0; i < imgUrlList.length; i++) {
// boolean success = ym.wxWriteImageMd5(md5List[i], imgUrlList[i]);
// if (!success) {
// res.set("success", false);
// res.set("message", "发现img_url重复无法执行");
// renderJson(res);
// return;
// }
// }
int task_id = ym.wxAddTask(user_id, model_id, source_img_url, prompt_id);
//计算当前任务的可能完成时间
String estimation_finish_time = ym.wxGetCostTime(task_id);
@ -374,7 +351,7 @@ public class HuiYaController extends Controller {
* MD5URL
*
* @param token
* @param image_md5
* @param image_md5 TODO
*/
@Before({POST.class})
@EmptyInterface({"token", "image_md5"})
@ -387,19 +364,37 @@ public class HuiYaController extends Controller {
renderJson(kv);
return;
}
// Record record = ym.wxMd5Exist(image_md5);
// if (record != null) {
// res.set("image_md5_exist", true);
// res.set("image_url", record.getStr("image_url"));
// } else {
// res.set("image_md5_exist", false);
// res.set("image_url", null);
// }
res.set("image_md5_exist", false);
res.set("image_url", null);
renderJson(res);
}
/**
*
*
* @param token
* @param limit
*/
@Before({POST.class})
@EmptyInterface({"token"})
@IsNumericInterface({"limit"})
public void wxUserImgHistory(String token, int limit) {
if (limit == 0) limit = 5;
//验证token
Kv res = ym.checkToken(token);
if (!res.getBoolean("success")) {
Kv kv = Kv.by("success", false);
kv.set("message", res.getStr("message"));
renderJson(kv);
return;
}
String user_id = res.getStr("user_id");
List<Record> list = ym.wxUserImgHistory(user_id, limit);
res.set("data", list);
renderJson(res);
}
/**
*
*

@ -6,7 +6,11 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import cn.hutool.core.date.DateTime;
import com.alibaba.fastjson.JSONObject;
import com.dsideal.QingLong.Interceptor.EmptyInterface;
import com.dsideal.QingLong.Interceptor.IsNumericInterface;
import com.dsideal.QingLong.Util.RsaUtils;
import com.jfinal.aop.Before;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.Kv;
import com.jfinal.kit.PropKit;
import com.jfinal.kit.StrKit;
@ -425,7 +429,6 @@ public class HuiYaModel {
}
public Record getModelPromptRecord(int model_id, int prompt_id) {
//http://hzkc.oss-cn-beijing.aliyuncs.com/Images/System/2/2.png
Record r = new Record();
r.set("prompt_id", prompt_id);
String img_url = "http://hzkc.oss-cn-beijing.aliyuncs.com/Images/System/" + model_id + "/" + prompt_id + ".png";
@ -536,38 +539,6 @@ public class HuiYaModel {
return Db.paginate(page, limit, sqlPara);
}
/**
* MD5
*
* @param image_md5
* @param image_url
*/
public boolean wxWriteImageMd5(String image_md5, String image_url) {
try {
String sql = "delete from t_hy_image_md5 where image_md5=?";
Db.update(sql, image_md5);
Record record = new Record();
record.set("image_md5", image_md5);
record.set("image_url", image_url);
Db.save("t_hy_image_md5", "image_md5", record);
return true;
} catch (Exception err) {
System.out.println(err.toString());
return false;
}
}
/**
* MD5
*
* @param image_md5
* @return
*/
public Record wxMd5Exist(String image_md5) {
String sql = "select * from t_hy_image_md5 where image_md5=?";
Record record = Db.findFirst(sql, image_md5);
return record;
}
/**
*
@ -578,7 +549,7 @@ public class HuiYaModel {
public static DateTime wxGetCostTimeListBeginTime = DateTime.now();
public static Map<Integer, Integer> wxGetCostMap = new HashMap<>();
public Map<Integer, Integer> wxGetCostTimeMap() {
public void wxGetCostTimeMap() {
Duration duration = Duration.between((Temporal) DateTime.now(), (Temporal) wxGetCostTimeListBeginTime);
if (duration.getSeconds() > 60) {
wxGetCostTimeList.clear();
@ -594,10 +565,12 @@ public class HuiYaModel {
wxGetCostMap.put(model_id, seconds_difference);
});
}
return wxGetCostMap;
}
public String wxGetCostTime(int task_id) {
//调用生成Map
wxGetCostTimeMap();
//当前任务的model_id
Record r = Db.findById("t_hy_task", "task_id", task_id);
int model_id = r.getInt("model_id");
@ -630,4 +603,16 @@ public class HuiYaModel {
}
return res;
}
/**
*
*
* @param user_id
* @param limit
*/
public List<Record> wxUserImgHistory(String user_id, int limit) {
Kv kv = Kv.by("user_id", user_id).set("limit", limit);
SqlPara sqlPara = Db.getSqlPara("HuiYa.wxUserImgHistory", kv);
return Db.find(sqlPara);
}
}

@ -38,4 +38,20 @@
select t1.*,t3.model_name from t_hy_journal as t1 left join t_hy_task as t2 on t1.task_id=t2.task_id left join t_hy_model as t3
on t2.model_id=t3.model_id where t1.user_id=#para(user_id) order by t1.id desc
#end
-- 获取用户的上传图片历史记录
#sql("wxUserImgHistory")
WITH RankedTasks AS (
SELECT
task_id,
source_img_url,
ROW_NUMBER() OVER (PARTITION BY source_img_url ORDER BY task_id DESC) AS rn
FROM t_hy_task where user_id=#para(user_id))
SELECT
task_id,source_img_url
FROM
RankedTasks
WHERE
rn = 1 order by task_id desc limit #para(limit);
#end
#end
Loading…
Cancel
Save