master
bai 2024-08-30 09:06:18 +08:00
commit 98acf286ab
46 changed files with 2435 additions and 0 deletions

32
.gitignore vendored 100644
View File

@ -0,0 +1,32 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/
logs
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

16
Dockerfile 100644
View File

@ -0,0 +1,16 @@
#指定构建镜像的起始镜像
FROM anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/dragonwell:17.0.4.0.4.8-standard-ga-8.6
#定义时区参数
ENV TZ=Asia/Shanghai
#设置时区
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
#挂载目录
VOLUME ["/home/logs/cloud-market2"]
#拷贝执行jar报
COPY ./cloud-market2-server/target/cloud-market2.jar /home/app.jar
ENTRYPOINT ["java","-Dfile.encoding=utf-8","-jar"]
CMD ["/home/app.jar"]

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-market2</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>cloud-market2-client</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-market2-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,8 @@
package com.muyu;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-market2</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>cloud-market2-common</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,8 @@
package com.muyu;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,119 @@
package com.muyu.market.admain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.market.admain.request.MyapiSaveReq;
import com.muyu.market.admain.request.MyapiUpdReq;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
import java.util.function.Supplier;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "market_myapi",autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
public class Myapi extends BaseEntity{
/**
* ID
*/
@TableId(value = "api_id",type = IdType.AUTO)
private Long apiId;
/**
*
*/
@Schema(type = "String",description = "接口名称")
private String name;
/**
*
*/
@Schema(description = "价钱/次",type = "BigDecimal")
private BigDecimal price;
/**
*
*/
@Schema(type = "String",description = "介绍")
private String test;
/**
*
*/
@Schema(description = "商品描述",type = "String")
private String data;
/**
*
*/
@Schema(description = "接口名称",type = "String")
private String apiName;
/**
*
*/
@Schema(description = "接口地址",type = "String")
private String ip;
/**
*
*/
@Schema(description = "请求方式",type = "String")
private String mode;
/**
*
*/
@Schema(description = "购买字段(当修改成功触发)",type = "Integer")
private int auth;
/*
API
*/
@Schema(description = "API类型",type = "String")
private String type;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
private String remark;
public static Myapi SaveMyapiList(MyapiSaveReq myapiSaveReq){
return Myapi
.builder()
.name( myapiSaveReq.getName())
.price( myapiSaveReq.getPrice())
.test( myapiSaveReq.getTest())
.data( myapiSaveReq.getData())
.apiName( myapiSaveReq.getApiName())
.ip( myapiSaveReq.getIp())
.mode( myapiSaveReq.getMode())
.auth( myapiSaveReq.getAuth() )
.type( myapiSaveReq.getType())
.build();
}
public static Myapi UpdMyapiList(MyapiUpdReq myapiUpdReq, Supplier<Long> apiId){
return Myapi
.builder()
.apiId(apiId.get())
.name( myapiUpdReq.getName())
.price( myapiUpdReq.getPrice())
.test( myapiUpdReq.getTest())
.data( myapiUpdReq.getData())
.apiName( myapiUpdReq.getApiName())
.ip( myapiUpdReq.getIp())
.mode( myapiUpdReq.getMode())
.auth( myapiUpdReq.getAuth() )
.type( myapiUpdReq.getType())
.build();
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -0,0 +1,56 @@
package com.muyu.market.admain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sys_logininfor",autoResultMap = true)
@Tag( name="登录日志",description = "记录登录操作")
public class SysLogininfor extends BaseEntity {
/*
访ID
*/
@TableId(value = "info_id",type = IdType.AUTO)
private Long infoId;
/*
*/
@Schema(description = "用户名",type = "String")
private String userName;
/*
IP
*/
@Schema(description = "用户账号",type = "String")
private String ipaddr;
/*
0 1
*/
@Schema(description = "登录IP地址",type = "char")
private Character status;
/*
*/
@Schema(description = "登录状态0成功 1失败",type = "String")
private String msg;
/*
访
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "提示信息",type = "Date")
private Data accessTime;
}

View File

@ -0,0 +1,130 @@
package com.muyu.market.admain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "sys_user",autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
public class SysUser extends BaseEntity {
/**
* ID
*/
@TableId(value = "user_id",type = IdType.AUTO)
private Long userId;
/**
* ID
*/
@Schema(description = "部门ID",type = "Long")
private Long deptId;
/**
*
*/
@Schema(description = "用户账号",type = "String")
private String userName;
/**
*
*/
@Schema(description = "用户昵称",type = "String")
private String nickName;
/**
*
*/
@Schema(description = "用户类型00系统用户",type = "String")
private String userType;
/**
*
*/
@Schema(description = "余额",type = "BigDecimal")
private BigDecimal money;
/**
*
*/
@Schema(description = "用户邮箱",type = "String")
private String email;
/**
*
*/
@Schema(description = "手机号码",type = "String")
private String phonenumber;
/**
* 0 1 2
*/
@Schema(description = "用户性别0男 1女 2未知",type = "String")
private String sex;
/**
*
*/
@Schema(description = "头像地址",type = "String")
private String avatar;
/**
*
*/
@Schema(description = "密码",type = "String")
private String password;
/**
* 0 1
*/
@Schema(description = "帐号状态0正常 1停用",type = "Character")
private Character status;
/**
* 0 2
*/
@Schema(description = "删除标志0代表存在 2代表删除",type = "Character")
private Character delFlag;
/**
* IP
*/
@Schema(description = "最后登录IP",type = "String")
private String loginIp;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "最后登录时间",type = "Date")
private Date loginDate;
/**
*
*/
@Schema(description = "创建者",type = "String")
private String createBy;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间",type = "Date")
private Date createTime;
/*
*/
@Schema(description = "更新者",type = "String")
private String updateBy;
/*
*/
@Schema(description = "更新时间",type = "Date")
private Date updateTime;
/*
*/
@Schema(description = "备注",type = "String")
private String remark;
}

View File

@ -0,0 +1,75 @@
package com.muyu.market.admain.request;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
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 lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Tag(name = "商品展示请求", description = "商品展示请求")
public class MyapiListReq {
/**
* ID
*/
@TableId(value = "api_id",type = IdType.AUTO)
private Long apiId;
/**
*
*/
@Schema(type = "String",description = "接口名称")
private String name;
/**
*
*/
@Schema(description = "价钱/次",type = "BigDecimal")
private BigDecimal price;
/**
*
*/
@Schema(type = "String",description = "介绍")
private String test;
/**
*
*/
@Schema(description = "商品描述",type = "String")
private String data;
/**
*
*/
@Schema(description = "接口名称",type = "String")
private String apiName;
/**
*
*/
@Schema(description = "接口地址",type = "String")
private String ip;
/**
*
*/
@Schema(description = "请求方式",type = "String")
private String mode;
/**
*
*/
@Schema(description = "购买字段(当修改成功触发)",type = "Integer")
private int auth;
/*
API
*/
@Schema(description = "API类型",type = "String")
private String type;
}

View File

@ -0,0 +1,78 @@
package com.muyu.market.admain.request;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
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 lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Tag(name = "商品添加", description = "商品添加")
public class MyapiSaveReq {
/**
* ID
*/
@TableId(value = "api_id",type = IdType.AUTO)
private Long apiId;
/**
*
*/
@Schema(type = "String",description = "接口名称")
private String name;
/**
*
*/
@Schema(description = "价钱/次",type = "BigDecimal")
private BigDecimal price;
/**
*
*/
@Schema(type = "String",description = "介绍")
private String test;
/**
*
*/
@Schema(description = "商品描述",type = "String")
private String data;
/**
*
*/
@Schema(description = "接口名称",type = "String")
private String apiName;
/**
*
*/
@Schema(description = "接口地址",type = "String")
private String ip;
/**
*
*/
@Schema(description = "请求方式",type = "String")
private String mode;
/**
*
*/
@Schema(description = "购买字段(当修改成功触发)",type = "Integer")
private int auth;
/*
API
*/
@Schema(description = "API类型",type = "String")
private String type;
}

View File

@ -0,0 +1,76 @@
package com.muyu.market.admain.request;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
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 lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Tag(name = "商品修改", description = "商品修改")
public class MyapiUpdReq {
/**
* ID
*/
@TableId(value = "api_id",type = IdType.AUTO)
private Long apiId;
/**
*
*/
@Schema(type = "String",description = "接口名称")
private String name;
/**
*
*/
@Schema(description = "价钱/次",type = "BigDecimal")
private BigDecimal price;
/**
*
*/
@Schema(type = "String",description = "介绍")
private String test;
/**
*
*/
@Schema(description = "商品描述",type = "String")
private String data;
/**
*
*/
@Schema(description = "接口名称",type = "String")
private String apiName;
/**
*
*/
@Schema(description = "接口地址",type = "String")
private String ip;
/**
*
*/
@Schema(description = "请求方式",type = "String")
private String mode;
/**
*
*/
@Schema(description = "购买字段(当修改成功触发)",type = "Integer")
private int auth;
/*
API
*/
@Schema(description = "API类型",type = "String")
private String type;
}

View File

@ -0,0 +1,127 @@
package com.muyu.market.admain.request;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
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 lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Tag(name = "充值余额", description = "用于发送充值请求参数")
public class updUserMoneyReq {
/**
* ID
*/
@TableId(value = "user_id",type = IdType.AUTO)
private Long userId;
/**
* ID
*/
@Schema(description = "部门ID",type = "Long")
private Long deptId;
/**
*
*/
@Schema(description = "用户账号",type = "String")
private String userName;
/**
*
*/
@Schema(description = "用户昵称",type = "String")
private String nickName;
/**
*
*/
@Schema(description = "用户类型00系统用户",type = "String")
private String userType;
/**
*
*/
@Schema(description = "余额",type = "BigDecimal")
private BigDecimal money;
/**
*
*/
@Schema(description = "用户邮箱",type = "String")
private String email;
/**
*
*/
@Schema(description = "手机号码",type = "String")
private String phonenumber;
/**
* 0 1 2
*/
@Schema(description = "用户性别0男 1女 2未知",type = "String")
private String sex;
/**
*
*/
@Schema(description = "头像地址",type = "String")
private String avatar;
/**
*
*/
@Schema(description = "密码",type = "String")
private String password;
/**
* 0 1
*/
@Schema(description = "帐号状态0正常 1停用",type = "Character")
private Character status;
/**
* 0 2
*/
@Schema(description = "删除标志0代表存在 2代表删除",type = "Character")
private Character delFlag;
/**
* IP
*/
@Schema(description = "最后登录IP",type = "String")
private String loginIp;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "最后登录时间",type = "Date")
private Date loginDate;
/**
*
*/
@Schema(description = "创建者",type = "String")
private String createBy;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间",type = "Date")
private Date createTime;
/*
*/
@Schema(description = "更新者",type = "String")
private String updateBy;
/*
*/
@Schema(description = "更新时间",type = "Date")
private Date updateTime;
/*
*/
@Schema(description = "备注",type = "String")
private String remark;
}

