李雨欣 8.30 18:37 测试查询接口
parent
6e71b8533f
commit
2bef3c2e9c
|
@ -9,8 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
import com.muyu.market.admain.request.OrdersUpdResp;
|
||||
import com.muyu.market.admain.request.ProductUpdReq;
|
||||
import com.muyu.market.admain.response.OrdersUpdResp;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
|
|
@ -70,6 +70,16 @@ public class Product extends BaseEntity {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
*接口地址
|
||||
*/
|
||||
@Excel(name = "接口地址")
|
||||
private String apiAddr;
|
||||
/**
|
||||
*请求方式
|
||||
*/
|
||||
@Excel(name = "请求方式")
|
||||
private String apiWay;
|
||||
|
||||
|
||||
|
||||
|
@ -91,6 +101,8 @@ public class Product extends BaseEntity {
|
|||
.status(productSave.getStatus())
|
||||
.createTime(productSave.getCreateTime())
|
||||
.updateTime(productSave.getUpdateTime())
|
||||
.apiAddr(productSave.getApiAddr())
|
||||
.apiWay(productSave.getApiWay())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -107,9 +119,12 @@ public class Product extends BaseEntity {
|
|||
.status(productUpdReq.getStatus())
|
||||
.createTime(productUpdReq.getCreateTime())
|
||||
.updateTime(productUpdReq.getUpdateTime())
|
||||
.apiAddr(productUpdReq.getApiAddr())
|
||||
.apiWay(productUpdReq.getApiWay())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
//https://gitea.qinmian.online/cloud/cloud-ui.git
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.market.admain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SelectByPhone {
|
||||
// 省份
|
||||
private String province;
|
||||
// 城市
|
||||
private String city;
|
||||
// 区号
|
||||
private String areacode;
|
||||
// 邮编
|
||||
private String zip;
|
||||
// 运营商
|
||||
private String company;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.market.admain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SelectWeather {
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 天气
|
||||
*/
|
||||
private String info;
|
||||
/**
|
||||
* 温度
|
||||
*/
|
||||
private String temperature;
|
||||
/**
|
||||
* 湿度
|
||||
*/
|
||||
private String humidity;
|
||||
/**
|
||||
* 风向
|
||||
*/
|
||||
private String direct;
|
||||
/**
|
||||
* 风力
|
||||
*/
|
||||
private String power;
|
||||
/**
|
||||
* 空气质量
|
||||
*/
|
||||
private String aqi;
|
||||
|
||||
}
|
|
@ -1,11 +1,14 @@
|
|||
package com.muyu.market.admain.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Tag(name = "订单查询", description = "订单查询")
|
||||
@AllArgsConstructor
|
||||
|
@ -23,5 +26,41 @@ public class OrdersSelectReq {
|
|||
*/
|
||||
@Schema(type = "Long",defaultValue = "用户ID",description = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(type = "Long",defaultValue = "商品ID",description = "1")
|
||||
private Long productId;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "订单号",description = "订单号")
|
||||
private String orderNo;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "订单状态",description = "订单状态")
|
||||
private String orderStatus;
|
||||
/**
|
||||
* 订单总金额
|
||||
*/
|
||||
@Schema(type = "BigDecimal",defaultValue = "25.3",description = "订单总金额")
|
||||
private String totalAmount;
|
||||
/**
|
||||
* 订单创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "订单创建时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 订单更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "订单更新时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 订单备注
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "订单备注",description = "订单备注")
|
||||
private String note;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.market.admain.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.market.admain.Product;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
@ -60,6 +61,16 @@ public class ProductListReq {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
*接口地址
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "接口地址",description = "接口地址")
|
||||
private String apiAddr;
|
||||
/**
|
||||
*请求方式
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "请求方式",description = "请求方式")
|
||||
private String apiWay;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -55,6 +55,16 @@ public class ProductSaveReq {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
*接口地址
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "接口地址",description = "接口地址")
|
||||
private String apiAddr;
|
||||
/**
|
||||
*请求方式
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "请求方式",description = "请求方式")
|
||||
private String apiWay;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -60,6 +60,16 @@ public class ProductUpdReq {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
*接口地址
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "接口地址",description = "接口地址")
|
||||
private String apiAddr;
|
||||
/**
|
||||
*请求方式
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "请求方式",description = "请求方式")
|
||||
private String apiWay;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.market.admain.request;
|
||||
package com.muyu.market.admain.response;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
@ -61,6 +61,17 @@ public class ProductListResp {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
*接口地址
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "接口地址",description = "接口地址")
|
||||
private String apiAddr;
|
||||
/**
|
||||
*请求方式
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "请求方式",description = "请求方式")
|
||||
private String apiWay;
|
||||
|
||||
|
||||
private BigDecimal begin;
|
||||
private BigDecimal end;
|
||||
|
@ -78,6 +89,8 @@ public class ProductListResp {
|
|||
.status(productlist.getStatus())
|
||||
.createTime(productlist.getCreateTime())
|
||||
.updateTime(productlist.getUpdateTime())
|
||||
.apiAddr(productlist.getApiAddr())
|
||||
.apiWay(productlist.getApiWay())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,16 @@ public class ProductSaveResp {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*接口地址
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "接口地址",description = "接口地址")
|
||||
private String apiAddr;
|
||||
/**
|
||||
*请求方式
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "请求方式",description = "请求方式")
|
||||
private String apiWay;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -103,6 +103,31 @@
|
|||
<artifactId>cloud-common-nacos-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- api接口 需要用到的依赖 -->
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.json-lib</groupId>
|
||||
<artifactId>json-lib</artifactId>
|
||||
<version>2.4</version>
|
||||
<classifier>jdk13</classifier>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
package com.muyu.market.server.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.market.admain.Orders;
|
||||
import com.muyu.market.admain.Product;
|
||||
import com.muyu.market.admain.request.OrdersSelectReq;
|
||||
import com.muyu.market.admain.request.OrdersUpdResp;
|
||||
import com.muyu.market.admain.response.OrdersSelectResp;
|
||||
import com.muyu.market.server.service.OrdersService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -29,31 +23,40 @@ public class OrdersController {
|
|||
private OrdersService orderService;
|
||||
|
||||
|
||||
@PostMapping("/orderSelect")
|
||||
@Operation(summary = "查询订信息",description = "查询订信息")
|
||||
public Result<List<OrdersSelectResp>> orderSelect(@RequestBody OrdersSelectReq ordersSelectReq){
|
||||
|
||||
/**
|
||||
* 点击下单 添加订单信息
|
||||
* @param product
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/orders")
|
||||
@Operation(summary = "订单添加",description = "添加添加订单")
|
||||
public Result<String> creatOrder(@RequestBody Product product){
|
||||
List<OrdersSelectResp> sellist = orderService.orderSelect(ordersSelectReq);
|
||||
return Result.success(sellist);
|
||||
|
||||
orderService.saveOrder(product);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询订信息
|
||||
* @param ordersSelectResp
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(path = "/orderSelect",method = RequestMethod.POST)
|
||||
@Operation(summary = "查询订单",description = "根据接口查看订单信息")
|
||||
public Result<List<OrdersSelectResp>> findByorderList(@RequestBody OrdersSelectResp ordersSelectResp){
|
||||
return Result.success(orderService.findByorderList(ordersSelectResp));
|
||||
}
|
||||
// /**
|
||||
// * 点击下单 添加订单信息
|
||||
// * @param product
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping("/orders")
|
||||
// @Operation(summary = "订单添加",description = "添加添加订单")
|
||||
// public Result<String> creatOrder(@RequestBody Product product){
|
||||
//
|
||||
// orderService.saveOrder(product);
|
||||
// return Result.success();
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * 查询订信息
|
||||
// * @param ordersSelectResp
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(path = "/orderSelect",method = RequestMethod.POST)
|
||||
// @Operation(summary = "查询订单",description = "根据接口查看订单信息")
|
||||
// public Result<List<OrdersSelectResp>> findByorderList(@RequestBody OrdersSelectResp ordersSelectResp){
|
||||
// return Result.success(orderService.findByorderList(ordersSelectResp));
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
|
@ -69,36 +72,36 @@ public class OrdersController {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID删除订单
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping
|
||||
@Operation(summary = "刪除订单",description = "根据订单Id 删除订单")
|
||||
public Result<String> removeById(@RequestParam(value = "orderId") Long orderId){
|
||||
orderService.removeById(orderId);
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改订单
|
||||
* @param orderId
|
||||
* @param ordersUpdResp
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/{orderId}")
|
||||
@Operation(summary = "订单的修改",description = "通过ID修改订单")
|
||||
public Result<String> update(
|
||||
@Schema(title = "订单ID",type = "Long",description = "修改订单信息",defaultValue = "1")
|
||||
@PathVariable("orderId") Long orderId,
|
||||
@RequestBody @Validated OrdersUpdResp ordersUpdResp){
|
||||
|
||||
orderService.updateById(Orders.UpdOrdersReq(ordersUpdResp,()->orderId));
|
||||
return Result.success(null,"操作成功");
|
||||
|
||||
}
|
||||
// /**
|
||||
// * 根据ID删除订单
|
||||
// * @param orderId
|
||||
// * @return
|
||||
// */
|
||||
// @DeleteMapping
|
||||
// @Operation(summary = "刪除订单",description = "根据订单Id 删除订单")
|
||||
// public Result<String> removeById(@RequestParam(value = "orderId") Long orderId){
|
||||
// orderService.removeById(orderId);
|
||||
// return Result.success(null,"操作成功");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 修改订单
|
||||
// * @param orderId
|
||||
// * @param ordersUpdResp
|
||||
// * @return
|
||||
// */
|
||||
// @PutMapping("/{orderId}")
|
||||
// @Operation(summary = "订单的修改",description = "通过ID修改订单")
|
||||
// public Result<String> update(
|
||||
// @Schema(title = "订单ID",type = "Long",description = "修改订单信息",defaultValue = "1")
|
||||
// @PathVariable("orderId") Long orderId,
|
||||
// @RequestBody @Validated OrdersUpdResp ordersUpdResp){
|
||||
//
|
||||
// orderService.updateById(Orders.UpdOrdersReq(ordersUpdResp,()->orderId));
|
||||
// return Result.success(null,"操作成功");
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.market.server.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.market.admain.Product;
|
||||
import com.muyu.market.admain.SelectByPhone;
|
||||
import com.muyu.market.server.util.SelectPhoneUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/party")
|
||||
@Tag(name = "查询手机号",description = "订单查询")
|
||||
public class PartyController {
|
||||
|
||||
|
||||
@PostMapping("/selparty")
|
||||
@Operation(summary = "查询手机号",description = "查询手机号")
|
||||
public SelectByPhone selparty(@RequestParam("phoneNumber") String phoneNumber){
|
||||
|
||||
return SelectPhoneUtil.queryMobileLocation(phoneNumber);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
SelectPhoneUtil.queryMobileLocation("18790307917");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.market.server.controller;
|
||||
|
||||
import com.muyu.market.admain.SelectWeather;
|
||||
import com.muyu.market.server.util.SelectWeatherUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/weather")
|
||||
@Tag(name = "查询天气",description = "查询天气")
|
||||
public class WeatherController {
|
||||
|
||||
|
||||
|
||||
@PostMapping("/selweather")
|
||||
@Operation(summary = "查询天气",description = "查询天气")
|
||||
public SelectWeather selweather(@RequestParam("cityName") String cityName){
|
||||
|
||||
return SelectWeatherUtil.queryWeather(cityName);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SelectWeatherUtil.queryWeather("南京");
|
||||
}
|
||||
}
|
|
@ -9,8 +9,10 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface OrdersMapper extends BaseMapper<Orders> {
|
||||
List<OrdersSelectResp> findByorderList(OrdersSelectResp ordersSelectResp);
|
||||
public interface OrdersMapper {
|
||||
|
||||
List<OrdersSelectResp> orderSelect(OrdersSelectReq ordersSelectReq);
|
||||
// List<OrdersSelectResp> findByorderList(OrdersSelectResp ordersSelectResp);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
|
|
|
@ -15,60 +15,65 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@Service
|
||||
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {
|
||||
public class OrdersServiceImpl implements OrdersService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private OrdersMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public void saveOrder(Product product) {
|
||||
|
||||
Orders order = new Orders();
|
||||
//获取用户ID
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
order.setUserId(userId);
|
||||
//获取商品ID
|
||||
order.setProductId(product.getProductId());
|
||||
|
||||
// 生成一个随机的UUID
|
||||
UUID uuid = UUID.randomUUID();
|
||||
// 将UUID转换为字符串
|
||||
String random = uuid.toString();
|
||||
//随机生成订单编号
|
||||
order.setOrderNo(random);
|
||||
|
||||
//订单状态(0:未支付 1:已支付)(订单刚生成状态都为未支付)
|
||||
order.setOrderStatus("0");
|
||||
//订单总金额
|
||||
order.setTotalAmount(product.getProductPrice());
|
||||
//订单创建时间(为当前时间)
|
||||
order.setCreateTime(new Date());
|
||||
//订单更新时间(为当前时间)
|
||||
order.setUpdateTime(new Date());
|
||||
|
||||
try {
|
||||
orderMapper.insert(order);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<OrdersSelectResp> orderSelect(OrdersSelectReq ordersSelectReq) {
|
||||
return orderMapper.orderSelect(ordersSelectReq);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @Override
|
||||
// public List<OrdersSelectResp> findAll() {
|
||||
// return orderMapper.findAll();
|
||||
// public void saveOrder(Product product) {
|
||||
//
|
||||
// Orders order = new Orders();
|
||||
// //获取用户ID
|
||||
// Long userId = SecurityUtils.getUserId();
|
||||
// order.setUserId(userId);
|
||||
// //获取商品ID
|
||||
// order.setProductId(product.getProductId());
|
||||
//
|
||||
// // 生成一个随机的UUID
|
||||
// UUID uuid = UUID.randomUUID();
|
||||
// // 将UUID转换为字符串
|
||||
// String random = uuid.toString();
|
||||
// //随机生成订单编号
|
||||
// order.setOrderNo(random);
|
||||
//
|
||||
// //订单状态(0:未支付 1:已支付)(订单刚生成状态都为未支付)
|
||||
// order.setOrderStatus("0");
|
||||
// //订单总金额
|
||||
// order.setTotalAmount(product.getProductPrice());
|
||||
// //订单创建时间(为当前时间)
|
||||
// order.setCreateTime(new Date());
|
||||
// //订单更新时间(为当前时间)
|
||||
// order.setUpdateTime(new Date());
|
||||
//
|
||||
// try {
|
||||
// orderMapper.insert(order);
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<OrdersSelectResp> findByorderList(OrdersSelectResp ordersSelectResp) {
|
||||
return orderMapper.findByorderList(ordersSelectResp);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//// @Override
|
||||
//// public List<OrdersSelectResp> findAll() {
|
||||
//// return orderMapper.findAll();
|
||||
//// }
|
||||
//
|
||||
// @Override
|
||||
// public List<OrdersSelectResp> findByorderList(OrdersSelectResp ordersSelectResp) {
|
||||
// return orderMapper.findByorderList(ordersSelectResp);
|
||||
// }
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|||
Product::getProductPrice,productListResp.getEnd()
|
||||
);
|
||||
}
|
||||
|
||||
List<Product> productlist = this.list(lambdaQueryWrapperlist);
|
||||
|
||||
// return productlist.stream()
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.market.server.service;
|
|||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.market.admain.Orders;
|
||||
import com.muyu.market.admain.Product;
|
||||
import com.muyu.market.admain.request.OrdersSelectReq;
|
||||
|
@ -9,13 +10,15 @@ import com.muyu.market.admain.response.OrdersSelectResp;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface OrdersService extends IService<Orders> {
|
||||
public interface OrdersService {
|
||||
List<OrdersSelectResp> orderSelect(OrdersSelectReq ordersSelectReq);
|
||||
|
||||
void saveOrder(Product product);
|
||||
|
||||
List<OrdersSelectResp> findByorderList(OrdersSelectResp ordersSelectResp);
|
||||
|
||||
// List<OrdersSelectResp> findAll();
|
||||
// void saveOrder(Product product);
|
||||
//
|
||||
// List<OrdersSelectResp> findByorderList(OrdersSelectResp ordersSelectResp);
|
||||
//
|
||||
//// List<OrdersSelectResp> findAll();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import com.alipay.api.DefaultAlipayClient;
|
|||
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
||||
import com.alipay.api.response.AlipayTradeWapPayResponse;
|
||||
|
||||
//测试 是能用的 好像 希望啥 写完啦 快了 我只要把公钥私钥换了就行了
|
||||
|
||||
|
||||
public class PayUtils {
|
||||
public static void main(String[] args) {
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(
|
||||
|
@ -19,55 +20,55 @@ public class PayUtils {
|
|||
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvAodOIG6vaqMsl5DXjcRYPRro+C/SeTswVo5gqQdikK3qy118GWkVwL9gvEovq23EMCTmSV+KAFsHz8f0UxLEK9FZcfRuM5E7GfnP7sdY0ctjfmUhQ7fWVOTGLuH0h5DiQ+4voO/2Hi6SElvtLXAUBSqMKw6J0PsJ0uUY9CBZCQnZkFJWAAroUWw5ARUMy62KPZSAW2s8Qg4gacdhSk7SBACNGBFcJZHCS09xQJi5SxCHaTRLhhIckLBvuKEWhBsh+jU75BKYAC4ovoWhMAFnIWKwCmubhXqmYjuJ4egUQTQBbD1hasK99I1YzdXRH8OKwKD4Lufb42B9buZ/2hOywIDAQAB",
|
||||
"RSA2");
|
||||
AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
|
||||
//异步接收地址,仅支持http/https,公网可访问
|
||||
//异步接收地址,仅支持http/https,公网可访问
|
||||
request.setNotifyUrl("");
|
||||
//同步跳转地址,仅支持http/https
|
||||
//同步跳转地址,仅支持http/https
|
||||
request.setReturnUrl("");
|
||||
/******必传参数******/
|
||||
/******必传参数******/
|
||||
JSONObject bizContent = new JSONObject();
|
||||
//商户订单号,商家自定义,保持唯一性
|
||||
//商户订单号,商家自定义,保持唯一性
|
||||
bizContent.put("out_trade_no", "2088721039266985");
|
||||
//支付金额,最小值0.01元
|
||||
//支付金额,最小值0.01元
|
||||
bizContent.put("total_amount", 0.01);
|
||||
//订单标题,不可使用特殊符号
|
||||
//订单标题,不可使用特殊符号
|
||||
bizContent.put("subject", "测试商品");
|
||||
|
||||
/******可选参数******/
|
||||
//手机网站支付默认传值QUICK_WAP_WAY
|
||||
bizContent.put("product_code", "QUICK_WAP_WAY");
|
||||
//bizContent.put("time_expire", "2022-08-01 22:00:00");
|
||||
/******可选参数******/
|
||||
//手机网站支付默认传值QUICK_WAP_WAY
|
||||
bizContent.put("product_code", "QUICK_WAP_WAY");
|
||||
//bizContent.put("time_expire", "2022-08-01 22:00:00");
|
||||
|
||||
//// 商品明细信息,按需传入
|
||||
//JSONArray goodsDetail = new JSONArray();
|
||||
//JSONObject goods1 = new JSONObject();
|
||||
//goods1.put("goods_id", "goodsNo1");
|
||||
//goods1.put("goods_name", "子商品1");
|
||||
//goods1.put("quantity", 1);
|
||||
//goods1.put("price", 0.01);
|
||||
//goodsDetail.add(goods1);
|
||||
//bizContent.put("goods_detail", goodsDetail);
|
||||
//// 商品明细信息,按需传入
|
||||
//JSONArray goodsDetail = new JSONArray();
|
||||
//JSONObject goods1 = new JSONObject();
|
||||
//goods1.put("goods_id", "goodsNo1");
|
||||
//goods1.put("goods_name", "子商品1");
|
||||
//goods1.put("quantity", 1);
|
||||
//goods1.put("price", 0.01);
|
||||
//goodsDetail.add(goods1);
|
||||
//bizContent.put("goods_detail", goodsDetail);
|
||||
|
||||
//// 扩展信息,按需传入
|
||||
//JSONObject extendParams = new JSONObject();
|
||||
//extendParams.put("sys_service_provider_id", "2088511833207846");
|
||||
//bizContent.put("extend_params", extendParams);
|
||||
//// 扩展信息,按需传入
|
||||
//JSONObject extendParams = new JSONObject();
|
||||
//extendParams.put("sys_service_provider_id", "2088511833207846");
|
||||
//bizContent.put("extend_params", extendParams);
|
||||
|
||||
request.setBizContent(bizContent.toString());
|
||||
AlipayTradeWapPayResponse response = null;
|
||||
try {
|
||||
response = alipayClient.pageExecute(request,"POST");
|
||||
} catch (AlipayApiException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// 如果需要返回GET请求,请使用
|
||||
// AlipayTradeWapPayResponse response = alipayClient.pageExecute(request,"GET");
|
||||
String pageRedirectionData = response.getBody();
|
||||
System.out.println(pageRedirectionData);
|
||||
request.setBizContent(bizContent.toString());
|
||||
AlipayTradeWapPayResponse response = null;
|
||||
try {
|
||||
response = alipayClient.pageExecute(request,"POST");
|
||||
} catch (AlipayApiException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// 如果需要返回GET请求,请使用
|
||||
// AlipayTradeWapPayResponse response = alipayClient.pageExecute(request,"GET");
|
||||
String pageRedirectionData = response.getBody();
|
||||
System.out.println(pageRedirectionData);
|
||||
|
||||
if(response.isSuccess()){
|
||||
System.out.println("调用成功");
|
||||
} else {
|
||||
System.out.println("调用失败");
|
||||
if(response.isSuccess()){
|
||||
System.out.println("调用成功");
|
||||
} else {
|
||||
System.out.println("调用失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
package com.muyu.market.server.util;
|
||||
|
||||
import com.muyu.market.admain.SelectByPhone;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class SelectPhoneUtil {
|
||||
// 手机归属地查询接口地址
|
||||
public static String API_URL = "http://apis.juhe.cn/mobile/get";
|
||||
// 接口请求Key
|
||||
public static String API_KEY = "4cfc25ee624fc08ad83b61a3a0ab1bcb";
|
||||
|
||||
|
||||
/**
|
||||
* 根据手机号码/手机号码前7位查询号码归属地
|
||||
* @param mobile
|
||||
*/
|
||||
public static SelectByPhone queryMobileLocation(String mobile)
|
||||
{
|
||||
Map<String, Object> params = new HashMap<>();//组合参数
|
||||
params.put("phone", mobile);
|
||||
params.put("key", API_KEY);
|
||||
String queryParams = urlencode(params);
|
||||
|
||||
String response = doGet(API_URL, queryParams);
|
||||
SelectByPhone selectByPhone = new SelectByPhone();
|
||||
try {
|
||||
JSONObject jsonObject = JSONObject.fromObject(response);
|
||||
int error_code = jsonObject.getInt("error_code");
|
||||
if (error_code == 0) {
|
||||
System.out.println("调用接口成功");
|
||||
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
|
||||
System.out.printf("省份:%s%n", result.getString("province"));
|
||||
System.out.printf("城市:%s%n", result.getString("city"));
|
||||
System.out.printf("区号:%s%n", result.getString("areacode"));
|
||||
System.out.printf("邮编:%s%n", result.getString("zip"));
|
||||
System.out.printf("运营商:%s%n", result.getString("company"));
|
||||
|
||||
selectByPhone.setCompany(result.getString("company"));
|
||||
selectByPhone.setCity(result.getString("city"));
|
||||
selectByPhone.setZip(result.getString("zip"));
|
||||
selectByPhone.setAreacode(result.getString("areacode"));
|
||||
selectByPhone.setProvince(result.getString("province"));
|
||||
} else {
|
||||
System.out.println("调用接口失败:" + jsonObject.getString("reason"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return selectByPhone;
|
||||
}
|
||||
|
||||
/**
|
||||
* get方式的http请求
|
||||
*
|
||||
* @param httpUrl 请求地址
|
||||
* @return 返回结果
|
||||
*/
|
||||
public static String doGet(String httpUrl, String queryParams) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream inputStream = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
String result = null;// 返回结果字符串
|
||||
try {
|
||||
// 创建远程url连接对象
|
||||
URL url = new URL(new StringBuffer(httpUrl).append("?").append(queryParams).toString());
|
||||
// 通过远程url连接对象打开一个连接,强转成httpURLConnection类
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
// 设置连接方式:get
|
||||
connection.setRequestMethod("GET");
|
||||
// 设置连接主机服务器的超时时间:15000毫秒
|
||||
connection.setConnectTimeout(5000);
|
||||
// 设置读取远程返回的数据时间:60000毫秒
|
||||
connection.setReadTimeout(6000);
|
||||
// 发送请求
|
||||
connection.connect();
|
||||
// 通过connection连接,获取输入流
|
||||
if (connection.getResponseCode() == 200) {
|
||||
inputStream = connection.getInputStream();
|
||||
// 封装输入流,并指定字符集
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
// 存放数据
|
||||
StringBuilder sbf = new StringBuilder();
|
||||
String temp;
|
||||
while ((temp = bufferedReader.readLine()) != null) {
|
||||
sbf.append(temp);
|
||||
sbf.append(System.getProperty("line.separator"));
|
||||
}
|
||||
result = sbf.toString();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
if (null != bufferedReader) {
|
||||
try {
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != inputStream) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
connection.disconnect();// 关闭远程连接
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将map型转为请求参数型
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static String urlencode(Map<String, ?> data) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, ?> i : data.entrySet()) {
|
||||
try {
|
||||
sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue() + "", "UTF-8")).append("&");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String result = sb.toString();
|
||||
result = result.substring(0, result.lastIndexOf("&"));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package com.muyu.market.server.util;
|
||||
import com.muyu.market.admain.SelectWeather;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@RestController
|
||||
public class SelectWeatherUtil {
|
||||
|
||||
|
||||
// 天气情况查询接口地址
|
||||
public static String API_URL = "http://apis.juhe.cn/simpleWeather/query";
|
||||
// 接口请求Key
|
||||
public static String API_KEY = "2e7b031d32a2eac211c099bf4918a4dd";
|
||||
|
||||
|
||||
/**
|
||||
* 根据城市名查询天气情况
|
||||
*
|
||||
* @param cityName
|
||||
*/
|
||||
public static SelectWeather queryWeather(String cityName) {
|
||||
Map<String, Object> params = new HashMap<>();//组合参数
|
||||
params.put("city", cityName);
|
||||
params.put("key", API_KEY);
|
||||
String queryParams = urlencode(params);
|
||||
|
||||
String response = doGet(API_URL, queryParams);
|
||||
SelectWeather selectWeather = new SelectWeather();
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = JSONObject.fromObject(response);
|
||||
int error_code = jsonObject.getInt("error_code");
|
||||
if (error_code == 0) {
|
||||
System.out.println("调用接口成功");
|
||||
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
JSONObject realtime = result.getJSONObject("realtime");
|
||||
|
||||
System.out.printf("城市:%s%n", result.getString("city"));
|
||||
System.out.printf("天气:%s%n", realtime.getString("info"));
|
||||
System.out.printf("温度:%s%n", realtime.getString("temperature"));
|
||||
System.out.printf("湿度:%s%n", realtime.getString("humidity"));
|
||||
System.out.printf("风向:%s%n", realtime.getString("direct"));
|
||||
System.out.printf("风力:%s%n", realtime.getString("power"));
|
||||
System.out.printf("空气质量:%s%n", realtime.getString("aqi"));
|
||||
|
||||
selectWeather.setCity(result.getString("city"));
|
||||
selectWeather.setInfo(realtime.getString("info"));
|
||||
selectWeather.setTemperature(realtime.getString("temperature"));
|
||||
selectWeather.setHumidity(realtime.getString("humidity"));
|
||||
selectWeather.setDirect(realtime.getString("direct"));
|
||||
selectWeather.setPower(realtime.getString("power"));
|
||||
selectWeather.setAqi(realtime.getString("aqi"));
|
||||
|
||||
} else {
|
||||
System.out.println("调用接口失败:" + jsonObject.getString("reason"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return selectWeather;
|
||||
}
|
||||
|
||||
/**
|
||||
* get方式的http请求
|
||||
*
|
||||
* @param httpUrl 请求地址
|
||||
* @return 返回结果
|
||||
*/
|
||||
public static String doGet(String httpUrl, String queryParams) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream inputStream = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
String result = null;// 返回结果字符串
|
||||
try {
|
||||
// 创建远程url连接对象
|
||||
URL url = new URL(new StringBuffer(httpUrl).append("?").append(queryParams).toString());
|
||||
// 通过远程url连接对象打开一个连接,强转成httpURLConnection类
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
// 设置连接方式:get
|
||||
connection.setRequestMethod("GET");
|
||||
// 设置连接主机服务器的超时时间:15000毫秒
|
||||
connection.setConnectTimeout(5000);
|
||||
// 设置读取远程返回的数据时间:60000毫秒
|
||||
connection.setReadTimeout(6000);
|
||||
// 发送请求
|
||||
connection.connect();
|
||||
// 通过connection连接,获取输入流
|
||||
if (connection.getResponseCode() == 200) {
|
||||
inputStream = connection.getInputStream();
|
||||
// 封装输入流,并指定字符集
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
// 存放数据
|
||||
StringBuilder sbf = new StringBuilder();
|
||||
String temp;
|
||||
while ((temp = bufferedReader.readLine()) != null) {
|
||||
sbf.append(temp);
|
||||
sbf.append(System.getProperty("line.separator"));
|
||||
}
|
||||
result = sbf.toString();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
if (null != bufferedReader) {
|
||||
try {
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != inputStream) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
connection.disconnect();// 关闭远程连接
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将map型转为请求参数型
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static String urlencode(Map<String, ?> data) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, ?> i : data.entrySet()) {
|
||||
try {
|
||||
sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue() + "", "UTF-8")).append("&");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String result = sb.toString();
|
||||
result = result.substring(0, result.lastIndexOf("&"));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,21 +17,36 @@
|
|||
</resultMap>
|
||||
|
||||
|
||||
<select id="findByorderList" resultType="com.muyu.market.admain.response.OrdersSelectResp">
|
||||
SELECT
|
||||
orders.*,
|
||||
sys_user.user_name,
|
||||
product.product_name,
|
||||
product.product_price,
|
||||
product.description,
|
||||
product.`status`
|
||||
FROM
|
||||
orders
|
||||
<select id="orderSelect" resultType="com.muyu.market.admain.response.OrdersSelectResp">
|
||||
SELECT
|
||||
orders.*,
|
||||
sys_user.user_name,
|
||||
product.product_name,
|
||||
product.product_price,
|
||||
product.description,
|
||||
product.`status`
|
||||
FROM
|
||||
orders
|
||||
LEFT JOIN sys_user ON orders.order_id = sys_user.user_id
|
||||
LEFT JOIN product ON orders.order_id = product.product_id
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <select id="findByorderList" resultType="com.muyu.market.admain.response.OrdersSelectResp">-->
|
||||
<!-- SELECT-->
|
||||
<!-- orders.*,-->
|
||||
<!-- sys_user.user_name,-->
|
||||
<!-- product.product_name,-->
|
||||
<!-- product.product_price,-->
|
||||
<!-- product.description,-->
|
||||
<!-- product.`status`-->
|
||||
<!-- FROM-->
|
||||
<!-- orders-->
|
||||
<!-- LEFT JOIN sys_user ON orders.order_id = sys_user.user_id-->
|
||||
<!-- LEFT JOIN product ON orders.order_id = product.product_id-->
|
||||
<!-- </select>-->
|
||||
|
||||
|
||||
<!-- <select id="findAll" resultType="com.muyu.market.admain.response.OrdersSelectResp">-->
|
||||
<!-- SELECT-->
|
||||
<!-- orders.*,-->
|
||||
|
|
Loading…
Reference in New Issue