获取openId接口
This commit is contained in:
@ -51,7 +51,10 @@ public class DeviceReportInfoController extends BaseController
|
||||
public TableDataInfo list(DeviceReportInfo deviceReportInfo)
|
||||
{
|
||||
startPage();
|
||||
|
||||
List<DeviceReportInfo> list = deviceReportInfoService.selectDeviceReportInfoList(deviceReportInfo);
|
||||
|
||||
|
||||
//查询设备在线状态
|
||||
list.forEach(d->{
|
||||
if(d.getType()==1){
|
||||
@ -67,6 +70,7 @@ public class DeviceReportInfoController extends BaseController
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return getDataTable(list);
|
||||
}
|
||||
//统计是设备相关信息
|
||||
|
@ -52,6 +52,22 @@ import static com.fastbee.rechargecard.service.impl.UserWechatPayServiceImpl.api
|
||||
@RestController
|
||||
@RequestMapping("/pay")
|
||||
public class WeChatPayController extends BaseController {
|
||||
/** 商户号 */
|
||||
public static String mchId = "1531795301";
|
||||
/** 商户API私钥文件路径 */
|
||||
public static String privateKeyPath = "fastbee-common/src/main/java/com/fastbee/common/utils/pay/apiclient_key.pem";
|
||||
/** 商户API证书序列号 */
|
||||
public static String serial_no = "3075B63EF52666EDC3EAFC5D4FB35C02CE123A9C";
|
||||
/** 商户APIV3密钥 */
|
||||
public static String apiV3Key = "e85a203e8ca146102f5cd7ecff912580";
|
||||
//微信小程序appid
|
||||
public static String appId="wx308612d2a8423311";
|
||||
//请求随机串
|
||||
public static String nonce_str="";
|
||||
//时间戳
|
||||
public static String timeStamp="";
|
||||
// 使用HttpClientBuilder创建CloseableHttpClient实例,采用默认配置
|
||||
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
@Autowired
|
||||
private INgUserRechargeRecordsService ngUserRechargeRecordsService;
|
||||
@ -62,6 +78,36 @@ public class WeChatPayController extends BaseController {
|
||||
@Autowired
|
||||
private IUserWechatPayService userWechatPayService;
|
||||
|
||||
/**
|
||||
* 获取openId
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("获取openId")
|
||||
@PostMapping("/getOpenId")
|
||||
public Map<String,Object> BuildOrder(@RequestBody String code)
|
||||
{
|
||||
Map<String ,Object> result=userWechatPayService.GetOpenId(code);
|
||||
Map<String,Object> returnParams=new HashMap<>();
|
||||
if(result.get("openid")==null && result.get("errcode")!=null)
|
||||
{
|
||||
if(result.get("errcode").equals(40163))
|
||||
{
|
||||
returnParams.put("code",401);
|
||||
returnParams.put("message","验证码已经被使用,请重新获取");
|
||||
return returnParams;
|
||||
//return warn("验证码已经被使用,请重新获取");
|
||||
}else if(result.get("errcode").equals(40029))
|
||||
{
|
||||
returnParams.put("code",403);
|
||||
returnParams.put("message","验证码已失效,请重新获取");
|
||||
return returnParams;
|
||||
//return warn("验证码已失效,请重新获取");
|
||||
}
|
||||
}
|
||||
return success(result.get("openid").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付生成订单
|
||||
* @return 登录结果
|
||||
@ -140,14 +186,23 @@ public class WeChatPayController extends BaseController {
|
||||
* responseBody 应答报文主体
|
||||
* publicKey 微信支付公钥(PEM 格式,去掉头尾并解码为二进制)
|
||||
*/
|
||||
/*String publicKey=wxPayConfig.getPublicKey(publicKeyPath);//读取并预处理后的微信支付公钥
|
||||
//String publicKey= wxPayConfig.getPublicKey(publicKeyPath);//读取并预处理后的微信支付公钥
|
||||
/*String Authorization=
|
||||
String publicKey=userWechatPayService.getPublicKeyByCertificat();
|
||||
boolean isVerified = verifySignature(wechatpaySignature, wechatpayTimestamp, wechatpayNonce, json, publicKey);
|
||||
if (isVerified) {
|
||||
System.out.println("签名验证成功");
|
||||
} else {
|
||||
System.out.println("签名验证失败");
|
||||
return error("签名验证失败");
|
||||
responseBody.put("code", "FAIL");
|
||||
responseBody.put("message", "签名验证失败");
|
||||
|
||||
// 返回500状态码以及符合要求的应答报文
|
||||
return new ResponseEntity<>(responseBody, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
//return error("签名验证失败");
|
||||
}*/
|
||||
|
||||
|
||||
//使用apiv3key解密
|
||||
String decryptData="";
|
||||
try{
|
||||
@ -212,7 +267,4 @@ public class WeChatPayController extends BaseController {
|
||||
//return error("修改数据库失败");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,110 @@
|
||||
package com.fastbee.data.controller.userRecharge;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.rechargecard.domain.NgIrrigationArea;
|
||||
import com.fastbee.rechargecard.service.INgIrrigationAreaService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 灌区Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-12-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rechargecard/area")
|
||||
@Api(tags = "灌区")
|
||||
public class NgIrrigationAreaController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private INgIrrigationAreaService ngIrrigationAreaService;
|
||||
|
||||
/**
|
||||
* 查询灌区列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('rechargecard:area:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询灌区列表")
|
||||
public TableDataInfo list(NgIrrigationArea ngIrrigationArea)
|
||||
{
|
||||
startPage();
|
||||
List<NgIrrigationArea> list = ngIrrigationAreaService.selectNgIrrigationAreaList(ngIrrigationArea);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出灌区列表
|
||||
*/
|
||||
@ApiOperation("导出灌区列表")
|
||||
@PreAuthorize("@ss.hasPermi('rechargecard:area:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, NgIrrigationArea ngIrrigationArea)
|
||||
{
|
||||
List<NgIrrigationArea> list = ngIrrigationAreaService.selectNgIrrigationAreaList(ngIrrigationArea);
|
||||
ExcelUtil<NgIrrigationArea> util = new ExcelUtil<NgIrrigationArea>(NgIrrigationArea.class);
|
||||
util.exportExcel(response, list, "灌区数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取灌区详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('rechargecard:area:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取灌区详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(ngIrrigationAreaService.selectNgIrrigationAreaById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增灌区
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('rechargecard:area:add')")
|
||||
@PostMapping
|
||||
@ApiOperation("新增灌区")
|
||||
public AjaxResult add(@RequestBody NgIrrigationArea ngIrrigationArea)
|
||||
{
|
||||
return toAjax(ngIrrigationAreaService.insertNgIrrigationArea(ngIrrigationArea));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改灌区
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('rechargecard:area:edit')")
|
||||
@PutMapping
|
||||
@ApiOperation("修改灌区")
|
||||
public AjaxResult edit(@RequestBody NgIrrigationArea ngIrrigationArea)
|
||||
{
|
||||
return toAjax(ngIrrigationAreaService.updateNgIrrigationArea(ngIrrigationArea));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除灌区
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('rechargecard:area:remove')")
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除灌区")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(ngIrrigationAreaService.deleteNgIrrigationAreaByIds(ids));
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.fastbee.data.controller.userRecharge.hanZhen;
|
||||
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.core.domain.AjaxResultPro;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
import com.fastbee.rechargecard.domain.NgIrrigationArea;
|
||||
import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper;
|
||||
import com.fastbee.rechargecard.service.impl.NgWaterPumpUsageRecordsServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controller
|
||||
*设备瞬时数据
|
||||
* @author kerwincui
|
||||
* @date 2024-12-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pump/usage")
|
||||
@Api(tags = "设备瞬时数据")
|
||||
public class HanZhenWaterRecordsController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private NgWaterPumpUsageRecordsServiceImpl ngWaterPumpUsageRecordsService;
|
||||
@GetMapping("/realtimeData")
|
||||
public AjaxResult realtimeData(@Param("deviceNumber") String deviceNumber) {
|
||||
|
||||
ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageDeviceNumber(deviceNumber);
|
||||
return toAjax(ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageDeviceNumber(deviceNumber));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user