From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConvertLinkController.java | 433 +++++++++++++++++++++++++++--------------------------- 1 files changed, 217 insertions(+), 216 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConvertLinkController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConvertLinkController.java index f22b333..439ee8a 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConvertLinkController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConvertLinkController.java @@ -2,11 +2,14 @@ import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.UUID; import javax.annotation.Resource; +import com.yeshi.fanli.entity.SystemFunction; +import com.yeshi.fanli.service.inter.user.UserFunctionsLimitService; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; @@ -26,259 +29,257 @@ /** * 鏂囨杞摼 - * @author Administrator * + * @author Administrator */ @Controller("convertLinkControllerV2") @RequestMapping("api/v2/convertlink") public class ConvertLinkController { - @Resource - private UserConvertLinkTemplateService userConvertLinkTemplateService; + @Resource + private UserConvertLinkTemplateService userConvertLinkTemplateService; - @Resource - private ConfigService configService; + @Resource + private ConfigService configService; - @Resource - private RedisManager redisManager; + @Resource + private RedisManager redisManager; - @Resource - private ConvertLinkManager convertLinkManager; + @Resource + private ConvertLinkManager convertLinkManager; - /** - * - * @Title: getCommonTextList - * @Description: 鑾峰彇妯℃澘 - * @param acceptData - * @param uid - * @param callback - * @param out - * void 杩斿洖绫诲瀷 - * @throws - */ - @RequestMapping(value = "getCommonTextList") - public void getCommonTextList(AcceptData acceptData, Long uid, String callback, PrintWriter out) { - if (uid == null || uid == 0L) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); - return; - } + @Resource + private UserFunctionsLimitService userFunctionsLimitService; - JSONObject data = new JSONObject(); + /** + * @param acceptData + * @param uid + * @param callback + * @param out void 杩斿洖绫诲瀷 + * @throws + * @Title: getCommonTextList + * @Description: 鑾峰彇妯℃澘 + */ + @RequestMapping(value = "getCommonTextList") + public void getCommonTextList(AcceptData acceptData, Long uid, String callback, PrintWriter out) { + if (uid == null || uid == 0L) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); + return; + } - List<UserConvertLinkTemplate> list = userConvertLinkTemplateService.listByUid(uid); - if (list == null) - list = new ArrayList<>(); + JSONObject data = new JSONObject(); - Gson gson = JsonUtil.getApiCommonGson(); - data.put("list", gson.toJson(list)); - data.put("tip", configService.getValue(ConfigKeyEnum.convertDocTip.getKey(),acceptData.getSystem())); - data.put("helpLink", configService.getValue(ConfigKeyEnum.convertDocHelpLink.getKey(),acceptData.getSystem())); + List<UserConvertLinkTemplate> list = userConvertLinkTemplateService.listByUid(uid); + if (list == null) + list = new ArrayList<>(); - String text = redisManager.getCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid); - if (text != null) { - data.put("lastText", text); - redisManager.removeCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid); - } - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - } + Gson gson = JsonUtil.getApiCommonGson(); + data.put("list", gson.toJson(list)); + data.put("tip", configService.getValue(ConfigKeyEnum.convertDocTip.getKey(), acceptData.getSystem())); + data.put("helpLink", configService.getValue(ConfigKeyEnum.convertDocHelpLink.getKey(), acceptData.getSystem())); - /** - * - * @Title: setConvertLinkDoc - * @Description: 鏆傚瓨鏂囨 - * @param acceptData - * @param uid - * @param text - * @param callback - * @param out - * void 杩斿洖绫诲瀷 - * @throws - */ - @RequestMapping(value = "setConvertLinkDoc") - public void setConvertLinkDoc(AcceptData acceptData, Long uid, String text, String callback, PrintWriter out) { - if (uid == null || uid == 0L) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); - return; - } + String text = redisManager.getCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid); + if (text != null) { + data.put("lastText", text); + redisManager.removeCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid); + } + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + } - if (StringUtil.isNullOrEmpty(text)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏂囨涓虹┖"))); - return; - } - redisManager.cacheCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid, text); - - - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); - } + /** + * @param acceptData + * @param uid + * @param text + * @param callback + * @param out void 杩斿洖绫诲瀷 + * @throws + * @Title: setConvertLinkDoc + * @Description: 鏆傚瓨鏂囨 + */ + @RequestMapping(value = "setConvertLinkDoc") + public void setConvertLinkDoc(AcceptData acceptData, Long uid, String text, String callback, PrintWriter out) { + if (uid == null || uid == 0L) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); + return; + } - /** - * - * @Title: addCommonText - * @Description: 娣诲姞妯℃澘 - * @param acceptData - * @param uid - * @param template - * @param callback - * @param out - * void 杩斿洖绫诲瀷 - * @throws - */ + if (StringUtil.isNullOrEmpty(text)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏂囨涓虹┖"))); + return; + } + redisManager.cacheCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid, text); - @RequestMapping(value = "addCommonText") - public void addCommonText(AcceptData acceptData, Long uid, String template, String callback, PrintWriter out) { - if (uid == null || uid == 0L) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); - return; - } - if (StringUtil.isNullOrEmpty(template)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏂囨涓虹┖"))); - return; - } - UserConvertLinkTemplate bean = new UserConvertLinkTemplate(); - bean.setUid(uid); - bean.setTemplate(template); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); + } - try { - userConvertLinkTemplateService.addConvertLinkTemplate(bean); - } catch (Exception e) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); - return; - } + /** + * @param acceptData + * @param uid + * @param template + * @param callback + * @param out void 杩斿洖绫诲瀷 + * @throws + * @Title: addCommonText + * @Description: 娣诲姞妯℃澘 + */ - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); - } + @RequestMapping(value = "addCommonText") + public void addCommonText(AcceptData acceptData, Long uid, String template, String callback, PrintWriter out) { + if (uid == null || uid == 0L) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); + return; + } - /** - * - * @Title: deleteCommonText - * @Description: 鍒犻櫎妯℃澘 - * @param acceptData - * @param uid - * @param id - * @param callback - * @param out - * void 杩斿洖绫诲瀷 - * @throws - */ - @RequestMapping(value = "deleteCommonText") - public void deleteCommonText(AcceptData acceptData, Long uid, String id, String callback, PrintWriter out) { - if (uid == null || uid == 0L) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); - return; - } + if (StringUtil.isNullOrEmpty(template)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏂囨涓虹┖"))); + return; + } + UserConvertLinkTemplate bean = new UserConvertLinkTemplate(); + bean.setUid(uid); + bean.setTemplate(template); - if (StringUtil.isNullOrEmpty(id)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("妯℃澘ID涓虹┖"))); - return; - } + try { + userConvertLinkTemplateService.addConvertLinkTemplate(bean); + } catch (Exception e) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); + return; + } - try { - userConvertLinkTemplateService.deleteConvertLinkTemplate(id, uid); - } catch (Exception e) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); - return; - } + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); + } - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); - } + /** + * @param acceptData + * @param uid + * @param id + * @param callback + * @param out void 杩斿洖绫诲瀷 + * @throws + * @Title: deleteCommonText + * @Description: 鍒犻櫎妯℃澘 + */ + @RequestMapping(value = "deleteCommonText") + public void deleteCommonText(AcceptData acceptData, Long uid, String id, String callback, PrintWriter out) { + if (uid == null || uid == 0L) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); + return; + } - @RequestMapping(value = "updateCommonText") - public void updateCommonText(AcceptData acceptData, Long uid, String id, String template, String callback, - PrintWriter out) { - if (uid == null || uid == 0L) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); - return; - } + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("妯℃澘ID涓虹┖"))); + return; + } - if (StringUtil.isNullOrEmpty(id)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("妯℃澘ID涓虹┖"))); - return; - } + try { + userConvertLinkTemplateService.deleteConvertLinkTemplate(id, uid); + } catch (Exception e) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); + return; + } - if (StringUtil.isNullOrEmpty(template)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("妯℃澘鍐呭涓虹┖"))); - return; - } + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); + } - UserConvertLinkTemplate bean = new UserConvertLinkTemplate(); - bean.setUid(uid); - bean.setTemplate(template); - bean.setId(id); + @RequestMapping(value = "updateCommonText") + public void updateCommonText(AcceptData acceptData, Long uid, String id, String template, String callback, + PrintWriter out) { + if (uid == null || uid == 0L) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); + return; + } - try { - userConvertLinkTemplateService.updateTemplate(bean); - } catch (Exception e) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); - return; - } + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("妯℃澘ID涓虹┖"))); + return; + } - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); - } + if (StringUtil.isNullOrEmpty(template)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("妯℃澘鍐呭涓虹┖"))); + return; + } - /** - * - * @Title: convert - * @Description: 鏂囨杞摼 - * @param acceptData - * @param uid - * @param text - * @param callback - * @param out - * void 杩斿洖绫诲瀷 - * @throws - */ - @RequestMapping(value = "convert") - public void convert(AcceptData acceptData, Long uid, String text, String callback, PrintWriter out) { - if (uid == null || uid == 0L) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); - return; - } + UserConvertLinkTemplate bean = new UserConvertLinkTemplate(); + bean.setUid(uid); + bean.setTemplate(template); + bean.setId(id); - if (StringUtil.isNullOrEmpty(text)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏂囨涓虹┖"))); - return; - } + try { + userConvertLinkTemplateService.updateTemplate(bean); + } catch (Exception e) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); + return; + } - try { - String key = RedisKeyEnum.convertLinkDocResultTemp.getKey() + uid + "-" - + StringUtil.Md5(UUID.randomUUID().toString()); - String result = convertLinkManager.convertLinkFromText(text, uid, true,true); - redisManager.cacheCommonString(key, result, 60); - JSONObject data = new JSONObject(); - data.put("id", key); - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - } catch (Exception e) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); - return; - } + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); + } - } + /** + * @param acceptData + * @param uid + * @param text + * @param callback + * @param out void 杩斿洖绫诲瀷 + * @throws + * @Title: convert + * @Description: 鏂囨杞摼 + */ + @RequestMapping(value = "convert") + public void convert(AcceptData acceptData, Long uid, String text, String callback, PrintWriter out) { + if (uid == null || uid == 0L) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); + return; + } - @RequestMapping(value = "getConvertResult") - public void getConvertResult(AcceptData acceptData, Long uid, String id, String callback, PrintWriter out) { - if (uid == null || uid == 0L) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); - return; - } + if (StringUtil.isNullOrEmpty(text)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏂囨涓虹┖"))); + return; + } - if (StringUtil.isNullOrEmpty(id)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏂囨ID涓虹┖"))); - return; - } + if (userFunctionsLimitService.isLimit(uid, SystemFunction.share, new Date())) { + out.print(JsonUtil.loadFalseResult(1, "璇ュ姛鑳介檺鍒朵娇鐢�")); + return; + } - String key =id; - String result = redisManager.getCommonString(key); - if (StringUtil.isNullOrEmpty(result)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鑾峰彇杞摼缁撴灉鍑洪敊"))); - } else { - redisManager.removeCommonString(key); - JSONObject data = new JSONObject(); - data.put("data", result); - data.put("tip", "1.杞ソ鐨勯摼鎺�/鍙d护鏈夋湁鏁堟湡锛岃鍦ㄦ湁鏁堟湡鍐呮帹骞垮垎浜紱\r\n" + "2.宸茬粡杞ソ鐨勯摼鎺�/鍙d护璇蜂笉瑕佷慨鏀癸紝浠ュ厤鏃犳硶杩借釜鍒拌鍗曪紱\r\n" - + "3.璇风‘淇濊浆鎹㈤摼鎺ュ悎娉曞悎瑙勶紝涓�鍒囪繚娉曠殑閾炬帴/鍙d护浜х敓鐨勬硶寰嬪悗鏋滆嚜琛屾壙鎷呬笌鏈珹pp鏃犲叧銆�"); - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - } - } + try { + String key = RedisKeyEnum.convertLinkDocResultTemp.getKey() + uid + "-" + + StringUtil.Md5(UUID.randomUUID().toString()); + String result = convertLinkManager.convertLinkFromText(acceptData.getSystem(), text, uid, true, true); + redisManager.cacheCommonString(key, result, 60); + JSONObject data = new JSONObject(); + data.put("id", key); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + } catch (Exception e) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); + return; + } + + } + + @RequestMapping(value = "getConvertResult") + public void getConvertResult(AcceptData acceptData, Long uid, String id, String callback, PrintWriter out) { + if (uid == null || uid == 0L) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"))); + return; + } + + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏂囨ID涓虹┖"))); + return; + } + + String key = id; + String result = redisManager.getCommonString(key); + if (StringUtil.isNullOrEmpty(result)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鑾峰彇杞摼缁撴灉鍑洪敊"))); + } else { + redisManager.removeCommonString(key); + JSONObject data = new JSONObject(); + data.put("data", result); + data.put("tip", "1.杞ソ鐨勯摼鎺�/鍙d护鏈夋湁鏁堟湡锛岃鍦ㄦ湁鏁堟湡鍐呮帹骞垮垎浜紱\r\n" + "2.宸茬粡杞ソ鐨勯摼鎺�/鍙d护璇蜂笉瑕佷慨鏀癸紝浠ュ厤鏃犳硶杩借釜鍒拌鍗曪紱\r\n" + + "3.璇风‘淇濊浆鎹㈤摼鎺ュ悎娉曞悎瑙勶紝涓�鍒囪繚娉曠殑閾炬帴/鍙d护浜х敓鐨勬硶寰嬪悗鏋滆嚜琛屾壙鎷呬笌鏈珹pp鏃犲叧銆�"); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + } + } } -- Gitblit v1.8.0