提交代码

master
胡锐 2 months ago
parent 69b5d9d3d3
commit 144d0eb3be
  1. 119
      openapi/src/main/java/com/openapi/controller/BsGasController.java
  2. 48
      service/src/main/java/com/hfkj/openapi/model/request/RequestQueryGasListModel.java

@ -0,0 +1,119 @@
package com.openapi.controller;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.pay.util.SignatureUtil;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.PageUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsAgentApiLogWithBLOBs;
import com.hfkj.entity.BsAgentApiParam;
import com.hfkj.entity.BsDiscountUser;
import com.hfkj.model.ResponseData;
import com.hfkj.openapi.model.request.RequestPushDiscountModel;
import com.hfkj.openapi.model.request.RequestPushPkDiscountModel;
import com.hfkj.openapi.model.request.RequestQueryCodeModel;
import com.hfkj.openapi.model.request.RequestQueryGasListModel;
import com.hfkj.openapi.model.response.ResponsePushDiscountModel;
import com.hfkj.openapi.model.response.ResponsePushDiscountPkModel;
import com.hfkj.openapi.model.response.ResponseQueryCodeModel;
import com.hfkj.service.agent.BsAgentApiLogService;
import com.hfkj.service.agent.BsAgentApiParamService;
import com.hfkj.service.agent.BsAgentDiscountService;
import com.hfkj.service.discount.BsDiscountUserService;
import com.hfkj.service.gas.BsGasService;
import com.hfkj.service.merchant.BsMerchantService;
import com.hfkj.sysenum.discount.DiscountStockCodeObtainTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/gas")
@Api(value = "油站管理")
public class BsGasController {
private static Logger log = LoggerFactory.getLogger(BsGasController.class);
@Resource
private BsAgentApiParamService agentApiParamService;
@Resource
private BsGasService gasService;
@Resource
private BsAgentApiLogService agentApiLogService;
@RequestMapping(value="/queryList",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "分页获取(全量)油站信息")
public ResponseData queryList(@Validated @RequestBody RequestQueryGasListModel body) {
log.info("========= Start 分页获取(全量)油站信息 Start ===========");
log.info("请求参数:" + JSONObject.toJSONString(body));
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs();
try {
// 验证签名
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId());
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, "");
}
// 验证请求id
if (agentApiLogService.isExist(body.getAppId(), body.getReqId())) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_REQ_ID_ERR, "");
}
apiLog.setAppId(body.getAppId());
apiLog.setRequestId(body.getReqId());
apiLog.setRequestUrl("gas/queryList");
apiLog.setRequestParam(JSONObject.toJSONString(body));
List<Map<String,Object>> codeMapList = new ArrayList<>();
/*for (BsDiscountUser discountUser : codeDataList) {
Map<String,Object> codeMap = new HashMap<>();
codeMap.put("discountNo", discountUser.getDiscountNo());
codeMap.put("phone", discountUser.getUserPhone());
codeMap.put("code", discountUser.getDiscountStockCode());
codeMap.put("status", discountUser.getStatus());
codeMap.put("createTime", DateUtil.date2String(discountUser.getCreateTime(), DateUtil.Y_M_D_HMS));
codeMap.put("expirationDate", DateUtil.date2String(discountUser.getExpirationDate(), DateUtil.Y_M_D_HMS));
codeMapList.add(codeMap);
}*/
ResponsePushDiscountModel response = new ResponsePushDiscountModel();
response.setReqId(body.getReqId());
response.setAppId(body.getAppId());
response.setCodeList(codeMapList);
response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret()));
log.info("返回参数:" + JSONObject.toJSONString(response));
apiLog.setResponseParam(JSONObject.toJSONString(response));
return ResponseMsgUtil.success(response);
} catch (Exception e) {
log.info("出现异常:", e);
// 异常内容
ResponseData exception = ResponseMsgUtil.exception(e);
apiLog.setErrorContent(JSONObject.toJSONString(exception));
return exception;
} finally {
// 记录日志
if (apiLog.getAppId() != null) {
agentApiLogService.edit(apiLog);
}
log.info("========= END 分页获取(全量)油站信息 END ===========");
}
}
}

@ -0,0 +1,48 @@
package com.hfkj.openapi.model.request;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @className: RequestQueryGasListModel
* @author: HuRui
* @date: 2024/9/18
**/
@Data
public class RequestQueryGasListModel {
/**
* appid
*/
@NotBlank(message = "请求id必填项")
private String reqId;
/**
* appid
*/
@NotBlank(message = "appId必填项")
private String appId;
/**
* 分页页数
*/
@NotNull(message = "页数必填项")
private Integer pageNum;
/**
* 每页数量
*/
@Range(min = 1, max = 50,message = "数量必须设置在1至100之内")
@NotNull(message = "每页数量必填项")
private Integer pageSize;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}
Loading…
Cancel
Save