初始化

master
chaiyapeng 2024-08-27 14:15:55 +08:00
parent 703f1f3704
commit 6023a120ce
29 changed files with 1829 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package com.muyu.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.domain
* @Projectcloud-mart
* @nameBirthdayHelper
* @Date2024/8/24 19:37
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Birthday {
private String year;
private String month;
private String day;
private String hour;
}

View File

@ -0,0 +1,64 @@
package com.muyu.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.domain
* @Projectcloud-mart
* @nameConnector
* @Date2024/8/26 10:03
*/
@Data
public class Connector {
/**
* id
*/
private Long connectorId;
/**
*
*/
private String connectorName;
/**
*
*/
private String connectorSort;
/**
*
*/
private String connectorDescribe;
/**
*
*/
private String connectorPicture;
/**
*
*/
private String connectorCompany;
/**
*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date connectorTime;
/**
*
*/
private Integer connectorResidueDegree;
/**
*
*/
private Integer connectorFrequency;
/**
*
*/
private String connectorAddress;
/**
*
*/
private Integer connectorStatus;
}

View File

@ -0,0 +1,51 @@
package com.muyu.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.domain
* @Projectcloud-mart
* @nameMarket
* @Date2024/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;
}

View File

@ -0,0 +1,25 @@
package com.muyu.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.domain
* @Projectcloud-mart
* @namePhonePlace
* @Date2024/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;
}

View File

@ -0,0 +1,22 @@
package com.muyu.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.domain
* @Projectcloud-mart
* @namePostcode
* @Date2024/8/25 11:04
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Postcode {
private String postcode;
private Integer page;
private Integer pagesize;
private String dtype;
}

View File

@ -0,0 +1,60 @@
package com.muyu.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.domain
* @Projectcloud-mart
* @nameUserSearch
* @Date2024/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;
}

View File

@ -0,0 +1,27 @@
package com.muyu.cloud.mart;
import com.github.tobato.fastdfs.FdfsClientConfig;
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;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Import;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart
* @Projectcloud-mart
* @nameMarketApplication
* @Date2024/8/21 22:14
*/
@EnableCustomConfig
@EnableMyFeignClients
@SpringBootApplication
//@Import(FdfsClientConfig.class)
//@EnableFeignClients
public class MarketApplication {
public static void main(String[] args) {
SpringApplication.run(MarketApplication.class,args);
}
}

View File

@ -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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.config
* @Projectcloud-mart
* @nameDemo65
* @Date2024/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();
}
}
/**
* gethttp
*
* @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;
}
/**
* posthttp
*
* @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;
}
}

View File

@ -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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.config
* @Projectcloud-mart
* @nameIPLocation
* @Date2024/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("&"));
}
}

View File

@ -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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.config
* @Projectcloud-mart
* @nameJuheDemo
* @Date2024/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();
}
}

View File

@ -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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.config
* @Projectcloud-mart
* @nameNewsLocation
* @Date2024/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("&"));
}
}

View File

@ -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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.config
* @Projectcloud-mart
* @nameWeatherInterface
* @Date2024/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("&"));
}
}

View File

@ -0,0 +1,92 @@
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.Birthday;
import com.muyu.domain.Market;
import com.muyu.domain.Postcode;
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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.etl.controller
* @Projectcloud-mart
* @nameMarketController
* @Date2024/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();
}
/**
*
*/
@GetMapping("getWeather")
public Result getWeather(){
return marketService.getWeather();
}
/**
*
*/
@PostMapping("getBirthday")
public Result getBirthday(@RequestBody Birthday birthday){
return marketService.getBirthday(birthday);
}
/**
*
*/
@PostMapping("getPostcode")
public Result getPostcode(@RequestBody Postcode postcode){
return marketService.getPostcode(postcode);
}
}

View File

@ -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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.etl.mapper
* @Projectcloud-mart
* @nameMarketMapper
* @Date2024/8/21 21:54
*/
@Mapper
public interface MarketMapper extends BaseMapper<Market> {
}

View File

@ -0,0 +1,32 @@
package com.muyu.cloud.mart.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.core.domain.Result;
import com.muyu.domain.Birthday;
import com.muyu.domain.Market;
import com.muyu.domain.Postcode;
import java.util.List;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.etl.service
* @Projectcloud-mart
* @nameMarketService
* @Date2024/8/21 21:54
*/
public interface MarketService extends IService<Market> {
List<Market> findMarketList();
Result getPhonePlace(String tel);
Result getIpPlace(String ip);
Result getHeadlines();
Result getWeather();
Result getBirthday(Birthday birthday);
Result getPostcode(Postcode postcode);
}

View File

@ -0,0 +1,118 @@
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.*;
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.Birthday;
import com.muyu.domain.Market;
import com.muyu.domain.PhonePlace;
import com.muyu.domain.Postcode;
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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.etl.service.impl
* @Projectcloud-mart
* @nameMarketServiceImpl
* @Date2024/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.queryIPLocation(ip);
return Result.success(stringBuffer);
}
/**
*
* @return
*/
@Override
public Result getHeadlines() {
StringBuffer stringBuffer = Headlines.queryHeadlines();
return Result.success(stringBuffer);
}
/**
*
*/
@Override
public Result getWeather() {
StringBuffer stringBuffer = Weather.queryWeather();
return Result.success(stringBuffer);
}
/**
*
*/
@Override
public Result getBirthday(Birthday birthday) {
StringBuffer stringBuffer = BirthdayHelper.queryBirthday(birthday);
return Result.success(stringBuffer);
}
/**
*
*/
@Override
public Result getPostcode(Postcode postcode) {
StringBuffer stringBuffer = PostcodeInquire.queryPostcode(postcode);
return Result.success(stringBuffer);
}
}

View File

@ -0,0 +1,67 @@
package com.muyu.cloud.mart.utils;
import com.muyu.domain.Birthday;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.utils
* @Projectcloud-mart
* @nameBirthdayHelper
* @Date2024/8/24 19:36
*
*/
public class BirthdayHelper {
public static StringBuffer queryBirthday(Birthday birthday){
String apiKey = "9bbfc46233d4931c39207b090ed4b27c";
String apiUrl = "http://apis.juhe.cn/birthEight/query";
HashMap<String, String> map = new HashMap<>();
map.put("key", apiKey);
map.put("year", birthday.getYear());
birthday.setYear(map.put("year", birthday.getYear()));
map.put("month", birthday.getMonth());
birthday.setMonth(map.put("month", birthday.getMonth()));
map.put("day", birthday.getDay());
birthday.setDay(map.put("day", birthday.getDay()));
map.put("hour", birthday.getHour());
birthday.setHour(map.put("hour", birthday.getHour()));
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 response;
} 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("&"));
}
}

View File

@ -0,0 +1,47 @@
package com.muyu.cloud.mart.utils;
import com.muyu.common.core.domain.Result;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import static com.muyu.cloud.mart.config.IPLocation.params;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.utils
* @Projectcloud-mart
* @nameHeadlines
* @Date2024/8/24 18:39
*
*/
public class Headlines {
public static StringBuffer queryHeadlines(){
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 response;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,56 @@
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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.utils
* @Projectcloud-mart
* @nameIPLocation
* @Date2024/8/23 20:54
* IP
*/
public class IPLocation {
public static StringBuffer queryIPLocation(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("&"));
}
}

View File

@ -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 tel
*/
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;
}
/**
* 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,62 @@
package com.muyu.cloud.mart.utils;
import com.muyu.domain.Postcode;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.utils
* @Projectcloud-mart
* @namePostcode
* @Date2024/8/24 20:50
*/
public class PostcodeInquire {
public static StringBuffer queryPostcode(Postcode postcode){
String apiKey = "0cabcd31c150369d8afb2c8b7e41a2c0";
String apiUrl = "http://v.juhe.cn/postcode/query";
HashMap<String, String> map = new HashMap<>();
map.put("key", apiKey);
map.put("postcode", postcode.getPostcode());//邮编215001
postcode.setPostcode(map.put("postcode", postcode.getPostcode()));
map.put("page", String.valueOf(postcode.getPage()));//页数默认1
map.put("pagesize", "");//每页返回,默认:20,最大不超过50
map.put("dtype", "json");//返回数据的格式,xml或json默认json
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 response;
} 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("&"));
}
}

View File

@ -0,0 +1,56 @@
package com.muyu.cloud.mart.utils;
import java.io.BufferedReader;
import java.io.IOException;
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;
/**
* @Authorchaiyapeng
* @Packagecom.muyu.cloud.mart.utils
* @Projectcloud-mart
* @nameWeather
* @Date2024/8/24 18:51
*
*/
public class Weather {
public static StringBuffer queryWeather() {
String apiKey = "80e78ee9adaded8b1f42ec9cbdf69ac9";
String apiUrl = "https://apis.juhe.cn/fapig/alarm/citys";
HashMap<String, String> map = new HashMap<>();
map.put("key", apiKey);
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 response;
} 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("&"));
}
}

View File

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

View File

@ -0,0 +1,73 @@
# Tomcat
server:
port: 10005
# nacos线上地址
nacos:
addr: 47.116.184.54:8848
user-name: nacos
password: nacos
namespace: cloud-2112
# Spring
spring:
application:
# 应用名称
name: cloud-mart
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}
- 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
#fdfs:
# so-timeout: 1500 # socket 连接时长
# connect-timeout: 600 # 连接 tracker 服务器超时时长
# # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
# tracker-list: 49.235.108.160:22122
# web-server-url: 49.235.108.160:8888
# pool:
# jmx-enabled: false
# # 生成缩略图
# thumb-image:
# height: 500
# width: 500

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-etl"/>
<!-- 日志输出格式 -->
<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-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"/>
<!-- 控制台输出 -->
<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-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"/>
<!-- 控制台输出 -->
<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,7 @@
<?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.ConnectorMapper">
</mapper>

View File

@ -0,0 +1,7 @@
<?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>