View File

@ -0,0 +1,97 @@
package com.muyu.market.admain.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.market.admain.Myapi;
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 lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Tag(name = "商品展示", description = "商品展示")
public class MyapiListResp {
/**
* ID
*/
@TableId(value = "api_id",type = IdType.AUTO)
private Long apiId;
/**
*
*/
@Schema(type = "String",description = "接口名称")
private String name;
/**
*
*/
@Schema(description = "价钱/次",type = "BigDecimal")
private BigDecimal price;
/**
*
*/
@Schema(type = "String",description = "介绍")
private String test;
/**
*
*/
@Schema(description = "商品描述",type = "String")
private String data;
/**
*
*/
@Schema(description = "接口名称",type = "String")
private String apiName;
/**
*
*/
@Schema(description = "接口地址",type = "String")
private String ip;
/**
*
*/
@Schema(description = "请求方式",type = "String")
private String mode;
/**
*
*/
@Schema(description = "购买字段(当修改成功触发)",type = "Integer")
private int auth;
/*
API
*/
@Schema(description = "API类型",type = "String")
private String type;
public static MyapiListResp selProductList(Myapi myapi){
return MyapiListResp
.builder()
.apiId( myapi.getApiId())
.name( myapi.getName())
.price( myapi.getPrice())
.test( myapi.getTest())
.data( myapi.getData())
.apiName( myapi.getApiName())
.ip( myapi.getIp())
.mode( myapi.getMode())
.auth( myapi.getAuth())
.type( myapi.getType())
.build();
}
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
private String remark;
}

View File

@ -0,0 +1,84 @@
package com.muyu.market.admain.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
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 lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Tag(name = "商品添加", description = "商品添加")
public class MyapiSaveResp {
/**
* ID
*/
@TableId(value = "api_id",type = IdType.AUTO)
private Long apiId;
/**
*
*/
@Schema(type = "String",description = "接口名称")
private String name;
/**
*
*/
@Schema(description = "价钱/次",type = "BigDecimal")
private BigDecimal price;
/**
*
*/
@Schema(type = "String",description = "介绍")
private String test;
/**
*
*/
@Schema(description = "商品描述",type = "String")
private String data;
/**
*
*/
@Schema(description = "接口名称",type = "String")
private String apiName;
/**
*
*/
@Schema(description = "接口地址",type = "String")
private String ip;
/**
*
*/
@Schema(description = "请求方式",type = "String")
private String mode;
/**
*
*/
@Schema(description = "购买字段(当修改成功触发)",type = "Integer")
private int auth;
/*
API
*/
@Schema(description = "API类型",type = "String")
private String type;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
private String remark;
}

View File

@ -0,0 +1,56 @@
package com.muyu.market.admain.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sys_logininfor",autoResultMap = true)
@Tag( name="登录日志",description = "记录登录操作")
public class SysLogininforResp extends BaseEntity {
/*
访ID
*/
@TableId(value = "info_id",type = IdType.AUTO)
private Long infoId;
/*
*/
@Schema(description = "用户名",type = "String")
private String userName;
/*
IP
*/
@Schema(description = "用户账号",type = "String")
private String ipaddr;
/*
0 1
*/
@Schema(description = "登录IP地址",type = "char")
private Character status;
/*
*/
@Schema(description = "登录状态0成功 1失败",type = "String")
private String msg;
/*
访
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "提示信息",type = "Date")
private Data accessTime;
}

View File

@ -0,0 +1,126 @@
package com.muyu.market.admain.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
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 lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Tag(name = "充值余额返回", description = "用于响应充值请求参数")
public class updSysUserMoneyResp {
/**
* ID
*/
@TableId(value = "user_id",type = IdType.AUTO)
private Long userId;
/**
* ID
*/
@Schema(description = "部门ID",type = "Long")
private Long deptId;
/**
*
*/
@Schema(description = "用户账号",type = "String")
private String userName;
/**
*
*/
@Schema(description = "用户昵称",type = "String")
private String nickName;
/**
*
*/
@Schema(description = "用户类型",type = "String")
private String userType;
/**
*
*/
@Schema(description = "余额",type = "BigDecimal")
private BigDecimal money;
/**
*
*/
@Schema(description = "用户邮箱",type = "String")
private String email;
/**
*
*/
@Schema(description = "用户邮箱",type = "String")
private String phonenumber;
/**
* 0 1 2
*/
@Schema(description = "用户性别",type = "String")
private String sex;
/**
*
*/
@Schema(description = "头像地址",type = "String")
private String avatar;
/**
*
*/
@Schema(description = "密码",type = "String")
private String password;
/**
* 0 1
*/
@Schema(description = "帐号状态",type = "String")
private String status;
/**
* 0 2
*/
@Schema(description = "删除标志",type = "String")
private String delFlag;
/**
* IP
*/
@Schema(description = "最后登录IP",type = "String")
private String loginIp;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "最后登录时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
private Date loginDate;
/**
*
*/
@Schema(description = "创建者",type = "String")
private String createBy;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
private Date createTime;
/**
*
*/
@Schema(description = "更新者",type = "String")
private String updateBy;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新时间",defaultValue = "2024-5-15 10:00:52",type = "Date")
private Date updateTime;
/**
*
*/
@Schema(description = "备注",type = "String")
private String remark;
}

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-market2</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>cloud-market2-remote</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-market2-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,8 @@
package com.muyu;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-market2</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>cloud-market2-server</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 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>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- MuYu Common DataSource -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-datasource</artifactId>
</dependency>
<!-- MuYu Common DataScope -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-datascope</artifactId>
</dependency>
<!-- MuYu Common Log -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-log</artifactId>
</dependency>
<!-- 接口模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-api-doc</artifactId>
</dependency>
<!-- XllJob定时任务 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-xxl</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-rabbit</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-market2-common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-nacos-api</artifactId>
</dependency>
</dependencies>
<build>
<finalName>cloud-market2</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 加入maven deploy插件当在deploy时忽略些model-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,17 @@
package com.muyu.market.server;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableCustomConfig
@EnableMyFeignClients
public class MarketApplication {
public static void main(String[] args) {
SpringApplication.run(MarketApplication.class);
}
}

View File

@ -0,0 +1,103 @@
package com.muyu.market.server.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.market.admain.Myapi;
import com.muyu.market.admain.request.MyapiListReq;
import com.muyu.market.admain.request.MyapiSaveReq;
import com.muyu.market.admain.request.MyapiUpdReq;
import com.muyu.market.admain.response.MyapiListResp;
import com.muyu.market.server.service.MyapiService;
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.RequiredArgsConstructor;
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;
@Slf4j
@RestController
@RequestMapping("/myapi")
@Tag(name = "产品展示控制层",description = "产品展示控制层")
@RequiredArgsConstructor
public class MyapiController {
@Autowired
private MyapiService myapiService;
/**
*
* @param myapiListReq
* @return
*/
@RequestMapping(path = "/myapiList",method = RequestMethod.POST)
@Operation(summary = "查询产品接口",description = "根据接口数据可以查看产品信息")
public Result<List<MyapiListResp>> findByMyapiList(@Validated @RequestBody MyapiListReq myapiListReq){
return Result.success( myapiService.findByMyapiList( myapiListReq ));
}
/**
*
* @param myapiSaveReq
* @return
*/
@PostMapping
@Operation(summary = "接口信息添加",description = "添加接口信息,添加成功才可以使用")
public Result<String> save(@Validated @RequestBody MyapiSaveReq myapiSaveReq){
myapiService.save( Myapi.SaveMyapiList( myapiSaveReq ));
return Result.success(null,"操作成功");
}
/**
*
* @param myapiId
* @param myapiUpdReq
* @return
*/
@PutMapping("/{myapiId}")
@Operation(summary = "接口信息的修改",description = "通过Id修改接口信息")
public Result<String> update(
@Schema(title = "商品ID",type = "Long",description = "修改商品信息",defaultValue = "1")
@PathVariable("myapiId") Long myapiId,
@RequestBody @Validated MyapiUpdReq myapiUpdReq){
myapiService.updateById( Myapi.UpdMyapiList( myapiUpdReq,()->myapiId));
return Result.success(null,"操作成功");
}
/**
*
* @param myapiId
* @return
*/
@DeleteMapping
@Operation(summary = "产品删除",description = "根据ID删除")
public Result<String> removeById(@Validated @RequestParam(value = "myapiId") Long myapiId){
myapiService.removeById(myapiId);
return Result.success(null,"操作成功");
}
/**
*
* @param myapiId
* @return
*/
@PostMapping("/selectById")
@Operation(summary = "产品详细信息",description = "根据ID查询产品")
public Result<Myapi> selectById(@Validated @RequestParam(value = "myapiId") Long myapiId){
Myapi byId = myapiService.getById( myapiId );
return Result.success(byId,"操作成功");
}
}

View File

@ -0,0 +1,30 @@
package com.muyu.market.server.controller;
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");
}
}

View File

@ -0,0 +1,4 @@
//package com.muyu.market.server.controller;
//
//public class SysLogininforController {
//}

View File

@ -0,0 +1,35 @@
package com.muyu.market.server.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.market.admain.SysUser;
import com.muyu.market.server.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/sysUser")
@Tag( name = "个人信息控制层",description = "用于操作用户个人信息")
public class SysUserController {
@Autowired
private SysUserService sysUserService;
@PostMapping("/findById")
@Operation(summary = "显示用户信息",description = "显示用户基本信息")
public Result<SysUser> findById(@RequestParam(value = "userId") Integer userId){
SysUser byId = sysUserService.getById( userId );
return Result.success(byId);
}
@PostMapping("/updSysUserMoney")
@Operation(summary = "充值",description = "通过修改余额达到充值效果")
public Result updSysUserMoney(@Validated @RequestBody SysUser sysUser){
Integer i = sysUserService.updSysUserMoney( sysUser );
return i>0?Result.success():Result.error(500,"充值失败 请联系管理员");
}
}

View File

@ -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("南京");
}
}

View File

@ -0,0 +1,9 @@
package com.muyu.market.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.market.admain.Myapi;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MyapiMapper extends BaseMapper<Myapi> {
}

View File

@ -0,0 +1,9 @@
//package com.muyu.market.server.mapper;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.muyu.market.admain.SysLogininfor;
//import org.apache.ibatis.annotations.Mapper;
//
//@Mapper
//public interface SysLogininforMapper extends BaseMapper<SysLogininfor> {
//}

View File

@ -0,0 +1,9 @@
package com.muyu.market.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.market.admain.SysUser;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
}

View File

@ -0,0 +1,47 @@
package com.muyu.market.server.service.Impl;
import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.market.admain.Myapi;
import com.muyu.market.admain.request.MyapiListReq;
import com.muyu.market.admain.response.MyapiListResp;
import com.muyu.market.server.mapper.MyapiMapper;
import com.muyu.market.server.service.MyapiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class MyapiServiceImpl extends ServiceImpl<MyapiMapper, Myapi> implements MyapiService {
@Autowired
private MyapiMapper myapiMapper;
@Override
public List<MyapiListResp> findByMyapiList(MyapiListReq myapiListReq) {
LambdaQueryWrapper<Myapi> lambdaQueryWrapperlist = new LambdaQueryWrapper<>();
/**
*
*/
if (StringUtils.isNotBlank( myapiListReq.getName())) {
lambdaQueryWrapperlist.like( Myapi::getName, myapiListReq.getName());
}
List<Myapi> productlist = this.list(lambdaQueryWrapperlist);
return productlist.stream()
.map( MyapiListResp::selProductList)
.collect(Collectors.toList());
}
}

View File

@ -0,0 +1,20 @@
//package com.muyu.market.server.service.Impl;
//
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.muyu.market.admain.SysLogininfor;
//
//import com.muyu.market.admain.response.SysLogininforResp;
//import com.muyu.market.server.mapper.SysLogininforMapper;
//import com.muyu.market.server.service.SysLogininforService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//@Service
//public class SysLogininforServiceImpl extends ServiceImpl<SysLogininforMapper,SysLogininfor> implements SysLogininforService {
// @Autowired
// private SysLogininforMapper sysLogininforMapper;
// @Override
// public SysLogininforResp selectLogininforByUserName(String userName) {
// return null;
// }
//}

View File

@ -0,0 +1,50 @@
package com.muyu.market.server.service.Impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.JwtUtils;
import com.muyu.market.admain.SysUser;
import com.muyu.market.server.mapper.SysUserMapper;
import com.muyu.market.server.service.SysUserService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
@Autowired
private HttpServletRequest request;
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private SysUserMapper sysUserMapper;
//充值余额
@Override
public Integer updSysUserMoney(SysUser sysUser) {
//获取请求头Token
String token = request.getHeader( "token" );
//转userkey
String userKey = JwtUtils.getUserKey( token );
//通过key名字和Token取值
String s = redisTemplate.opsForValue().get( "token:" + userKey );
//转实体类类型
SysUser user = JSONObject.parseObject( s, SysUser.class );
UpdateWrapper<SysUser> sysUserUpdateWrapper = new UpdateWrapper<>();
UpdateWrapper<SysUser> money = sysUserUpdateWrapper.setSql("money=money+"+sysUser.getMoney()).
eq( "user_id",user.getUserId() );
return sysUserMapper.update( money );
}
//回显用户信息
@Override
public SysUser selectByUserId(Integer userId) {
return sysUserMapper.selectById( userId );
}
}

View File

@ -0,0 +1,21 @@
package com.muyu.market.server.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.market.admain.Myapi;
import com.muyu.market.admain.request.MyapiListReq;
import com.muyu.market.admain.response.MyapiListResp;
import java.util.List;
public interface MyapiService extends IService<Myapi> {
/**
*
*
* @param myapiListReq
* @return
*/
List<MyapiListResp> findByMyapiList(MyapiListReq myapiListReq);
}

View File

@ -0,0 +1,13 @@
//package com.muyu.market.server.service;
//
//import com.baomidou.mybatisplus.extension.service.IService;
//import com.muyu.market.admain.SysLogininfor;
//import com.muyu.market.admain.response.SysLogininforResp;
//
//
//public interface SysLogininforService extends IService<SysLogininfor> {
// /*
// 根据名字查询登录日志表
// */
// SysLogininforResp selectLogininforByUserName(String userName);
//}

View File

@ -0,0 +1,23 @@
package com.muyu.market.server.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.market.admain.SysUser;
public interface SysUserService extends IService<SysUser> {
/**
*
*
* @param sysUser
* @return void
*/
Integer updSysUserMoney(SysUser sysUser);
/**
*
*
* @param userId
* @return SysUser
*/
SysUser selectByUserId(Integer userId);
}

View File

@ -0,0 +1,154 @@
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"));
// 设置编码(仅在需要时启用)
try {
System.setOut(new java.io.PrintStream(System.out,true,"UTF-8"));
} catch (java.io.UnsupportedEncodingException e) {
System.err.println("无法设置UTF-8编码" + e.getMessage());
}
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;
}
/**
* gethttp
*
* @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;
}
}

View File

@ -0,0 +1,148 @@
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"));
} else {
System.out.println("调用接口失败:" + jsonObject.getString("reason"));
}
} catch (Exception e) {
e.printStackTrace();
}
return selectWeather;
}
/**
* gethttp
*
* @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;
}
}

View File

@ -0,0 +1,2 @@
com.muyu.market.server.MarketApplication
com.muyu.Main

View File

@ -0,0 +1,2 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}

View File

@ -0,0 +1,56 @@
# Tomcat
server:
port: 6666
# nacos线上地址
nacos:
addr: 12.2.0.252:8848
user-name: nacos
password: nacos
namespace: muyu-cloud
# Spring
spring:
main:
allow-bean-definition-overriding: true
application:
# 应用名称
name: cloud-market2
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: ${nacos.addr}
# nacos用户名
username: ${nacos.user-name}
# nacos密码
password: ${nacos.password}
# 命名空间
namespace: ${nacos.namespace}
config:
# 服务注册地址
server-addr: ${nacos.addr}
# nacos用户名
username: ${nacos.user-name}
# nacos密码
password: ${nacos.password}
# 命名空间
namespace: ${nacos.namespace}
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
# 系统共享配置
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
# 系统环境Config共享配置
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
# xxl-job 配置文件
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
# rabbit 配置文件
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.muyu.system.mapper: DEBUG

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/cloud-pay"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/cloud-pay"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.sky.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 使用gRpc将日志发送到skywalking服务端 -->
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<Pattern>${log.sky.pattern}</Pattern>
</layout>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="GRPC_LOG"/>
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/cloud-pay"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.sky.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 使用gRpc将日志发送到skywalking服务端 -->
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<Pattern>${log.sky.pattern}</Pattern>
</layout>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="GRPC_LOG"/>
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

32
pom.xml 100644
View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-server-parent</artifactId>
<version>3.6.4</version>
</parent>
<artifactId>cloud-market2</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>cloud-market2-client</module>
<module>cloud-market2-common</module>
<module>cloud-market2-remote</module>
<module>cloud-market2-server</module>
</modules>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>