Compare commits
7 Commits
ca243b4f52
...
bc97dc7f89
Author | SHA1 | Date |
---|---|---|
|
bc97dc7f89 | |
|
6d4f0c67b9 | |
|
5032bcc26e | |
|
a4044ec0c2 | |
|
3feffee3e8 | |
|
1a778306d8 | |
|
a0d4a53459 |
|
@ -0,0 +1,7 @@
|
|||
package com.muyu;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -23,6 +23,19 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MybatisPlus代码自动生成器 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>3.5.7</version>
|
||||
</dependency>
|
||||
<!-- 默认模板引擎 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.muyu.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.checkerframework.checker.units.qual.N;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.domain
|
||||
* @Project:cloud-mart
|
||||
* @name:Market
|
||||
* @Date:2024/8/21 21:00
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Market {
|
||||
private String name;
|
||||
private String cardno;
|
||||
private String descriot;
|
||||
private String ctftp;
|
||||
private String ctfid;
|
||||
private String gender;
|
||||
private String birthday;
|
||||
private String address;
|
||||
private String zip;
|
||||
private String dirty;
|
||||
private String district1;
|
||||
private String district2;
|
||||
private String district3;
|
||||
private String district4;
|
||||
private String district5;
|
||||
private String district6;
|
||||
private String firstnm;
|
||||
private String lastnm;
|
||||
private String duty;
|
||||
private String mobile;
|
||||
private String tel;
|
||||
private String fax;
|
||||
private String email;
|
||||
private String nation;
|
||||
private String taste;
|
||||
private String education;
|
||||
private String company;
|
||||
private String ctel;
|
||||
private String caddress;
|
||||
private String czip;
|
||||
private String family;
|
||||
private String version;
|
||||
private String id;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.muyu.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.domain
|
||||
* @Project:cloud-mart
|
||||
* @name:PhonePlace
|
||||
* @Date:2024/8/23 20:34
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PhonePlace {
|
||||
private String province;
|
||||
private String city;
|
||||
private String areacode;
|
||||
private String zip;
|
||||
private String company;
|
||||
private String reason;
|
||||
private String tel;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.domain
|
||||
* @Project:cloud-mart
|
||||
* @name:User
|
||||
* @Date:2024/8/22 15:26
|
||||
*/
|
||||
@Data
|
||||
public class User {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String userPwd;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String userPhone;
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
private String userIdentityCard;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String userMailbox;
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal userBalance;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.muyu.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.domain
|
||||
* @Project:cloud-mart
|
||||
* @name:UserSearch
|
||||
* @Date:2024/8/22 16:55
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserSearch {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String userPwd;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String userPhone;
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
private String userIdentityCard;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String userMailbox;
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal userBalance;
|
||||
/**
|
||||
* 用户名查询
|
||||
*/
|
||||
private String blur;
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
private Integer pageSum;
|
||||
/**
|
||||
*每页显示的条数
|
||||
*/
|
||||
private Integer pageSize;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.muyu.utli;
|
||||
|
||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Types;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.utli
|
||||
* @Project:cloud-mart
|
||||
* @name:CodeGenerator
|
||||
* @Date:2024/8/22 14:39
|
||||
*/
|
||||
public class CodeGenerator {
|
||||
public static void main(String[] args) {
|
||||
FastAutoGenerator.create("jdbc:mysql://172.13.1.1:3306/datamart",
|
||||
"root", "root")
|
||||
.globalConfig(builder -> {
|
||||
builder.author("cyp") // 设置作者
|
||||
.enableSwagger() // 开启 swagger 模式
|
||||
.outputDir(System.getProperty("cloud-mart-server")+"/src/main/java"); // 指定输出目录
|
||||
})
|
||||
.dataSourceConfig(builder ->
|
||||
builder.typeConvertHandler((globalConfig, typeRegistry, metaInfo) -> {
|
||||
int typeCode = metaInfo.getJdbcType().TYPE_CODE;
|
||||
if (typeCode == Types.SMALLINT) {
|
||||
// 自定义类型转换
|
||||
return DbColumnType.INTEGER;
|
||||
}
|
||||
return typeRegistry.getColumnType(metaInfo);
|
||||
})
|
||||
)
|
||||
.packageConfig(builder ->
|
||||
builder.parent("com.muyu.cloud") // 设置父包名
|
||||
.moduleName("mart") // 设置父包模块名
|
||||
.serviceImpl("MarketServiceImpl")
|
||||
.pathInfo(Collections.singletonMap(OutputFile.xml, "D://")) // 设置mapperXml生成路径
|
||||
)
|
||||
.strategyConfig(builder ->
|
||||
builder.addInclude("market") // 设置需要生成的表名
|
||||
.addTablePrefix("t_", "c_") // 设置过滤表前缀
|
||||
)
|
||||
.templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
||||
.execute();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.muyu;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -90,6 +90,35 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-mart-common</artifactId>
|
||||
</dependency>
|
||||
<!-- 手机号归属地-->
|
||||
<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>
|
||||
<!-- 老黄历-->
|
||||
<dependency>
|
||||
<groupId>net.sf.json-lib</groupId>
|
||||
<artifactId>json-lib</artifactId>
|
||||
<version>2.2.3</version>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.muyu</groupId>-->
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
package com.muyu.cloud.mart;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/20 上午9:55
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart
|
||||
* @Project:cloud-mart
|
||||
* @name:MarketApplication
|
||||
* @Date:2024/8/21 22:14
|
||||
*/
|
||||
@Log4j2
|
||||
@EnableCustomConfig
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class MuYuMartApplication {
|
||||
public class MarketApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MuYuMartApplication.class, args);
|
||||
SpringApplication.run(MarketApplication.class,args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,249 @@
|
|||
package com.muyu.cloud.mart.config;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.config
|
||||
* @Project:cloud-mart
|
||||
* @name:Demo65
|
||||
* @Date:2024/8/23 9:59
|
||||
* 老黄历
|
||||
*/
|
||||
public class Demo65 {
|
||||
//接口请求地址
|
||||
public static final String CAlENDAR_URL = "http://v.juhe.cn/laohuangli/d?key=%s&date=%s";
|
||||
public static final String HOUR_URL = "http://v.juhe.cn/laohuangli/h?key=%s&date=%s";
|
||||
//申请接口的请求key
|
||||
// TODO: 您需要改为自己的请求key
|
||||
public static final String KEY = "您需要改为自己的请求key";
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// TODO: 日期
|
||||
String date = "2020-11-10";
|
||||
|
||||
|
||||
//日期接口
|
||||
System.out.println("------------日期接口-----------------");
|
||||
printCalendar(date);
|
||||
//时辰接口
|
||||
System.out.println("------------时辰接口-----------------");
|
||||
printHour(date);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 时辰
|
||||
*
|
||||
* @param date String 日期
|
||||
*/
|
||||
public static void printHour(String date) {
|
||||
//发送http请求的url
|
||||
String url = String.format(HOUR_URL, KEY, date);
|
||||
|
||||
final String response = doGet(url);
|
||||
System.out.println("接口返回:" + response);
|
||||
try {
|
||||
JSONObject jsonObject = JSONObject.fromObject(response);
|
||||
int error_code = jsonObject.getInt("error_code");
|
||||
if (error_code == 0) {
|
||||
System.out.println("调用接口成功");
|
||||
JSONArray result = jsonObject.getJSONArray("result");
|
||||
result.stream().map(JSONObject::fromObject).forEach(hour -> {
|
||||
System.out.println("阳历:" + ((JSONObject) hour).getString("yangli"));
|
||||
System.out.println("时间段:" + ((JSONObject) hour).getString("hours"));
|
||||
System.out.println("描述:" + ((JSONObject) hour).getString("des"));
|
||||
System.out.println("宜:" + ((JSONObject) hour).getString("yi"));
|
||||
System.out.println("忌:" + ((JSONObject) hour).getString("ji"));
|
||||
});
|
||||
|
||||
} else {
|
||||
System.out.println("调用接口失败:" + jsonObject.getString("reason"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*
|
||||
* @param date String 日期
|
||||
*/
|
||||
public static void printCalendar(String date) {
|
||||
//发送http请求的url
|
||||
String url = String.format(CAlENDAR_URL, KEY, date);
|
||||
|
||||
final String response = doGet(url);
|
||||
System.out.println("接口返回:" + response);
|
||||
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.println("阳历:" + result.getString("yangli"));
|
||||
System.out.println("阴历:" + result.getString("yinli"));
|
||||
System.out.println("五行:" + result.getString("wuxing"));
|
||||
System.out.println("冲煞:" + result.getString("chongsha"));
|
||||
System.out.println("彭祖百忌:" + result.getString("baiji"));
|
||||
System.out.println("吉神宜趋:" + result.getString("jishen"));
|
||||
System.out.println("宜:" + result.getString("yi"));
|
||||
System.out.println("凶神宜忌:" + result.getString("xiongshen"));
|
||||
System.out.println("忌:" + result.getString("ji"));
|
||||
} else {
|
||||
System.out.println("调用接口失败:" + jsonObject.getString("reason"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get方式的http请求
|
||||
*
|
||||
* @param httpUrl 请求地址
|
||||
* @return 返回结果
|
||||
*/
|
||||
public static String doGet(String httpUrl) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream inputStream = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
String result = null;// 返回结果字符串
|
||||
try {
|
||||
// 创建远程url连接对象
|
||||
URL url = new URL(httpUrl);
|
||||
// 通过远程url连接对象打开一个连接,强转成httpURLConnection类
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
// 设置连接方式:get
|
||||
connection.setRequestMethod("GET");
|
||||
// 设置连接主机服务器的超时时间:15000毫秒
|
||||
connection.setConnectTimeout(15000);
|
||||
// 设置读取远程返回的数据时间:60000毫秒
|
||||
connection.setReadTimeout(60000);
|
||||
// 发送请求
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* post方式的http请求
|
||||
*
|
||||
* @param httpUrl 请求地址
|
||||
* @param param 请求参数
|
||||
* @return 返回结果
|
||||
*/
|
||||
public static String doPost(String httpUrl, String param) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
String result = null;
|
||||
try {
|
||||
URL url = new URL(httpUrl);
|
||||
// 通过远程url连接对象打开连接
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
// 设置连接请求方式
|
||||
connection.setRequestMethod("POST");
|
||||
// 设置连接主机服务器超时时间:15000毫秒
|
||||
connection.setConnectTimeout(15000);
|
||||
// 设置读取主机服务器返回数据超时时间:60000毫秒
|
||||
connection.setReadTimeout(60000);
|
||||
// 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true
|
||||
connection.setDoOutput(true);
|
||||
// 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
|
||||
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
// 通过连接对象获取一个输出流
|
||||
outputStream = connection.getOutputStream();
|
||||
// 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
|
||||
outputStream.write(param.getBytes());
|
||||
// 通过连接对象获取一个输入流,向远程读取
|
||||
if (connection.getResponseCode() == 200) {
|
||||
inputStream = connection.getInputStream();
|
||||
// 对输入流对象进行包装:charset根据工作项目组的要求来设置
|
||||
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 != outputStream) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != inputStream) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.muyu.cloud.mart.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.config
|
||||
* @Project:cloud-mart
|
||||
* @name:IPLocation
|
||||
* @Date:2024/8/23 9:48
|
||||
* IP查询归属地接口
|
||||
*/
|
||||
public class IPLocation {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String apiKey = "e84b7d13a9fb87b4ebcc9813e4518955";
|
||||
String apiUrl = "http://apis.juhe.cn/ip/ipNewV3";
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("key", apiKey);
|
||||
map.put("ip", "47.116.182.215");
|
||||
|
||||
URL url = new URL(String.format(apiUrl + "?" + params(map)));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader((url.openConnection()).getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
public static String params(Map<String, String> map) {
|
||||
return map.entrySet().stream()
|
||||
.map(entry -> {
|
||||
try {
|
||||
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return entry.getKey() + "=" + entry.getValue();
|
||||
}
|
||||
})
|
||||
.collect(Collectors.joining("&"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package com.muyu.cloud.mart.config;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.muyu.domain.Market;
|
||||
import net.sf.json.JSONObject;
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.config
|
||||
* @Project:cloud-mart
|
||||
* @name:JuheDemo
|
||||
* @Date:2024/8/22 22:03
|
||||
*/
|
||||
public class JuheDemo {
|
||||
public static final String DEF_CHATSET = "UTF-8";
|
||||
public static final int DEF_CONN_TIMEOUT = 30000;
|
||||
public static final int DEF_READ_TIMEOUT = 30000;
|
||||
public static String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
|
||||
|
||||
public static void mobileQuery(Market market){
|
||||
String result =null;
|
||||
String url ="http://apis.juhe.cn/mobile/get";//请求接口地址
|
||||
Map params = new HashMap();//请求参数
|
||||
params.put("phone",market.getTel());//需要查询的手机号码
|
||||
params.put("key","8e5493da8edee8e42831574b9a2c3492");//应用APPKEY(应用详细页查询)
|
||||
try {
|
||||
result = net(url, params, "GET");
|
||||
JSONObject object = JSONObject.fromObject(result);
|
||||
if(object.getInt("error_code")==0){
|
||||
System.out.println(object.get("result"));
|
||||
}else{
|
||||
System.out.println(object.get("error_code")+":"+object.get("reason"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param strUrl 请求地址
|
||||
* @param params 请求参数
|
||||
* @param method 请求方法
|
||||
* @return 网络请求字符串
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String net(String strUrl, Map params,String method) throws Exception {
|
||||
HttpURLConnection conn = null;
|
||||
BufferedReader reader = null;
|
||||
String rs = null;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if(method==null || method.equals("GET")){
|
||||
strUrl = strUrl+"?"+urlencode(params);
|
||||
}
|
||||
URL url = new URL(strUrl);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
if(method==null || method.equals("GET")){
|
||||
conn.setRequestMethod("GET");
|
||||
}else{
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
}
|
||||
conn.setRequestProperty("User-agent", userAgent);
|
||||
conn.setUseCaches(false);
|
||||
conn.setConnectTimeout(DEF_CONN_TIMEOUT);
|
||||
conn.setReadTimeout(DEF_READ_TIMEOUT);
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.connect();
|
||||
if (params!= null && method.equals("POST")) {
|
||||
try {
|
||||
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
|
||||
out.writeBytes(urlencode(params));
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
InputStream is = conn.getInputStream();
|
||||
reader = new BufferedReader(new InputStreamReader(is, DEF_CHATSET));
|
||||
String strRead = null;
|
||||
while ((strRead = reader.readLine()) != null) {
|
||||
sb.append(strRead);
|
||||
}
|
||||
rs = sb.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
//将map型转为请求参数型
|
||||
public static String urlencode(Map<String,String> data) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry i : data.entrySet()) {
|
||||
try {
|
||||
sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue()+"","UTF-8")).append("&");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
//package com.muyu.cloud.mart.config;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.annotation.DbType;
|
||||
//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
//import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
//import org.mybatis.spring.annotation.MapperScan;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
///**
|
||||
// * @Author:chaiyapeng
|
||||
// * @Package:com.muyu.cloud.mart.config
|
||||
// * @Project:cloud-mart
|
||||
// * @name:MybatisPlusConfig
|
||||
// * @Date:2024/8/22 16:59
|
||||
// */
|
||||
//@Configuration
|
||||
//@MapperScan("com.muyu.cloud.mart.mapper")
|
||||
//public class MybatisPlusConfig {
|
||||
// @Bean
|
||||
// public MybatisPlusInterceptor mybatisPlusInterceptor(){
|
||||
// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
// return interceptor;
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,54 @@
|
|||
package com.muyu.cloud.mart.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.config
|
||||
* @Project:cloud-mart
|
||||
* @name:NewsLocation
|
||||
* @Date:2024/8/23 9:52
|
||||
* 新闻头条接口
|
||||
*/
|
||||
public class NewsInterface {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String apiKey = "cdbb93769c75054e6beda4c1dc0b6a0b";
|
||||
String apiUrl = "http://v.juhe.cn/toutiao/index";
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("key", apiKey);
|
||||
map.put("type", "top");
|
||||
map.put("page", "20");
|
||||
map.put("page_size", "");
|
||||
map.put("is_filter", "");
|
||||
|
||||
URL url = new URL(String.format(apiUrl + "?" + params(map)));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader((url.openConnection()).getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
public static String params(Map<String, String> map) {
|
||||
return map.entrySet().stream()
|
||||
.map(entry -> {
|
||||
try {
|
||||
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return entry.getKey() + "=" + entry.getValue();
|
||||
}
|
||||
})
|
||||
.collect(Collectors.joining("&"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.muyu.cloud.mart.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.config
|
||||
* @Project:cloud-mart
|
||||
* @name:WeatherInterface
|
||||
* @Date:2024/8/23 10:11
|
||||
* 气象预警接口
|
||||
*/
|
||||
public class WeatherInterface {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String apiKey = "80e78ee9adaded8b1f42ec9cbdf69ac9";
|
||||
String apiUrl = "https://apis.juhe.cn/fapig/alarm/citys";
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("key", apiKey);
|
||||
|
||||
URL url = new URL(String.format(apiUrl + "?" + params(map)));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader((url.openConnection()).getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
public static String params(Map<String, String> map) {
|
||||
return map.entrySet().stream()
|
||||
.map(entry -> {
|
||||
try {
|
||||
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return entry.getKey() + "=" + entry.getValue();
|
||||
}
|
||||
})
|
||||
.collect(Collectors.joining("&"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.muyu.cloud.mart.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import com.muyu.cloud.mart.config.IPLocation;
|
||||
import com.muyu.cloud.mart.service.MarketService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.domain.Market;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.etl.controller
|
||||
* @Project:cloud-mart
|
||||
* @name:MarketController
|
||||
* @Date:2024/8/21 21:53
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("list")
|
||||
public class MarketController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private MarketService marketService;
|
||||
@Autowired
|
||||
private RedisTemplate<String,String>redisTemplate;
|
||||
|
||||
// @RequiresPermissions("mart:info:list")
|
||||
|
||||
/**
|
||||
* 两千万条数据查询
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("findMarketList")
|
||||
public Result<TableDataInfo<Market>> findMarketList(){
|
||||
List<Market> list = marketService.findMarketList();
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号查询归属地
|
||||
*/
|
||||
@GetMapping("getPhonePlace")
|
||||
public Result getPhonePlace(@RequestParam(name = "tel") String tel){
|
||||
return marketService.getPhonePlace(tel);
|
||||
}
|
||||
/**
|
||||
* IP查询归属地
|
||||
*/
|
||||
@GetMapping("getIpPlace")
|
||||
public Result getIpPlace(@RequestParam(name = "ip") String ip){
|
||||
return marketService.getIpPlace(ip);
|
||||
}
|
||||
/**
|
||||
* 新闻头条
|
||||
*/
|
||||
@GetMapping("getHeadlines")
|
||||
public Result getHeadlines(){
|
||||
return marketService.getHeadlines();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.cloud.mart.controller;
|
||||
|
||||
import com.dtflys.forest.annotation.Post;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.muyu.cloud.mart.mapper.UserMapper;
|
||||
import com.muyu.cloud.mart.service.UserService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.domain.User;
|
||||
import com.muyu.domain.UserSearch;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.controller
|
||||
* @Project:cloud-mart
|
||||
* @name:UserController
|
||||
* @Date:2024/8/22 15:28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("user")
|
||||
public class UserController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
/**
|
||||
* 查询所以用户信息
|
||||
*/
|
||||
@GetMapping("getAllUsers")
|
||||
public Result getAllUsers(){
|
||||
List<User> list = userService.getAllUsers();
|
||||
return Result.success(list);
|
||||
}
|
||||
/**
|
||||
* 添加新用户
|
||||
*/
|
||||
@PostMapping("/addUser")
|
||||
public Result addUser(@RequestBody User user){
|
||||
return userService.addUser(user);
|
||||
}
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
@PostMapping("/updateUser")
|
||||
public Result updateUser(@RequestBody User user){
|
||||
return userService.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
@PostMapping("deleteUser")
|
||||
public Result deleteUser(@RequestBody User user){
|
||||
return userService.deleteUser(user);
|
||||
}
|
||||
/**
|
||||
* 多条件分页查询
|
||||
*/
|
||||
@PostMapping("getAllUserByCon")
|
||||
public Result getAllUserByCon(@RequestBody UserSearch userSearch){
|
||||
startPage();
|
||||
return userService.getAllUserByCon(userSearch);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.cloud.mart.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.Market;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.etl.mapper
|
||||
* @Project:cloud-mart
|
||||
* @name:MarketMapper
|
||||
* @Date:2024/8/21 21:54
|
||||
*/
|
||||
@Mapper
|
||||
public interface MarketMapper extends BaseMapper<Market> {
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.cloud.mart.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.mapper
|
||||
* @Project:cloud-mart
|
||||
* @name:UserMapper
|
||||
* @Date:2024/8/22 15:28
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.cloud.mart.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.Market;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.etl.service
|
||||
* @Project:cloud-mart
|
||||
* @name:MarketService
|
||||
* @Date:2024/8/21 21:54
|
||||
*/
|
||||
public interface MarketService extends IService<Market> {
|
||||
List<Market> findMarketList();
|
||||
|
||||
Result getPhonePlace(String tel);
|
||||
|
||||
Result getIpPlace(String ip);
|
||||
|
||||
Result getHeadlines();
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.cloud.mart.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.User;
|
||||
import com.muyu.domain.UserSearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.service
|
||||
* @Project:cloud-mart
|
||||
* @name:UserService
|
||||
* @Date:2024/8/22 15:28
|
||||
*/
|
||||
public interface UserService extends IService<User> {
|
||||
List<User> getAllUsers();
|
||||
|
||||
Result addUser(User user);
|
||||
|
||||
Result updateUser(User user);
|
||||
|
||||
Result deleteUser(User user);
|
||||
|
||||
Result getAllUserByCon(UserSearch userSearch);
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.muyu.cloud.mart.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import com.muyu.cloud.mart.utils.IPLocation;
|
||||
import com.muyu.cloud.mart.utils.MobileLocation;
|
||||
import com.muyu.cloud.mart.mapper.MarketMapper;
|
||||
import com.muyu.cloud.mart.service.MarketService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.Market;
|
||||
import com.muyu.domain.PhonePlace;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.muyu.cloud.mart.config.IPLocation.params;
|
||||
import static com.muyu.common.core.utils.PageUtils.startPage;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.etl.service.impl
|
||||
* @Project:cloud-mart
|
||||
* @name:MarketServiceImpl
|
||||
* @Date:2024/8/21 21:54
|
||||
*/
|
||||
@Service
|
||||
@Log4j2
|
||||
public class MarketServiceImpl extends ServiceImpl<MarketMapper, Market> implements MarketService {
|
||||
|
||||
@Autowired
|
||||
private MarketMapper marketMapper;
|
||||
@Autowired
|
||||
private RedisTemplate<String,String>redisTemplate;
|
||||
|
||||
@Override
|
||||
public List<Market> findMarketList() {
|
||||
if (redisTemplate.hasKey("list")){
|
||||
List<String> list = redisTemplate.opsForList().range("list", 0, -1);
|
||||
ArrayList<Market> markets = new ArrayList<>();
|
||||
for (String s : list) {
|
||||
markets.add(JSON.parseObject(s, Market.class));
|
||||
}
|
||||
return markets;
|
||||
}
|
||||
startPage();
|
||||
// List<Market> list = marketService.findMarketList();
|
||||
List<Market> list = marketMapper.selectList(null);
|
||||
for (Market market1 : list) {
|
||||
redisTemplate.opsForList().rightPush("list", JSON.toJSONString(market1));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
// public static final PhoneNumberOfflineGeocoder GEOCODER = PhoneNumberOfflineGeocoder.getInstance();
|
||||
|
||||
/**
|
||||
* 手机号查询归属地
|
||||
* @param tel
|
||||
*/
|
||||
@Override
|
||||
public Result getPhonePlace(String tel) {
|
||||
PhonePlace phonePlace = MobileLocation.queryMobileLocation(tel);
|
||||
return Result.success(phonePlace);
|
||||
}
|
||||
|
||||
/**
|
||||
* IP查询归属地
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result getIpPlace(String ip) {
|
||||
StringBuffer stringBuffer = IPLocation.queryMobileLocation(ip);
|
||||
return Result.success(stringBuffer);
|
||||
}
|
||||
/**
|
||||
* 新闻头条
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result getHeadlines() {
|
||||
String apiKey = "cdbb93769c75054e6beda4c1dc0b6a0b";
|
||||
String apiUrl = "http://v.juhe.cn/toutiao/index";
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("key", apiKey);
|
||||
map.put("type", "top");
|
||||
map.put("page", "20");
|
||||
map.put("page_size", "");
|
||||
map.put("is_filter", "");
|
||||
try {
|
||||
URL url = new URL(String.format(apiUrl + "?" + params(map)));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader((url.openConnection()).getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
System.out.println(response);
|
||||
return Result.success(response);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.muyu.cloud.mart.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.cloud.mart.mapper.UserMapper;
|
||||
import com.muyu.cloud.mart.service.UserService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.User;
|
||||
import com.muyu.domain.UserSearch;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.service.impl
|
||||
* @Project:cloud-mart
|
||||
* @name:UserServiceImpl
|
||||
* @Date:2024/8/22 15:29
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public List<User> getAllUsers() {
|
||||
List<User> list = userMapper.selectList(null);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addUser(User user) {
|
||||
Integer i = userMapper.insert(user);
|
||||
if (i>0){
|
||||
return Result.success(i,"添加成功");
|
||||
}else {
|
||||
return Result.error("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateUser(User user) {
|
||||
Integer i = userMapper.updateById(user);
|
||||
if (i>0){
|
||||
return Result.success(i,"更新成功");
|
||||
}else{
|
||||
return Result.error("更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteUser(User user) {
|
||||
Integer i = userMapper.deleteById(user);
|
||||
if (i>0){
|
||||
return Result.success(i,"删除成功");
|
||||
}else {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getAllUserByCon(UserSearch userSearch) {
|
||||
QueryWrapper<User> wrapper = new QueryWrapper<>();
|
||||
if (userSearch.getBlur()!=null && !userSearch.getBlur().equals("")){
|
||||
wrapper.like("user_name",userSearch.getBlur());
|
||||
}
|
||||
List<User> list = userMapper.selectList(wrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.muyu.cloud.mart.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.cloud.mart.utils
|
||||
* @Project:cloud-mart
|
||||
* @name:IPLocation
|
||||
* @Date:2024/8/23 20:54
|
||||
*/
|
||||
public class IPLocation {
|
||||
public static StringBuffer queryMobileLocation(String ip){
|
||||
String apiKey = "e84b7d13a9fb87b4ebcc9813e4518955";
|
||||
String apiUrl = "http://apis.juhe.cn/ip/ipNewV3";
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("key", apiKey);
|
||||
map.put("ip", ip);
|
||||
try {
|
||||
URL url = new URL(String.format(apiUrl + "?" + params(map)));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader((url.openConnection()).getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null){
|
||||
stringBuffer.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
System.out.println(stringBuffer);
|
||||
return stringBuffer;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String params(Map<String, String> map) {
|
||||
return map.entrySet().stream()
|
||||
.map(entry -> {
|
||||
try {
|
||||
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return entry.getKey() + "=" + entry.getValue();
|
||||
}
|
||||
})
|
||||
.collect(Collectors.joining("&"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package com.muyu.cloud.mart.utils;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.muyu.domain.PhonePlace;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 手机号查询归属地接口
|
||||
*/
|
||||
public class MobileLocation {
|
||||
// 手机归属地查询接口地址
|
||||
// http://apis.juhe.cn/mobile/get http://127.0.0.1:8369/query?mobile
|
||||
public static String API_URL = "http://apis.juhe.cn/mobile/get";
|
||||
// 接口请求Key
|
||||
public static String API_KEY = "8e5493da8edee8e42831574b9a2c3492";
|
||||
|
||||
|
||||
/**
|
||||
* 根据手机号码/手机号码前7位查询号码归属地
|
||||
* @param mobile
|
||||
*/
|
||||
public static PhonePlace queryMobileLocation(String tel)
|
||||
{
|
||||
Map<String, Object> params = new HashMap<>();//组合参数
|
||||
params.put("phone", tel);
|
||||
params.put("key", API_KEY);
|
||||
String queryParams = urlencode(params);
|
||||
PhonePlace phonePlace = new PhonePlace();
|
||||
|
||||
String response = doGet(API_URL, queryParams);
|
||||
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");
|
||||
|
||||
phonePlace.setProvince(result.getString("province"));
|
||||
phonePlace.setCity(result.getString("city"));
|
||||
phonePlace.setAreacode(result.getString("areacode"));
|
||||
phonePlace.setZip(result.getString("zip"));
|
||||
phonePlace.setCompany(result.getString("company"));
|
||||
|
||||
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"));
|
||||
|
||||
} else {
|
||||
System.out.println("调用接口失败:" + jsonObject.getString("reason"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return phonePlace;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
|
||||
|
||||
_,--._.-,
|
||||
/\_r-,\_ )
|
||||
.-.) _;='_/ (.;
|
||||
\ \' \/S )
|
||||
L.'-. _.'|-'
|
||||
<_`-'\'_.'/
|
||||
`'-._( \ Shanaka Dias
|
||||
___ \\, ___
|
||||
\ .'-. \\ .-'_. /
|
||||
'._' '.\\/.-'_.'
|
||||
'--``\('--'
|
||||
snd \\
|
||||
`\\,
|
||||
\|
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9798
|
||||
port: 10005
|
||||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
|
@ -8,16 +8,12 @@ nacos:
|
|||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: cloud-2112
|
||||
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
application:
|
||||
# 应用名称
|
||||
name: cloud-mart
|
||||
name: cloud-datamart
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
|
@ -49,8 +45,18 @@ spring:
|
|||
- 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}
|
||||
|
||||
- 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}
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 配置 MyBatis 的日志输出实现类,这里是输出到控制台
|
||||
mapper-locations: classpath:/mapper/*.xml # MyBatis Mapper 文件的位置,这里假设是 XML 形式的 Mapper
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto # 主键生成策略,这里设置为自动增长
|
||||
logic-delete-value: 1 # 逻辑删除标记值,例如设置为 1 表示已删除
|
||||
logic-not-delete-value: 0 # 逻辑未删除标记值,例如设置为 0 表示未删除
|
||||
banner: false # 关闭控制台打印的 MyBatis-Plus Banne
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-mart"/>
|
||||
<property name="log.path" value="logs/cloud-etl"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-mart"/>
|
||||
<property name="log.path" value="logs/cloud-etl"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-test"/>
|
||||
<property name="log.path" value="logs/cloud-text"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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"/>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.cloud.mart.mapper.MarketMapper">
|
||||
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue