Commit 455a7f8c authored by ysongq's avatar ysongq

api上传-调用getway

parent d7b311c3
......@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
......@@ -17,6 +19,7 @@ import java.util.Date;
*/
@TableName("t_data_goods")
@ApiModel
@Data
public class DataGoods implements Serializable {
private static final long serialVersionUID = 938517475031285541L;
/**
......@@ -32,6 +35,9 @@ public class DataGoods implements Serializable {
* 数据商户id
*/
private Long userId;
@ApiModelProperty(value = "唯一数据商品标识")
private String apiOpenId;
/**
* 数据商品名称
*/
......@@ -126,212 +132,6 @@ public class DataGoods implements Serializable {
private BigDecimal secondType;
public Long getDataGoodsId() {
return dataGoodsId;
}
public void setDataGoodsId(Long dataGoodsId) {
this.dataGoodsId = dataGoodsId;
}
public Long getCategoryId() {
return categoryId;
}
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getDataName() {
return dataName;
}
public void setDataName(String dataName) {
this.dataName = dataName;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getDataLabel() {
return dataLabel;
}
public void setDataLabel(String dataLabel) {
this.dataLabel = dataLabel;
}
public String getDataPicture() {
return dataPicture;
}
public void setDataPicture(String dataPicture) {
this.dataPicture = dataPicture;
}
public BigDecimal getDataPrice() {
return dataPrice;
}
public void setDataPrice(BigDecimal dataPrice) {
this.dataPrice = dataPrice;
}
public BigDecimal getDiscountPrice() {
return discountPrice;
}
public void setDiscountPrice(BigDecimal discountPrice) {
this.discountPrice = discountPrice;
}
public String getPriceType() {
return priceType;
}
public void setPriceType(String priceType) {
this.priceType = priceType;
}
public String getGoodsStandards() {
return goodsStandards;
}
public void setGoodsStandards(String goodsStandards) {
this.goodsStandards = goodsStandards;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
public String getAuditStatus() {
return auditStatus;
}
public void setAuditStatus(String auditStatus) {
this.auditStatus = auditStatus;
}
public String getCleanRule() {
return cleanRule;
}
public void setCleanRule(String cleanRule) {
this.cleanRule = cleanRule;
}
public String getRejectReason() {
return rejectReason;
}
public void setRejectReason(String rejectReason) {
this.rejectReason = rejectReason;
}
public String getAuditPerson() {
return auditPerson;
}
public void setAuditPerson(String auditPerson) {
this.auditPerson = auditPerson;
}
public Date getAuditTime() {
return auditTime;
}
public void setAuditTime(Date auditTime) {
this.auditTime = auditTime;
}
public Date getCreTime() {
return creTime;
}
public void setCreTime(Date creTime) {
this.creTime = creTime;
}
public String getCrePerson() {
return crePerson;
}
public void setCrePerson(String crePerson) {
this.crePerson = crePerson;
}
public Date getUptTime() {
return uptTime;
}
public void setUptTime(Date uptTime) {
this.uptTime = uptTime;
}
public String getUptPerson() {
return uptPerson;
}
public void setUptPerson(String uptPerson) {
this.uptPerson = uptPerson;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public BigDecimal getYearType() {
return yearType;
}
public void setYearType(BigDecimal yearType) {
this.yearType = yearType;
}
public BigDecimal getSeasonType() {
return seasonType;
}
public void setSeasonType(BigDecimal seasonType) {
this.seasonType = seasonType;
}
public BigDecimal getMonthType() {
return monthType;
}
public void setMonthType(BigDecimal monthType) {
this.monthType = monthType;
}
public BigDecimal getSecondType() {
return secondType;
}
public void setSecondType(BigDecimal secondType) {
this.secondType = secondType;
}
}
\ No newline at end of file
package com.jz.common.utils;
/**
* 常量
*
*/
public class Constants {
public static final String SIGN_TYPE_RSA = "RSA";
/**
* sha256WithRsa 算法请求类型
*/
public static final String SIGN_TYPE_RSA2 = "RSA2";
public static final String ENCRYPT_TYPE_AES = "AES";
public static final String APP_KEY = "app_key";
public static final String FORMAT = "format";
public static final String METHOD = "method";
public static final String TIMESTAMP = "timestamp";
public static final String VERSION = "version";
public static final String SIGN_TYPE = "sign_type";
public static final String SIGN = "sign";
public static final String CHARSET = "charset";
public static final String ENCRYPT_TYPE = "encrypt_type";
public static final String PARAMS = "params";
public static final String RESPONSE = "response";
public static final String SUCCESS = "SUCCESS";
/** 默认时间格式 **/
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/** Date默认时区 **/
public static final String DATE_TIMEZONE = "GMT+8";
/** UTF-8字符集 **/
public static final String CHARSET_UTF8 = "UTF-8";
/** GBK字符集 **/
public static final String CHARSET_GBK = "GBK";
/** JSON 应格式 */
public static final String FORMAT_JSON = "JSON";
/** 生成内部授权码格式 */
public static final String AUTH_INT = "INT";
/** 生成外部授权码格式 */
public static final String AUTH_OUT = "OUT";
/** XML 应格式 */
public static final String FORMAT_XML = "XML";
/** 默认版本 */
public static final String DEFAULT_VERSION = "1.0.0";
public static final int FILTER_ORDER_0 = 0;
public static final int FILTER_ORDER_1 = 1;
public static final int FILTER_ORDER_2 = 2;
public static final int FILTER_ORDER_3 = 3;
public static final int FILTER_ORDER_4 = 4;
public static final int FILTER_ORDER_5 = 5;
public static final int FILTER_ORDER_6 = 6;
}
package com.jz.common.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Random;
import java.util.regex.Pattern;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.util
* @PROJECT_NAME: jz-dm-parent
* @NAME: RandomUtil
* @DATE: 2020-12-30/9:50
* @DAY_NAME_SHORT: 周三
* @Description: 生成随机编码工具类
**/
@Slf4j
public class RandomUtil {
private final static int[] li_SecPosValue = {1601, 1637, 1833, 2078, 2274,
2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635, 3722, 3730, 3858,
4027, 4086, 4390, 4558, 4684, 4925, 5249, 5590};
private final static String[] lc_FirstLetter = {"a", "b", "c", "d", "e",
"f", "g", "h", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
"t", "w", "x", "y", "z"};
/**
* 生成指定长度字母+数字的随机数
*
* @param length 长度
* @return
*/
public static String getStringRandom(int length) {
String val = "";
Random random = new Random();
//参数length,表示生成几位随机数
for (int i = 0; i < length; i++) {
String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
//输出字母还是数字
if ("char".equalsIgnoreCase(charOrNum)) {
//输出是大写字母还是小写字母
int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
val += (char) (random.nextInt(26) + temp);
} else if ("num".equalsIgnoreCase(charOrNum)) {
val += String.valueOf(random.nextInt(10));
}
}
log.info("生成指定长度字母+数字的随机数为:{}", val);
return val;
}
/**
* 生成组织(内/外)部编码
*
* @param type 类型
* @param content
* @return
*/
public static String generateOrgCoding(String content, String type) {
String coding = "";
if (null == content || null == type) {
log.info("----------生成组织编码内容或类型不存在--------------");
return "";
}
/* boolean chineseWord = isChineseWord(content);
if (!chineseWord) {
log.info("----------编码中不能出现英文或者字母--------------");
return "";
}*/
StringBuilder builder = new StringBuilder();
if (Constants.AUTH_INT.equalsIgnoreCase(type)) {
builder.append("NEI");
} else {
builder.append("WAI");
}
String orgContent = getAllFirstLetter(content);
orgContent = orgContent.toUpperCase();
builder.append(orgContent);
if (builder.length() > 12) {
coding = builder.toString().substring(0, 13);
} else if (builder.length() == 12) {
coding = builder.toString();
} else if (builder.length() < 12) {
String random = getStringRandom(12 - builder.length());
builder.append(random);
coding = builder.toString();
log.info("-----------生成的组织编码为:{}", coding);
}
return coding;
}
/**
* 生成内/外部授权码
*
* @param orgCode
* @param userId
* @param type
* @return
*/
public static String generateTokenCode(String type, String orgCode, String userId) {
String coding = "";
StringBuilder builder = new StringBuilder();
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
int second = cal.get(Calendar.SECOND);
builder.append(year);//年
if (StringUtils.isNotBlank(type) && Constants.AUTH_INT.equalsIgnoreCase(type)) {//内部授权码
if (StringUtils.isBlank(orgCode)) {
return "";
}
coding = getCodeInfo(orgCode, coding, builder, month, day, hour, minute, second);
} else if (StringUtils.isNotBlank(type) && Constants.AUTH_OUT.equalsIgnoreCase(type)) { //外部组织
if (StringUtils.isBlank(userId)) {
return "";
}
if (userId.length() < 8) { //补全用户id
String userNum = addZeroForNum(userId, 8);
builder.append(userNum);
}
coding = getCodeInfo(userId, coding, builder, month, day, hour, minute, second);
}
return coding;
}
/**
* 拼接内部/外部授权码
*
* @param orgCode
* @param coding
* @param builder
* @param month
* @param day
* @param hour
* @param minute
* @param second
* @return
*/
private static String getCodeInfo(String orgCode, String coding,
StringBuilder builder, int month,
int day, int hour, int minute, int second) {
builder.append(orgCode);//组织编码
builder.append(month);//月
builder.append(day);//日
builder.append(hour);//时
builder.append(minute);//分
builder.append(second);//秒
if (builder.length() > 32) {
coding = builder.toString().substring(0, 33);
} else if (builder.length() == 32) {
coding = builder.toString();
} else if (builder.length() < 32) {
String random = getStringRandom(32 - builder.length());
builder.append(random);
coding = builder.toString();
log.info("-----------生成的内部授权码为:{}", coding);
}
return coding;
}
/**
* 取得给定汉字串的首字母串,即声母串
*
* @param str 给定汉字串
* @return 声母串
*/
public static String getAllFirstLetter(String str) {
if (str == null || str.trim().length() == 0) {
return "";
}
String _str = "";
for (int i = 0; i < str.length(); i++) {
_str = _str + getFirstLetter(str.substring(i, i + 1));
}
return _str;
}
/**
* 取得给定汉字的首字母,即声母
*
* @param chinese 给定的汉字
* @return 给定汉字的声母
*/
public static String getFirstLetter(String chinese) {
if (chinese == null || chinese.trim().length() == 0) {
return "";
}
chinese = conversionStr(chinese, "GB2312", "ISO8859-1");
if (chinese.length() > 1) { // 判断是不是汉字
int li_SectorCode = (int) chinese.charAt(0); // 汉字区码
int li_PositionCode = (int) chinese.charAt(1); // 汉字位码
li_SectorCode = li_SectorCode - 160;
li_PositionCode = li_PositionCode - 160;
int li_SecPosCode = li_SectorCode * 100 + li_PositionCode; // 汉字区位码
if (li_SecPosCode > 1600 && li_SecPosCode < 5590) {
for (int i = 0; i < 23; i++) {
if (li_SecPosCode >= li_SecPosValue[i]
&& li_SecPosCode < li_SecPosValue[i + 1]) {
chinese = lc_FirstLetter[i];
break;
}
}
} else // 非汉字字符,如图形符号或ASCII码
{
chinese = conversionStr(chinese, "ISO8859-1", "GB2312");
chinese = chinese.substring(0, 1);
}
}
return chinese;
}
/**
* 字符串编码转换
*
* @param str 要转换编码的字符串
* @param charsetName 原来的编码
* @param toCharsetName 转换后的编码
* @return 经过编码转换后的字符串
*/
private static String conversionStr(String str, String charsetName, String toCharsetName) {
try {
str = new String(str.getBytes(charsetName), toCharsetName);
} catch (UnsupportedEncodingException ex) {
System.out.println("字符串编码转换异常:" + ex.getMessage());
}
return str;
}
/**
* 限制只能输入中文
*/
public static boolean isChineseWord(String str) {
String pattern = "[\u4e00-\u9fa5]+";
boolean isMatch = Pattern.matches(pattern, str);
return isMatch;
}
/**
* 生成8位用户id,不够的前面用0补全
*
* @param str
* @param strLength
* @return
*/
public static String addZeroForNum(String str, int strLength) {
int strLen = str.length();
if (strLen < strLength) {
while (strLen < strLength) {
StringBuffer sb = new StringBuffer();
sb.append("0").append(str);// 左补0
// sb.append(str).append("0");//右补0
str = sb.toString();
strLen = str.length();
}
}
return str;
}
/**
* 生成指定版本号
* @param version 旧版本号
* @return
*/
public static String generateVersion(String version) {
StringBuilder builder = new StringBuilder();
if (StringUtils.isNotBlank(version)) {
String[] split = version.substring(1).split("\\.");
Integer one = Integer.parseInt(split[0]);
Integer two = Integer.parseInt(split[1]);
if (two + 1 == 100) {
one = one + 1;
two = 0;
} else if (two < 100) {
two = two + 1;
}
builder.append("v");
builder.append(one.toString());
builder.append(".");
builder.append(two.toString());
}else {
return "";
}
return builder.toString();
}
public static void main(String[] args) {
//System.out.println(getStringRandom(8));
// System.out.println("获取拼音首字母:"+getAllFirstLetter("大中国南昌中大china"));
//System.out.println(isChineseWord("大中国南昌中大"));
//System.out.println(generateOrgCoding("九章数据","INT"));
// System.out.println(generateTokenCode("", ""));
//System.out.println(addZeroForNum("1", 8));
//System.out.println("内部授权码:" + generateTokenCode("INT", "NEIJZSJ900hx", ""));//内部授权码
//System.out.println("外部授权码:" + generateTokenCode("OUT", "", "199"));//内部授权码
System.out.println(generateVersion("v1.99"));
}
}
......@@ -128,6 +128,69 @@
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>static/**</exclude>
<exclude>xls/**</exclude>
<exclude>conf/**</exclude>
<exclude>emails/**</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>static/**</include>
<include>xls/**</include>
<include>conf/**</include>
<include>emails/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<!-- 过滤后缀为pem、pfx的证书文件 -->
<nonFilteredFileExtensions>
<nonFilteredFileExtension>p12</nonFilteredFileExtension>
<nonFilteredFileExtension>pem</nonFilteredFileExtension>
<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
......@@ -44,9 +44,6 @@ public class DataGoodsApiController extends BaseController {
public Result<List<DataGoodsApiDto>> findById(@PathVariable(value = "id") Long id) {
if (id != null) {
Result result = tDataGoodsApiService.selectById(id);
result.getMessage();
result.getCode();
result.getData();
return result;
}
return new Result<>(false, "查询商品详情失败!",StatusCode.ERROR);
......
......@@ -50,6 +50,9 @@ public class DataDetailsDto implements Serializable {
@ApiModelProperty(value = "api接口方法")
private String apiMethod;
@ApiModelProperty(value = "商品价格")
private BigDecimal dataPrice;
/**
* 返回类型
*/
......
......@@ -94,6 +94,9 @@ public class DataGoodsApiDto implements Serializable {
@ApiModelProperty(value = "价格类型")
private String priceType;
@ApiModelProperty(value = "商品价格")
private BigDecimal dataPrice;
/**
* 供应商名称
*/
......
......@@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
*/
@RestController
@RequestMapping("/pay")
@CrossOrigin
@Api(tags = "支付controller")
public class PayController {
......
......@@ -21,6 +21,6 @@ public interface DataGoodsApiDao extends BaseMapper<DataGoodsApi> {
* @param id
* @return
*/
List<DataGoodsApiDto> selectById(@Param("goodsApi") Long id);
List<DataGoodsApiDto> selectById(@Param("dataGoodsId") Long id);
}
\ No newline at end of file
......@@ -81,6 +81,7 @@ public class DataGoodsApiServiceImpl implements DataGoodsApiService {
data.setReturnType(goods.getReturnType());
data.setDataPicture(goods.getDataPicture());
data.setDataDesc(goods.getDataDesc());
data.setDataPrice(goods.getDataPrice());
map.put("dataInfo", data);
// 商品参数
......
......@@ -61,7 +61,7 @@ public class MallCustomerServiceImpl implements MallCustomerService {
request.getSession().setAttribute("mallCustomer", mallCustomerApiDto);
// 存入到redis
redisTemplate.opsForValue().set("user_" + RedisMessageConstant.SENDTYPE_LOGIN_CUSTOMER, mallCustomerApiDto, 3, TimeUnit.DAYS);
redisTemplate.opsForValue().set("USER_" + RedisMessageConstant.SENDTYPE_LOGIN_CUSTOMER, mallCustomerApiDto, 3, TimeUnit.DAYS);
}
return mallCustomer;
}
......@@ -88,7 +88,7 @@ public class MallCustomerServiceImpl implements MallCustomerService {
request.getSession().setAttribute("mallCustomer", mallCustomerApiDto);
// 存入到redis
redisTemplate.opsForValue().set("user_" + RedisMessageConstant.SENDTYPE_LOGIN_CUSTOMER, mallCustomerApiDto, 3, TimeUnit.DAYS);
redisTemplate.opsForValue().set("USER_" + RedisMessageConstant.SENDTYPE_LOGIN_CUSTOMER, mallCustomerApiDto, 3, TimeUnit.DAYS);
}
return mallCustomer;
}
......
......@@ -131,20 +131,24 @@ public class PayServiceImpl implements PayService {
}
BigDecimal subtract = bigDecimal.subtract(bigDecima2);
String uri = "http://127.0.0.1:8088/api/auth/mall-user-auth-api";
String uri = "http://127.0.0.1:8088/api/auth/mall-user-auth-api"; // TODO
AuthMallUserApiReq apiReq = new AuthMallUserApiReq();
if ("04".equals(payDto.getPurchaseMethod())) {
apiReq.setAuthMode(AuthModeEnum.RECORD_TIME_MODE);
}else {
apiReq.setAuthMode(AuthModeEnum.RECORD_TIME_MODE);
}
apiReq.setApiKey(payDto.getApiKey());
apiReq.setAuthMode(AuthModeEnum.RECORD_TIME_MODE);
apiReq.setAuthType(AuthTypeEnum.DATA_BANK_AUTH);
apiReq.setOrgCode("WAISJYX40E3e"); // TODO
apiReq.setOrgType("OUT");
apiReq.setUserId(payDto.getCustomerId() + "");
apiReq.setValidStartTime(order.getTakeEffectTime());
apiReq.setValidEndTime(order.getInvalidTime());
String post = RestTemplateUtils.post(uri, JSON.toJSONString(apiReq));
JSONObject params = JSONObject.parseObject(post);
if (params.get("success").equals("false") || StringUtils.isEmpty(params.get("data"))){
if (!params.get("code").equals(200) || StringUtils.isEmpty(params.get("data"))){
return Result.of_error("授权失败!");
}
assets.setUseMoney(subtract);
......@@ -159,7 +163,7 @@ public class PayServiceImpl implements PayService {
FinanceTradeFlow flow = new FinanceTradeFlow();
flow.setAssetsId(assetsId);
flow.setOrderId(orderId);
// flow.setTradeFlowNumber();// 交易流水编号
flow.setTradeFlowNumber(NumberUtils.getDealNum());// 交易流水编号
flow.setTradeMoney(payDto.getDataPrice());
flow.setTradeType("03");
flow.setCreTime(DateUtils.getToday());
......@@ -167,7 +171,7 @@ public class PayServiceImpl implements PayService {
flow.setTradeFlowNumber(NumberUtils.getDealNum());
financeTradeFlowDao.addFlow(flow);
}
return Result.of_success(ResultMsg.SUCCESS, ResultCode.SUCCESS);
return Result.of_success(ResultMsg.SUCCESS,params);
}
......
......@@ -36,6 +36,7 @@
t1.return_data_example AS returnDataExample,
t1.request_example AS requestExample,
t1.api_key as apiKey,
t2.data_price as dataPrice,
t2.data_picture as dataPicture,
t3.supplier_name AS supplierName,
t4.api_params_id AS apiParamsId,
......@@ -56,13 +57,13 @@
( CASE WHEN t4.params_diff = '01' THEN '公共参数' WHEN t4.params_diff = '02' THEN '请求参数' WHEN t4.params_diff = '03' THEN '响应参数' WHEN t4.params_diff = '04' THEN '请求头参数' WHEN t4.params_diff = '05' THEN '状态码参数' end ) AS paramsDiff
FROM
t_data_goods_api t1
INNER JOIN t_data_goods t2 ON t1.data_goods_id = t2.data_goods_id
INNER JOIN t_sys_user t3 ON t3.user_id = t2.user_id
left JOIN t_data_goods t2 ON t1.data_goods_id = t2.data_goods_id
left JOIN t_sys_user t3 ON t3.user_id = t2.user_id
INNER JOIN t_data_goods_api_params t4 ON t4.goods_api = t1.goods_api
INNER JOIN t_data_goods_category t5 ON t5.category_id = t2.category_id
WHERE
1 = 1
AND t1.del_flag = 'N'
<if test="goodsApi != null"> and t1.goods_api = #{goodsApi}</if>
<if test="dataGoodsId != null"> and t2.data_goods_id = #{dataGoodsId}</if>
</select>
</mapper>
\ No newline at end of file
package com.jz.manage;
import com.jz.common.utils.HttpsUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -21,7 +22,7 @@ public class manageApplication {
}
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
public HttpsUtils restTemplate() {
return new HttpsUtils();
}
}
......@@ -12,6 +12,7 @@ import com.jz.manage.moduls.controller.customer.bean.request.EnterpriseAuditRequ
import com.jz.manage.moduls.controller.customer.bean.request.SaveCustomerRequest;
import com.jz.manage.moduls.service.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
......@@ -79,7 +80,7 @@ public class DepartmentController extends BaseController {
* @return
*/
@PostMapping(value = "/audit/{id}")
@ApiModelProperty(value = "企业审核")
@ApiOperation(value = "企业审核")
public Result audit(@PathVariable(value = "id") Long id, HttpServletRequest req) throws Exception{
if (id != null) {
departmentService.audit(id, req);
......@@ -96,12 +97,10 @@ public class DepartmentController extends BaseController {
* @throws Exception
*/
@PostMapping(value = "/add")
@ApiModelProperty(value = "添加用户")
@ApiOperation(value = "添加用户")
public Result add(@RequestBody SaveCustomerRequest saveCustomerRequest, HttpServletRequest req) throws Exception {
if (saveCustomerRequest != null) {
Result result = departmentService.add(saveCustomerRequest, req);
result.getMessage();
result.getCode();
return result;
}
return new Result<CompanyDetailsDto>(false, "添加用户失败!", StatusCode.ERROR);
......
......@@ -7,6 +7,7 @@ import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
......@@ -25,8 +26,6 @@ public class DataApiUpReq implements Serializable {
/**
* api表
*/
@ApiModelProperty(value = "api服务名称")
private String apiName;
@ApiModelProperty(value = "请求类型")
private String requestType;
......@@ -40,46 +39,28 @@ public class DataApiUpReq implements Serializable {
@ApiModelProperty(value = "api返回数据样例")
private String returnDataExample;
@ApiModelProperty(value = "api请求样例")
private String requestExample;
@ApiModelProperty(value = "返回类型")
@ApiModelProperty(value = "返回类型 json/flow")
private String returnType;
@ApiModelProperty(value = "apikey")
private String apiKey;
@ApiModelProperty(value = "加密方式")
@ApiModelProperty(value = "加密方式 MD5/RSA")
private String encryMode;
@ApiModelProperty(value = "传输方式")
@ApiModelProperty(value = "传输方式 HTTP/HTTPS")
private String transMode;
@ApiModelProperty(value = "功能")
private String apiFunction;
@ApiModelProperty(value = "每单接口调用频率")
private String oneCallFrequency;
@ApiModelProperty(value = "每个接口的调用频率")
private String allCallFrequency;
@ApiModelProperty(value = "客户请求token")
private String requestToken;
@ApiModelProperty(value = "版本号")
private String versionNumber;
@ApiModelProperty(value = "创建人")
@ApiModelProperty(value = "创建人", hidden = true)
private String crePerson;
@ApiModelProperty(value = "创建时间")
private Date creTime;
@ApiModelProperty(value = "价格类型")
private String priceType;
@ApiModelProperty(value = "api类型")
@ApiModelProperty(value = "api类型 01:api 02: 数据包")
private String apiType;
@ApiModelProperty(value = "接口描述",required = false)
......@@ -99,30 +80,19 @@ public class DataApiUpReq implements Serializable {
@ApiModelProperty(value = "商品分类")
private Long categoryId;
@ApiModelProperty(value = "数据id")
private String dataGoodsId;
@ApiModelProperty(value = "数据描述")
private String dataDesc;
@ApiModelProperty(value = "商品图片")
private String dataPicture;
@ApiModelProperty(value = "数据状态")
private String dataStatus;
@ApiModelProperty(value = "唯一数据商品标识")
private String apiOpenId;
@ApiModelProperty(value = "审核状态")
private String auditStatus;
@ApiModelProperty(value = "审核人")
@ApiModelProperty(value = "审核人" , hidden = true)
private String auditPerson;
@ApiModelProperty(value = "审核时间")
private Date auditTime;
@ApiModelProperty(value = "年(元)")
private BigDecimal yearType;
......@@ -138,6 +108,26 @@ public class DataApiUpReq implements Serializable {
/**
* apiParam
*/
@ApiModelProperty(value = "参数集合")
private List<DataGoodsApiParams> paramsList;
@ApiModelProperty(value = "请求头")
private List<DataGoodsApiParams> reqHeaders;
@ApiModelProperty(value = "请求参数")
private List<DataGoodsApiParams> requestParam;
@ApiModelProperty(value = "响应参数")
private List<DataGoodsApiParams> responseParam;
@ApiModelProperty(value = "固定参数")
private List<DataGoodsApiParams> inboxParam;
@ApiModelProperty(value = "响应状态码参数")
public List<DataGoodsApiParams> respCode;
/**
* 接口需要的参数
*/
@ApiModelProperty(value = "接入类型:对应字典表key",required = true)
@NotNull(message = "接入类型不能为空")
public String joinType;
}
package com.jz.manage.moduls.controller.goods.bean.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @author ZC
......@@ -24,23 +26,32 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull(message = "api类型不能为空")
public String apiType;
// @ApiModelProperty(value = "apiId 等价于apiKey",required = true)
// @NotNull(message = "apiId不能为空")
// public String apiId;
@ApiModelProperty(value = "接口描述",required = false)
public String apiDesc;
// @ApiModelProperty(value = "api版本",required = false)
// public String version;
@ApiModelProperty(value = "传输方式(1为HTTPS,2为HTTP)",required = true)
@NotNull(message = "传输方式不能为空")
public String apiProtocl;
@ApiModelProperty(value = "加密方式0 无,1:MD5 2:RSA",required = true)
@NotNull(message = "加密方式不能为空")
public String type;
public String signType;
@ApiModelProperty(value = "接入类型:对应字典表key",required = true)
@NotNull(message = "接入类型不能为空")
public String joinType;
@ApiModelProperty(value = "输出类型:flow 流,json json形式", required = true)
@NotNull(message = "输出类型不能为空")
public String outputType;
@ApiModelProperty(value = "是否分页 page", required = true)
// @NotNull(message = "分页不能为空")
public String page;
@ApiModelProperty(value = "接口描述",required = false)
public String apiDesc;
@ApiModelProperty(value = "接口地址")
private String apiUrl;
@ApiModelProperty(value = "目标地址",required = false)
public String targetUrl;
......@@ -51,6 +62,9 @@ public class MakeDataBankApiReq implements Serializable {
@ApiModelProperty(value = "api描述",required = false)
public String apiFunction;
@ApiModelProperty(value = "固定参数", required = false)
private String inboxParam;
@ApiModelProperty(value = "请求头",required = false)
public String reqHeaders;
......@@ -66,7 +80,9 @@ public class MakeDataBankApiReq implements Serializable {
@ApiModelProperty(value = "api样例",required = false)
public String apiExample;
@ApiModelProperty(value = "文件id")
@ApiModelProperty(value = "文件id",required = false)
//@NotNull(message = "文件id不能为空")
public Long fileId;
}
......@@ -2,6 +2,7 @@ package com.jz.manage.moduls.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
......@@ -77,6 +78,9 @@ public class DataGoods implements Serializable {
* 驳回原因
*/
private String rejectReason;
@ApiModelProperty(value = "唯一数据商品标识")
private String apiOpenId;
/**
* 审核人
*/
......
package com.jz.manage.moduls.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
......@@ -14,11 +18,14 @@ import java.util.Date;
*/
@TableName("t_data_goods_api")
@ApiModel
@Data
public class DataGoodsApi implements Serializable {
private static final long serialVersionUID = -14346819849726413L;
/**
* api商品id
*/
@ApiModelProperty(value = "主健ID")
@TableId(value = "id", type = IdType.AUTO)
private Long goodsApi;
/**
* 数据id
......@@ -81,133 +88,22 @@ public class DataGoodsApi implements Serializable {
*/
private String delFlag;
/**
* 加密方式
*/
private String encryMode;
public Long getGoodsApi() {
return goodsApi;
}
public void setGoodsApi(Long goodsApi) {
this.goodsApi = goodsApi;
}
public Long getDataGoodsId() {
return dataGoodsId;
}
public void setDataGoodsId(Long dataGoodsId) {
this.dataGoodsId = dataGoodsId;
}
public String getApiName() {
return apiName;
}
public void setApiName(String apiName) {
this.apiName = apiName;
}
public String getRequestType() {
return requestType;
}
public void setRequestType(String requestType) {
this.requestType = requestType;
}
public String getApiUrl() {
return apiUrl;
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getApiMethod() {
return apiMethod;
}
public void setApiMethod(String apiMethod) {
this.apiMethod = apiMethod;
}
public String getApiProtocl() {
return apiProtocl;
}
public void setApiProtocl(String apiProtocl) {
this.apiProtocl = apiProtocl;
}
public String getReturnDataExample() {
return returnDataExample;
}
public void setReturnDataExample(String returnDataExample) {
this.returnDataExample = returnDataExample;
}
public String getRequestExample() {
return requestExample;
}
public void setRequestExample(String requestExample) {
this.requestExample = requestExample;
}
public String getReturnType() {
return returnType;
}
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public Date getCreTime() {
return creTime;
}
public void setCreTime(Date creTime) {
this.creTime = creTime;
}
public String getCrePerson() {
return crePerson;
}
public void setCrePerson(String crePerson) {
this.crePerson = crePerson;
}
public String getUptPerson() {
return uptPerson;
}
public void setUptPerson(String uptPerson) {
this.uptPerson = uptPerson;
}
/**
* 传输方式
*/
private String transMode;
public Date getUptTime() {
return uptTime;
}
/**
* 版本号
*/
private String versionNumber;
public void setUptTime(Date uptTime) {
this.uptTime = uptTime;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
......@@ -18,6 +19,7 @@ import java.util.Date;
*/
@TableName("t_data_goods_api_params")
@ApiModel
@Data
public class DataGoodsApiParams implements Serializable {
private static final long serialVersionUID = 944366688061324185L;
/**
......@@ -76,6 +78,10 @@ public class DataGoodsApiParams implements Serializable {
*/
@ApiModelProperty(value = "创建时间")
private Date creTime;
@ApiModelProperty(value = "创建人")
private String crePerson;
/**
* 更新时间
*/
......@@ -83,100 +89,6 @@ public class DataGoodsApiParams implements Serializable {
private Date uptTime;
public Long getApiParamsId() {
return apiParamsId;
}
public void setApiParamsId(Long apiParamsId) {
this.apiParamsId = apiParamsId;
}
public Long getGoodsApi() {
return goodsApi;
}
public void setGoodsApi(Long goodsApi) {
this.goodsApi = goodsApi;
}
public String getParamsDiff() {
return paramsDiff;
}
public void setParamsDiff(String paramsDiff) {
this.paramsDiff = paramsDiff;
}
public String getParamsName() {
return paramsName;
}
public void setParamsName(String paramsName) {
this.paramsName = paramsName;
}
public String getParamsType() {
return paramsType;
}
public void setParamsType(String paramsType) {
this.paramsType = paramsType;
}
public String getParamsDesc() {
return paramsDesc;
}
public void setParamsDesc(String paramsDesc) {
this.paramsDesc = paramsDesc;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getIfRequird() {
return ifRequird;
}
public void setIfRequird(String ifRequird) {
this.ifRequird = ifRequird;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public Date getCreTime() {
return creTime;
}
public void setCreTime(Date creTime) {
this.creTime = creTime;
}
public Date getUptTime() {
return uptTime;
}
public void setUptTime(Date uptTime) {
this.uptTime = uptTime;
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ import com.jz.manage.moduls.mapper.DataGoodsApiParamsDao;
import com.jz.manage.moduls.mapper.DataGoodsDao;
import com.jz.manage.moduls.service.DataGoodsService;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -37,21 +37,16 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.client.RestTemplate;
/**
* 数据商品(DataGoods)表服务实现类
......@@ -60,6 +55,7 @@ import org.springframework.web.client.RestTemplate;
* @since 2020-12-01 10:41:30
*/
@Service("dataGoodsService")
@CrossOrigin
public class DataGoodsServiceImpl implements DataGoodsService {
@Autowired
private DataGoodsDao dataGoodsDao;
......@@ -74,7 +70,7 @@ public class DataGoodsServiceImpl implements DataGoodsService {
private DataGoodsApiDao tDataGoodsApiDao;
@Autowired
private RestTemplate restTemplate;
private HttpsUtils httpsUtils;
/**
* 条件分页查询数据列表
*
......@@ -242,16 +238,16 @@ public class DataGoodsServiceImpl implements DataGoodsService {
* @param dataApiUpReq
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Result uploadApi(DataApiUpReq dataApiUpReq) throws Exception {
// 获取当前用户
SysUserDto user = (SysUserDto) redisTemplate.opsForValue().get("user_" + RedisMessageConstant.SENDTYPE_LOGIN_SYS);
SysUserDto user = (SysUserDto) redisTemplate.opsForValue().get("USER_" + RedisMessageConstant.SENDTYPE_LOGIN_SYS);
if (dataApiUpReq == null) {
return Result.error("上传失败!");
}
if (!StringUtils.isNotEmpty(dataApiUpReq.getApiKey())) {
return Result.error("apiKey不存在!");
if (!StringUtils.isNotEmpty(dataApiUpReq.getJoinType())) {
return Result.error("接入类型不存在!");
}
if (!StringUtils.isNotEmpty(dataApiUpReq.getApiType())) {
return Result.error("api类型不存在!");
......@@ -262,15 +258,55 @@ public class DataGoodsServiceImpl implements DataGoodsService {
if (!StringUtils.isNotEmpty(dataApiUpReq.getEncryMode())) {
return Result.error("加密方式不能为空!");
}
// 调用getway获取apikey
MakeDataBankApiReq apiReq = new MakeDataBankApiReq();
apiReq.setApiType(dataApiUpReq.getApiType());
apiReq.setApiDesc(dataApiUpReq.getApiDesc());
apiReq.setApiProtocl(dataApiUpReq.getApiProtocl());
apiReq.setSignType(dataApiUpReq.getEncryMode());
apiReq.setTargetUrl(dataApiUpReq.getTargetUrl());
apiReq.setApiFunction(dataApiUpReq.getApiFunction());
apiReq.setApiUrl(dataApiUpReq.getApiUrl());
apiReq.setJoinType(dataApiUpReq.getJoinType());
apiReq.setOutputType(dataApiUpReq.getReturnType());
// apiReq.setPage(); // TODO
apiReq.setFileId(1L);
apiReq.setTimeout(dataApiUpReq.getOverTime() + "");
for (DataGoodsApiParams params : dataApiUpReq.getInboxParam()) {
apiReq.setInboxParam(JSON.toJSONString(params));
}
for (DataGoodsApiParams reqHeader : dataApiUpReq.getReqHeaders()) {
apiReq.setReqHeaders(JSON.toJSONString(reqHeader));
}
for (DataGoodsApiParams params : dataApiUpReq.getRequestParam()) {
apiReq.setRequestParam(JSON.toJSONString(params));
}
for (DataGoodsApiParams params : dataApiUpReq.getResponseParam()) {
apiReq.setResponseParam(JSON.toJSONString(params));
}
for (DataGoodsApiParams params : dataApiUpReq.getRespCode()) {
apiReq.setResponseParam(JSON.toJSONString(params));
}
apiReq.setApiExample(dataApiUpReq.getReturnDataExample());
String url= "http://47.115.53.1:8088/api/producer/addDataBankApiInfo";
// String url= "http://127.0.0.1:8088/api/producer/addDataBankApiInfo";
String post = httpsUtils.submitPost(url, JSON.toJSONString(apiReq));
System.out.println(post);
JSONObject result = JSON.parseObject(post);
if (!result.get("code").equals(200) || org.springframework.util.StringUtils.isEmpty(result.get("data"))){
return Result.of_error("制作失败!");
}
//封装参数
DataGoods dataGoods = new DataGoods();
dataApiUpReq.setApiOpenId("wj"+DateUtils.getHMS());
dataApiUpReq.setCreTime(DateUtils.getToday());
dataApiUpReq.setCrePerson(user.getUserId() + "");
dataApiUpReq.setAuditTime(DateUtils.getToday());
dataApiUpReq.setAuditPerson(user.getUserId() + "");
dataApiUpReq.setAuditStatus("02");
dataApiUpReq.setDataStatus("02");
dataGoods.setApiOpenId(dataApiUpReq.getApiOpenId());
dataGoods.setCreTime(DateUtils.getToday());
dataGoods.setCrePerson(user.getUserId() + "");
dataGoods.setAuditTime(DateUtils.getToday());
dataGoods.setAuditPerson(user.getUserId() + "");
dataGoods.setAuditStatus("02");
dataGoods.setDataStatus("02");
BeanUtils.copyProperties(dataApiUpReq, dataGoods);
dataGoodsDao.insert(dataGoods);
......@@ -280,88 +316,80 @@ public class DataGoodsServiceImpl implements DataGoodsService {
DataGoodsApi dataGoodsApi = new DataGoodsApi();
dataGoodsApi.setDataGoodsId(dataGoodsId);
dataApiUpReq.setCreTime(DateUtils.getToday());
dataApiUpReq.setCrePerson(user.getUserId() + "");
dataApiUpReq.setEncryMode("MD5");
dataApiUpReq.setTransMode("http");
dataApiUpReq.setVersionNumber("1.0");
dataGoodsApi.setCreTime(DateUtils.getToday());
dataGoodsApi.setCrePerson(user.getUserId() + "");
dataGoodsApi.setEncryMode("MD5");
dataGoodsApi.setTransMode("http");
dataGoodsApi.setVersionNumber("v1.0");
dataGoodsApi.setApiKey(result.get("data").toString());
BeanUtils.copyProperties(dataApiUpReq, dataGoodsApi);
tDataGoodsApiDao.insert(dataGoodsApi);
apiReq.setApiDesc(dataApiUpReq.getApiDesc());
apiReq.setApiExample("");
apiReq.setApiFunction(dataApiUpReq.getApiFunction());
// apiReq.setApiId(dataApiUpReq.getApiKey());
apiReq.setApiType(dataApiUpReq.getApiType());
apiReq.setType(dataApiUpReq.getEncryMode());
apiReq.setTargetUrl(dataApiUpReq.getTargetUrl());
apiReq.setTimeout(dataApiUpReq.getOverTime() + "");
apiReq.setReqHeaders("sdadasd");
// apiReq.setFileId(1L);
String url= "http://127.0.0.1:8088/api/producer/addDataBankApiInfo";
System.out.println(JSON.toJSONString(apiReq));
// String post = RestTemplateUtils.post(url, JSON.toJSONString(apiReq) );
// String post = WebUtils.post(url, JSON.toJSONString(apiReq));
String s = doPostJson(url, JSON.toJSONString(apiReq));
System.out.println("dopost:" + s);
// 赋值params
Long goodsApi = dataGoodsApi.getGoodsApi();
if (goodsApi != null) {
List<DataGoodsApiParams> paramsList = dataApiUpReq.getParamsList();
for (DataGoodsApiParams params : paramsList) {
params.setGoodsApi(goodsApi);
dataApiUpReq.setCreTime(DateUtils.getToday());
dataApiUpReq.setCrePerson(user.getUserId() + "");
BeanUtils.copyProperties(dataApiUpReq, params);
apiParamsDao.insert(params);
// 公共参数
List<DataGoodsApiParams> inboxParam = dataApiUpReq.getInboxParam();
if (inboxParam != null || inboxParam.size() != 0) {
for (DataGoodsApiParams params : inboxParam) {
params.setGoodsApi(goodsApi);
params.setParamsDiff("01");
params.setCreTime(DateUtils.getToday());
params.setCrePerson(user.getUserId() + "");
BeanUtils.copyProperties(dataApiUpReq, params);
apiParamsDao.insert(params);
}
}
// 请求参数
List<DataGoodsApiParams> requestParam = dataApiUpReq.getRequestParam();
if (requestParam != null || requestParam.size() != 0) {
for (DataGoodsApiParams params : requestParam) {
params.setGoodsApi(goodsApi);
params.setParamsDiff("02");
params.setCreTime(DateUtils.getToday());
params.setCrePerson(user.getUserId() + "");
BeanUtils.copyProperties(dataApiUpReq, params);
apiParamsDao.insert(params);
}
}
// 响应参数
List<DataGoodsApiParams> responseParam = dataApiUpReq.getResponseParam();
if (responseParam != null || responseParam.size() != 0) {
for (DataGoodsApiParams params : responseParam) {
params.setGoodsApi(goodsApi);
params.setParamsDiff("03");
params.setCreTime(DateUtils.getToday());
params.setCrePerson(user.getUserId() + "");
BeanUtils.copyProperties(dataApiUpReq, params);
apiParamsDao.insert(params);
}
}
// 请求头参数
List<DataGoodsApiParams> paramsList = dataApiUpReq.getReqHeaders();
if (paramsList != null || paramsList.size() != 0) {
for (DataGoodsApiParams params : paramsList) {
params.setGoodsApi(goodsApi);
params.setParamsDiff("04");
params.setCreTime(DateUtils.getToday());
params.setCrePerson(user.getUserId() + "");
BeanUtils.copyProperties(dataApiUpReq, params);
apiParamsDao.insert(params);
}
}
// 状态码参数
List<DataGoodsApiParams> respCode = dataApiUpReq.getRespCode();
if (respCode != null || respCode.size() != 0) {
for (DataGoodsApiParams params : paramsList) {
params.setGoodsApi(goodsApi);
params.setParamsDiff("05");
params.setCreTime(DateUtils.getToday());
params.setCrePerson(user.getUserId() + "");
BeanUtils.copyProperties(dataApiUpReq, params);
apiParamsDao.insert(params);
}
}
}
}
//
try {
String url= "http://127.0.0.1:8088/api/producer/addDataBankApiInfo";
System.out.println(JSON.toJSONString(apiReq));
// String post = RestTemplateUtils.post(url, JSON.toJSONString(apiReq) );
// String post = WebUtils.post(url, JSON.toJSONString(apiReq));
// JSONObject object = doPOst(url, JSON.toJSONString(apiReq));
// System.out.println(object);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
// return Result.of_success(ResultMsg.SUCCESS, ResultCode.SUCCESS);
return Result.of_success(ResultMsg.SUCCESS, dataApiUpReq);
}
public static String doPostJson(String url, String json) {
// 创建Httpclient对象
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
String resultString = "";
try {
// 创建Http Post请求
HttpPost httpPost = new HttpPost(url);
// 创建请求内容
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
// 执行http请求
response = httpClient.execute(httpPost);
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return resultString;
return Result.of_success(ResultMsg.SUCCESS);
}
}
\ No newline at end of file
......@@ -51,7 +51,7 @@ public class SysUserServiceImpl implements SysUserService {
// 存入到session
SessionUtils.setUserCurrent("sysUser", SysUserDto, request);
// 存入到redis
redisTemplate.opsForValue().set("user_" + RedisMessageConstant.SENDTYPE_LOGIN_SYS, SysUserDto, 3, TimeUnit.DAYS);
redisTemplate.opsForValue().set("USER_" + RedisMessageConstant.SENDTYPE_LOGIN_SYS, SysUserDto, 3, TimeUnit.DAYS);
}
return sysUser;
}
......@@ -72,7 +72,7 @@ public class SysUserServiceImpl implements SysUserService {
// 存入到session
SessionUtils.setUserCurrent("sysUser", SysUserDto, request);
// 存入到redis
redisTemplate.opsForValue().set("user_" + RedisMessageConstant.SENDTYPE_LOGIN_SYS, SysUserDto, 3, TimeUnit.DAYS);
redisTemplate.opsForValue().set("USER_" + RedisMessageConstant.SENDTYPE_LOGIN_SYS, SysUserDto, 3, TimeUnit.DAYS);
}
return sysUser;
}
......
......@@ -29,6 +29,7 @@
<result property="seasonType" column="season_type" jdbcType="NUMERIC"/>
<result property="monthType" column="month_type" jdbcType="NUMERIC"/>
<result property="secondType" column="second_type" jdbcType="NUMERIC"/>
<result property="apiOpenId" column="api_openid" jdbcType="VARCHAR"/>
</resultMap>
<!--查询单个-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment