| @@ -34,6 +34,9 @@ public class UserApplication { | |||
| @Value("${fm.upload_dir}") | |||
| private String uploadDir; | |||
| @Value("${fm.ocr_data}") | |||
| private String ocrData; | |||
| @Bean | |||
| public boolean isFmException() { | |||
| return fmException; | |||
| @@ -53,6 +56,11 @@ public class UserApplication { | |||
| public String fmUploadDir() { | |||
| return uploadDir; | |||
| } | |||
| @Bean | |||
| public String ocrData() { | |||
| return ocrData; | |||
| } | |||
| public static void main(String[] args) { | |||
| SpringApplication.run(UserApplication.class, args); | |||
| @@ -0,0 +1,223 @@ | |||
| package com.iformall.controller.ocr; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantOcrModel; | |||
| import com.iformall.domain.po.WxOcrModel; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||
| import com.iformall.enums.EnumFromType; | |||
| import com.iformall.enums.EnumRentStartType; | |||
| import com.iformall.ocr.FormallTess4j; | |||
| import com.iformall.ocr.FormallTess4jTrain; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxOcrService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.io.File; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.OutputStream; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| @RestController | |||
| @RequestMapping("ocr") | |||
| public class WxOcrController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxOcrService ocrService; | |||
| @Autowired | |||
| private WxMerchantService merchantService; | |||
| @Autowired | |||
| private String ocrData; | |||
| /** | |||
| * 模板列表 | |||
| * @param wxRentContract | |||
| * @param pageNum | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| @GetMapping("/modelList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData modelList(@ModelAttribute WxOcrModel ocrModel, Integer pageNum, Integer pageSize) { | |||
| if (null == ocrModel) { | |||
| ocrModel = new WxOcrModel(); | |||
| } | |||
| ocrModel.setSortColumns(SortField.Createtime_DESC); | |||
| PageInfo<WxOcrModel> page = ocrService.listOcrModelAsPage(ocrModel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| /** | |||
| * 更新模板 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @PostMapping("updateModel") | |||
| public ResultData updateModel(@RequestBody WxOcrModel ocrModel) { | |||
| return ocrService.saveOrUpdateOcrModel(ocrModel); | |||
| } | |||
| /** | |||
| * 根据商户查询模板 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @GetMapping("merchantModel") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "merchantId", value = "商户编号", dataType = "Long", paramType = "query", required = true) | |||
| }) | |||
| public ResultData merchantModel(Long merchantId) { | |||
| WxMerchant merchant = merchantService.getById(merchantId); | |||
| if (null == merchant) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"商户数据不存在"); | |||
| } | |||
| return new ResultData(ocrService.getMerchantOcrModel(merchantId, merchant.getTenantId(), merchant.getParentTenantId())); | |||
| } | |||
| /** | |||
| * 更新商户模板 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @PostMapping("updateMerchantModel") | |||
| public ResultData updateMerchantModel(@RequestBody WxMerchantOcrModel merchantModel) { | |||
| return ocrService.saveOrUpdateMerchantOcrModel(merchantModel); | |||
| } | |||
| /** | |||
| * 删除商户模板 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @PostMapping("deleteMerchantModel") | |||
| public ResultData deleteMerchantModel(@RequestBody WxMerchantOcrModel merchantModel) { | |||
| return ocrService.deleteMerchantOcrModel(merchantModel.getId()); | |||
| } | |||
| /** | |||
| * 获取训练步骤 | |||
| * @return | |||
| */ | |||
| @GetMapping("getTrainSteps") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "modelId", value = "模板编号", dataType = "Long", paramType = "query", required = true) | |||
| }) | |||
| public ResultData getTrainSteps(Long modelId) { | |||
| WxOcrModel model = ocrService.getOcrModelById(modelId); | |||
| if (null == model) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"ocr模板不存在"); | |||
| } | |||
| return new ResultData(FormallTess4jTrain.getTrainSteps(model.getLangCode(), model.getFontName())); | |||
| } | |||
| /** | |||
| *测试训练结果 | |||
| * @return | |||
| */ | |||
| @PostMapping(value = "/testTrain", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| public ResultData testTrain(@RequestParam("file") MultipartFile multiReq,@RequestParam("modelId") Long modelId) { | |||
| try { | |||
| WxOcrModel model = ocrService.getOcrModelById(modelId); | |||
| if (null == model) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"ocr模板不存在"); | |||
| } | |||
| File file = multipartFileToFile(multiReq); | |||
| String result = FormallTess4j.testDoOCR_File(ocrData, file, model.getFontName()); | |||
| file.delete(); | |||
| return new ResultData(result); | |||
| } catch (Exception e) { | |||
| logger.error("testTrain error.",e); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR.getCode(),"解析失败。"+e.getMessage()); | |||
| } | |||
| } | |||
| private File multipartFileToFile(MultipartFile file) { | |||
| File toFile = null; | |||
| if (file.equals("") || file.getSize() <= 0) { | |||
| file = null; | |||
| } else { | |||
| InputStream ins = null; | |||
| try { | |||
| ins = file.getInputStream(); | |||
| toFile = new File(file.getOriginalFilename()); | |||
| inputStreamToFile(ins, toFile); | |||
| ins.close(); | |||
| } catch (IOException e) { | |||
| logger.error("multipartFileToFile error.",e); | |||
| }finally { | |||
| if (null != ins) { | |||
| try { | |||
| ins.close(); | |||
| } catch (IOException e) { | |||
| logger.error("multipartFileToFile error.",e); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return toFile; | |||
| } | |||
| private void inputStreamToFile(InputStream ins, File file) { | |||
| OutputStream os = null; | |||
| try { | |||
| os = new FileOutputStream(file); | |||
| int bytesRead = 0; | |||
| byte[] buffer = new byte[8192]; | |||
| while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { | |||
| os.write(buffer, 0, bytesRead); | |||
| } | |||
| os.close(); | |||
| ins.close(); | |||
| } catch (Exception e) { | |||
| logger.error("inputStreamToFile error.",e); | |||
| }finally { | |||
| if (null != os) { | |||
| try { | |||
| os.close(); | |||
| } catch (IOException e) { | |||
| logger.error("inputStreamToFile error.",e); | |||
| } | |||
| } | |||
| if (null != ins) { | |||
| try { | |||
| ins.close(); | |||
| } catch (IOException e) { | |||
| logger.error("inputStreamToFile error.",e); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -168,6 +168,7 @@ fm: | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads/ | |||
| ocr_data: /root/ocr_data/ | |||
| ueditor: | |||
| config: config.json | |||
| @@ -124,6 +124,7 @@ fm: | |||
| deploy: 3 | |||
| open: true | |||
| upload_dir: /root/uploads/ | |||
| ocr_data: /root/ocr_data/ | |||
| ueditor: | |||
| config: config.json | |||
| @@ -34,3 +34,7 @@ CREATE TABLE `wx_mall_ocr_model` ( | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `UNIQUE` (`mall_id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |||
| ALTER TABLE `wx_wiwide_info` ADD COLUMN `user_name` VARCHAR(100) COMMENT '登陆账号,首次初始化wiwideId和key用'; | |||
| ALTER TABLE `wx_wiwide_info` ADD COLUMN `password` VARCHAR(100) COMMENT '登陆密码'; | |||
| @@ -19,6 +19,12 @@ public class WxWiWideInfo extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪key",name="wiwideKey") | |||
| private String wiwideKey; | |||
| @io.swagger.annotations.ApiModelProperty(value="登陆username",name="userName") | |||
| private String userName; | |||
| @io.swagger.annotations.ApiModelProperty(value="登陆password",name="password") | |||
| private String password; | |||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪url",name="wiwideUrl") | |||
| private String wiwideUrl; | |||
| @@ -15,6 +15,7 @@ import com.iformall.service.DataTowerService; | |||
| import com.iformall.service.WxCUserCarService; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| import com.iformall.service.WxCouponOrderService; | |||
| import com.iformall.sms.wiwide.WiwideToken; | |||
| import com.iformall.sms.wiwide.WiwideUtil; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -782,14 +783,11 @@ public class DataTowerServiceImpl implements DataTowerService { | |||
| return datamap; | |||
| } | |||
| private void updateToken(WxWiWideInfo wiWideInfo, String token) { | |||
| Calendar instance = Calendar.getInstance(); | |||
| instance.add(Calendar.MINUTE, 45); | |||
| logger.info("数据表中的数据:"+JSONObject.toJSONString(wiWideInfo)); | |||
| private void updateToken(WxWiWideInfo wiWideInfo, String secretId,String secretKey) { | |||
| WxWiWideInfo record = new WxWiWideInfo(); | |||
| record.setId(wiWideInfo.getId()); | |||
| record.setToken(token); | |||
| record.setExpiredTime(instance.getTime()); | |||
| record.setWiwideId(secretId); | |||
| record.setWiwideKey(secretKey); | |||
| try { | |||
| logger.info("要更新的数据before>>>>>>>>>>"+JSONObject.toJSONString(record)); | |||
| wxWiwideInfoMapper.updateToken(record); | |||
| @@ -799,20 +797,25 @@ public class DataTowerServiceImpl implements DataTowerService { | |||
| } | |||
| } | |||
| private String getWiwideToken(WxWiWideInfo wiWideInfo) { | |||
| Date expiredTime = wiWideInfo.getExpiredTime(); | |||
| String token = wiWideInfo.getToken(); | |||
| logger.info("wiwideinfo:"+JSONObject.toJSONString(wiWideInfo)); | |||
| // if (StringUtils.isEmpty(token) || expiredTime == null || expiredTime.before(new Date())) { | |||
| String data = WiwideUtil.queryToken(wiWideInfo); | |||
| logger.info("bid:"+wiWideInfo.getWiwideId()+",newdata:"+data); | |||
| if (data == null) | |||
| return null; | |||
| token = (String) JSONObject.parseObject(data).get("data"); | |||
| updateToken(wiWideInfo, token); | |||
| // } | |||
| /** | |||
| * 测试: http://140.143.33.245/ fm_test/Wiwide123 | |||
| * @param wiWideInfo | |||
| * @return | |||
| */ | |||
| private WiwideToken getWiwideToken(WxWiWideInfo wiWideInfo) { | |||
| if ((!StringUtils.isBlank(wiWideInfo.getWiwideId())) && (!StringUtils.isBlank(wiWideInfo.getWiwideKey()))) { | |||
| return new WiwideToken(wiWideInfo.getWiwideId(), wiWideInfo.getWiwideKey()); | |||
| } | |||
| String data = WiwideUtil.queryToken(wiWideInfo); | |||
| logger.info("bid:"+wiWideInfo.getWiwideId()+",newdata:"+data); | |||
| if (StringUtils.isBlank(data)) return null; | |||
| JSONObject token = JSONObject.parseObject(data).getJSONObject("data"); | |||
| if (null == token) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),(String)JSONObject.parseObject(data).get("msg")); | |||
| } | |||
| updateToken(wiWideInfo, token.getString("SecretId"), token.getString("SecretKey")); | |||
| logger.info("返回的token:"+token); | |||
| return token; | |||
| return new WiwideToken(token.getString("SecretId"),token.getString("SecretKey")); | |||
| } | |||
| @Override | |||
| @@ -837,8 +840,9 @@ public class DataTowerServiceImpl implements DataTowerService { | |||
| return new ResultData(ErrorCode.WIWIDE_INFO_NOT_FOUND); | |||
| } | |||
| logger.info("迈外迪访问接口参数:" + params); | |||
| String res = WiwideUtil.queryData(wiWideInfo, getWiwideToken(wiWideInfo), params); | |||
| logger.info("迈外迪访问接口结果:" + res); | |||
| //String res = WiwideUtil.queryData(wiWideInfo, getWiwideToken(wiWideInfo), params); | |||
| //logger.info("迈外迪访问接口结果:" + res); | |||
| String res = ""; | |||
| JSONObject result = JSONObject.parseObject(res); | |||
| if (result == null) | |||
| return new ResultData(ErrorCode.WIWIDE_INFO_NOT_READY); | |||
| @@ -0,0 +1,149 @@ | |||
| package com.iformall.sms.wiwide; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.security.Key; | |||
| import javax.crypto.Cipher; | |||
| import javax.crypto.spec.SecretKeySpec; | |||
| import com.iformall.utils.Base64Util; | |||
| public class WiwideEntry { | |||
| private static final String AESTYPE = "AES/ECB/NoPadding"; | |||
| private static final String ENCRYPT_MODEL = "AES"; | |||
| private static final String TAG = "WIWIDE"; | |||
| /** | |||
| * encrypt function | |||
| * | |||
| * @param keyStr | |||
| * @param plainText | |||
| * @return string(encrypt data) | |||
| * @throws UnsupportedEncodingException | |||
| */ | |||
| public static String encrypt(String keyStr, String plainText) throws UnsupportedEncodingException { | |||
| if(keyStr.length()!=32){ | |||
| return "invalid key"; | |||
| } | |||
| byte[] encrypt = null; | |||
| byte[] bytes = plainText.getBytes(); // | |||
| byte[] type = new byte[]{0,0,0,0}; // | |||
| byte[] len = intToByteArray(bytes.length); // | |||
| byte[] orilen = intToByteArray(bytes.length + 8); // | |||
| byte[] fix = TAG.getBytes(); // | |||
| int dataLen = type.length + len.length + bytes.length + orilen.length + fix.length; | |||
| //16 | |||
| int mod = dataLen % 16; | |||
| String padding = ""; | |||
| if(mod != 0){ | |||
| int paddingLen = 16 - mod; | |||
| dataLen = dataLen + paddingLen; | |||
| for(int i = 0; i < paddingLen ; i++){ | |||
| padding += "0"; | |||
| } | |||
| } | |||
| byte[] nBytes = new byte[dataLen]; | |||
| System.arraycopy(type, 0, nBytes, 0, type.length); | |||
| System.arraycopy(len, 0, nBytes, type.length, len.length); | |||
| System.arraycopy(bytes, 0, nBytes, (type.length + len.length), bytes.length); | |||
| System.arraycopy(orilen, 0, nBytes, (type.length + len.length + bytes.length), orilen.length); | |||
| System.arraycopy(fix, 0, nBytes, (type.length + len.length + bytes.length + orilen.length), fix.length); | |||
| if(!"".equals(padding)){ | |||
| byte[] paddingByte = padding.getBytes("ISO-8859-1"); | |||
| System.arraycopy(paddingByte, 0, nBytes, (type.length + len.length + bytes.length + orilen.length + fix.length), paddingByte.length); | |||
| } | |||
| try{ | |||
| Key key = generateKey(keyStr.substring(8, 24)); | |||
| Cipher cipher = Cipher.getInstance(AESTYPE); | |||
| cipher.init(Cipher.ENCRYPT_MODE, key); | |||
| encrypt = cipher.doFinal(nBytes); | |||
| }catch(Exception e){ | |||
| e.printStackTrace(); | |||
| } | |||
| return new String(Base64Util.encode(encrypt)); | |||
| } | |||
| /** | |||
| * decrypt function | |||
| * | |||
| * @param keyStr | |||
| * @param encryptData | |||
| * @return string(base data) | |||
| * @throws UnsupportedEncodingException | |||
| */ | |||
| public static String decrypt(String keyStr, String encryptData) throws UnsupportedEncodingException { | |||
| if(keyStr.length()!=32){ | |||
| return "invalid key"; | |||
| } | |||
| byte[] decrypt = null; | |||
| try{ | |||
| Key key = generateKey(keyStr.substring(8, 24)); | |||
| Cipher cipher = Cipher.getInstance(AESTYPE); | |||
| cipher.init(Cipher.DECRYPT_MODE, key); | |||
| decrypt = cipher.doFinal(Base64Util.decode(encryptData)); | |||
| }catch(Exception e){ | |||
| e.printStackTrace(); | |||
| } | |||
| byte[] type = new byte[]{0,0,0,0}; | |||
| byte[] len = intToByteArray(decrypt.length); | |||
| byte[] orilen = intToByteArray(decrypt.length + 8); | |||
| String buffDecrypt = new String(decrypt,("ISO-8859-1")); | |||
| buffDecrypt = buffDecrypt.substring(0, buffDecrypt.lastIndexOf(TAG)); | |||
| int start = type.length + len.length; | |||
| int end = orilen.length; | |||
| int length = buffDecrypt.getBytes("ISO-8859-1").length - start - end; | |||
| byte[] endDecrypt = new byte[length]; | |||
| System.arraycopy(buffDecrypt.getBytes("ISO-8859-1"), start, endDecrypt, 0, length); | |||
| return new String(endDecrypt); | |||
| } | |||
| /** | |||
| * get the generateKey | |||
| * | |||
| * @param key | |||
| * @return Object (Key) | |||
| * @throws Exception | |||
| */ | |||
| private static Key generateKey(String key)throws Exception{ | |||
| try{ | |||
| SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), ENCRYPT_MODEL); | |||
| return keySpec; | |||
| }catch(Exception e){ | |||
| e.printStackTrace(); | |||
| throw e; | |||
| } | |||
| } | |||
| /** | |||
| * integer to | |||
| * | |||
| * @param i | |||
| * @return byte[] | |||
| */ | |||
| public static byte[] intToByteArray(int i) { | |||
| byte[] result = new byte[4]; | |||
| result[0] = (byte)((i >> 24) & 0xFF); | |||
| result[1] = (byte)((i >> 16) & 0xFF); | |||
| result[2] = (byte)((i >> 8) & 0xFF); | |||
| result[3] = (byte)(i & 0xFF); | |||
| return result; | |||
| } | |||
| public static void main(String[] args) throws UnsupportedEncodingException{ | |||
| /** | |||
| * Signature签名生成规则为:SecretId+&_&+SecretKey+&_&+秒级时间戳【默认过期时间为5分钟】 | |||
| * Signature参数为每个接口请求必传参数【获取开发者id与令牌接口可不传】,放入Cookie中 | |||
| */ | |||
| String plainText = "vbq9KQsf&_&6cff3a09a27e745300882d60c08b82c11617ef6c&_&1606311935";// | |||
| String keyStr = "191ffbbb437946318bfecb373e694a13";//KEY | |||
| String encText = encrypt(keyStr, plainText);//: | |||
| String decString = decrypt(keyStr, encText);// | |||
| System.out.print("base data:"); | |||
| System.out.println(plainText); | |||
| System.out.print("encrypt data:"); | |||
| System.out.println(encText); | |||
| System.out.print("decrypt data:"); | |||
| System.out.println(decString); | |||
| } | |||
| } | |||
| @@ -0,0 +1,33 @@ | |||
| package com.iformall.sms.wiwide; | |||
| import java.io.Serializable; | |||
| public class WiwideToken implements Serializable{ | |||
| private static final long serialVersionUID = -5462040922824432499L; | |||
| public WiwideToken() { | |||
| } | |||
| public WiwideToken(String secretId,String secretKey) { | |||
| this.secretId = secretId; | |||
| this.secretKey = secretKey; | |||
| } | |||
| private String secretKey; | |||
| private String secretId; | |||
| public String getSecretKey() { | |||
| return secretKey; | |||
| } | |||
| public void setSecretKey(String secretKey) { | |||
| this.secretKey = secretKey; | |||
| } | |||
| public String getSecretId() { | |||
| return secretId; | |||
| } | |||
| public void setSecretId(String secretId) { | |||
| this.secretId = secretId; | |||
| } | |||
| } | |||
| @@ -153,25 +153,26 @@ public class WiwideUtil implements SMSExcutor { | |||
| public static String queryToken(WxWiWideInfo wiWideInfo) { | |||
| logger.info("获取TOKEN"); | |||
| String username = wiWideInfo.getWiwideId(); | |||
| String authVal = WiwideUtil.encrypt(wiWideInfo.getWiwideKey()); | |||
| String username = wiWideInfo.getUserName(); | |||
| String password = wiWideInfo.getPassword(); | |||
| //String authVal = WiwideUtil.encrypt(wiWideInfo.getWiwideKey()); | |||
| if(StringUtils.isEmpty(username)){ | |||
| logger.error("商场:" + wiWideInfo.getTenantId() + ",wiwideId为空" ); | |||
| return null; | |||
| } | |||
| if(StringUtils.isEmpty(authVal)){ | |||
| if(StringUtils.isEmpty(password)){ | |||
| logger.error("商场:" + wiWideInfo.getTenantId() + ",wiwideKey为空" ); | |||
| return null; | |||
| } | |||
| Map<String, String> params = new HashMap<>(2); | |||
| params.put("username", username); | |||
| params.put("authVal", authVal); | |||
| params.put("password", password); | |||
| String wiwideUrl = wiWideInfo.getWiwideUrl(); | |||
| String token = HttpUtil.doPost(wiwideUrl + "/login/auth", params); | |||
| logger.info("商场:" + wiWideInfo.getTenantId() + ",返回TOKEN" + token); | |||
| return token; | |||
| String result = HttpUtil.doPost(wiwideUrl + "/api/user/auth", params); | |||
| logger.info("商场:" + wiWideInfo.getTenantId() + ",返回TOKEN" + result); | |||
| return result; | |||
| } | |||
| public static String queryData(WxWiWideInfo wiWideInfo, String token, Map<String, String> params) { | |||
| @@ -179,5 +180,13 @@ public class WiwideUtil implements SMSExcutor { | |||
| String data = HttpUtil.doPostWiwide(wiWideInfo.getWiwideUrl() + "/reports/data", token, params); | |||
| return data; | |||
| } | |||
| public static void main(String[] args) { | |||
| Map<String, String> params = new HashMap<>(2); | |||
| params.put("username", "lianhua"); | |||
| params.put("password", "widash1234"); | |||
| String token = HttpUtil.doPost("http://140.143.33.245/api/user/auth", params); | |||
| System.out.println(token); | |||
| } | |||
| } | |||
| @@ -11,10 +11,12 @@ | |||
| <result column="token" jdbcType="VARCHAR" property="token"/> | |||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime"/> | |||
| <result column="capability" jdbcType="VARCHAR" property="capability"/> | |||
| <result column="user_name" jdbcType="VARCHAR" property="userName"/> | |||
| <result column="password" jdbcType="VARCHAR" property="password"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`wiwide_id`,`wiwide_key`,`wiwide_url`, `token`,`expired_time`,`capability` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`wiwide_id`,`wiwide_key`,`wiwide_url`, `token`,`expired_time`,`capability`,`user_name`,`password` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -51,7 +53,7 @@ | |||
| </select> | |||
| <update id="updateToken" parameterType="com.iformall.domain.po.WxWiWideInfo"> | |||
| update wx_wiwide_info set token=#{token},expired_time=#{expiredTime} where id=#{id} | |||
| update wx_wiwide_info set wiwide_id=#{wiwideId},wiwide_key=#{wiwideKey} where id=#{id} | |||
| </update> | |||