4 files modified
1 files added
| | |
| | | package org.example.controller; |
| | | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.example.common.ServerResponse; |
| | | import org.example.dao.ConfigCurrencyMapper; |
| | | import org.example.dao.LogMapper; |
| | | import org.example.pojo.ConfigCurrency; |
| | | import org.example.pojo.Log; |
| | | import org.example.pojo.LoginOut; |
| | | import org.example.pojo.User; |
| | | import org.example.pojo.vo.DeleteConfigVo; |
| | | import org.example.pojo.vo.SaveConfigVo; |
| | | import org.example.server.impl.UserServiceImpl; |
| | | import org.example.util.IpAddressUtil; |
| | | import org.example.util.JwtUtil; |
| | | import org.example.util.MD5Util; |
| | | import org.example.util.RedisUtil; |
| | | import org.example.util.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | import java.security.SecureRandom; |
| | | import java.sql.Date; |
| | | import java.time.LocalDate; |
| | | import java.util.Base64; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @program: demo |
| | |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("/user") |
| | | @CrossOrigin(origins = "*") |
| | | @Slf4j |
| | | public class UserController { |
| | | |
| | | @Autowired |
| | |
| | | private LogMapper logMapper; |
| | | |
| | | @PostMapping("/login") |
| | | @ResponseBody |
| | | public ServerResponse saveUser(@RequestParam("account") String account |
| | | , @RequestParam("password") String password, HttpServletRequest request) { |
| | | , @RequestParam("password") String password, HttpServletRequest request) throws JsonProcessingException { |
| | | try { |
| | | User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getAccount, account)); |
| | | if(null == user){ |
| | | return ServerResponse.createBySuccessMsg("用户不存在"); |
| | | } |
| | | |
| | | User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getAccount, account).eq(User::getIsRoot,0)); |
| | | if(null == user){ |
| | | return ServerResponse.createBySuccessMsg("用户不存在"); |
| | | if (!MD5Util.verify(password, user.getPassword())) { |
| | | return ServerResponse.createBySuccessMsg("密码错误"); |
| | | } |
| | | |
| | | if(user.getIsRoot() == 1){ |
| | | String token = JwtUtil.getToken(user); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("token",token); |
| | | String loginJson = "[\n" + |
| | | " {\n" + |
| | | " \"title\":\"行情比对\",\n" + |
| | | " \"name\":\"index\",\n" + |
| | | " \"path\":\"/index\",\n" + |
| | | " \"icon\":\"el-icon-data-analysis\",\n" + |
| | | " \"component\":\"comparison\"\n" + |
| | | " },\n" + |
| | | " {\n" + |
| | | " \"title\":\"用户管理\",\n" + |
| | | " \"name\":\"user\",\n" + |
| | | " \"path\":\"/user\",\n" + |
| | | " \"icon\":\"el-icon-user\",\n" + |
| | | " \"component\": \"user\"\n" + |
| | | " }\n" + |
| | | "]"; |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | List<LoginOut> loginOuts = objectMapper.readValue(loginJson, new TypeReference<List<LoginOut>>() {}); |
| | | map.put("menu",loginOuts); |
| | | return ServerResponse.createBySuccess(map); |
| | | } |
| | | |
| | | //判断是否锁定 |
| | | if(user.getIsLock() == 1){ |
| | | return ServerResponse.createBySuccessMsg("账号已被锁定"); |
| | | } |
| | | |
| | | //判断是否到期 |
| | | if(new java.util.Date().after(user.getEndTime())){ |
| | | return ServerResponse.createBySuccessMsg("账号已到期"); |
| | | } |
| | | |
| | | String token = JwtUtil.getToken(user); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("token",token); |
| | | String loginJson = "[\n" + |
| | | " {\n" + |
| | | " \"title\":\"行情比对\",\n" + |
| | | " \"name\":\"index\",\n" + |
| | | " \"path\":\"/index\",\n" + |
| | | " \"icon\":\"el-icon-data-analysis\",\n" + |
| | | " \"component\":\"comparison\"\n" + |
| | | " }\n" + |
| | | "]"; |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | List<LoginOut> loginOuts = objectMapper.readValue(loginJson, new TypeReference<List<LoginOut>>() {}); |
| | | map.put("menu",loginOuts); |
| | | |
| | | String key = "user_"; |
| | | RedisUtil.set(key+user.getId(),token); |
| | | String ip = IpAddressUtil.getIpAddress(request); |
| | | String address = null; |
| | | address = IpAddressUtil.getIpPossessionByFile(ip); |
| | | if(null == address){ |
| | | address = IpAddressUtil.getIpAddressByOnline(ip); |
| | | } |
| | | Log log = new Log(); |
| | | log.setIp(ip); |
| | | log.setAccount(account); |
| | | log.setLoginTime(new java.util.Date()); |
| | | log.setAddress(address); |
| | | logMapper.insert(log); |
| | | return ServerResponse.createBySuccess(map); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | log.error("登录异常:"+e.getMessage()); |
| | | } |
| | | |
| | | if (!MD5Util.verify(password, user.getPassword())) { |
| | | return ServerResponse.createBySuccessMsg("密码错误"); |
| | | } |
| | | |
| | | //判断是否锁定 |
| | | if(user.getIsLock() == 1){ |
| | | return ServerResponse.createBySuccessMsg("账号已被锁定"); |
| | | } |
| | | |
| | | //判断是否到期 |
| | | if(new java.util.Date().after(user.getEndTime())){ |
| | | return ServerResponse.createBySuccessMsg("账号已到期"); |
| | | } |
| | | |
| | | |
| | | String token = JwtUtil.getToken(user); |
| | | Map<String,String> map = new HashMap<>(); |
| | | map.put("token",token); |
| | | String key = "user_"; |
| | | RedisUtil.set(key+user.getId(),token); |
| | | String ip = IpAddressUtil.getIpAddress(request); |
| | | String address = null; |
| | | address = IpAddressUtil.getIpPossessionByFile(ip); |
| | | if(null == address){ |
| | | address = IpAddressUtil.getIpAddressByOnline(ip); |
| | | } |
| | | Log log = new Log(); |
| | | log.setIp(ip); |
| | | log.setAccount(account); |
| | | log.setLoginTime(new java.util.Date()); |
| | | log.setAddress(address); |
| | | logMapper.insert(log); |
| | | |
| | | return ServerResponse.createBySuccess(map); |
| | | } |
| | | |
| | | // 生成指定长度的随机 token |
| | | public static String generateToken() { |
| | | SecureRandom secureRandom = new SecureRandom(); |
| | | byte[] token = new byte[16]; |
| | | secureRandom.nextBytes(token); |
| | | return Base64.getUrlEncoder().withoutPadding().encodeToString(token); |
| | | return ServerResponse.createBySuccessMsg("系统异常"); |
| | | } |
| | | |
| | | @PostMapping("/saveConfig") |
| New file |
| | |
| | | package org.example.pojo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class LoginOut { |
| | | |
| | | private String title; |
| | | private String name; |
| | | private String path; |
| | | private String icon; |
| | | private String component; |
| | | |
| | | } |
| | |
| | | public class IpAddressUtil { |
| | | |
| | | // ip2region.xdb 文件地址常量(本地xdb文件路径) |
| | | public static String XDB_PATH = "D:\\项目\\demo\\websocketSerivce\\src\\main\\resources\\ip\\csdn-ip2region.xdb"; |
| | | public static String XDB_PATH = PropertiesUtil.getProperty("XDB_PATH"); |
| | | |
| | | /** |
| | | * 获取IP地址: |
| | |
| | | //log.info("{地区: {}, IO操作数: {}, 耗时: {} μs}", region, searcher.getIOCount(), cost); |
| | | return region; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("获取IP地址异常:{} ", e.getMessage()); |
| | | throw new RuntimeException("获取IP地址异常"); |
| | | } |
| | |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(new LoginInterceptor()) |
| | | .addPathPatterns("/**") // 拦截所有请求 |
| | | .excludePathPatterns("/admin/login", |
| | | .excludePathPatterns( |
| | | "/user/saveConfig", |
| | | "/user/login"); |
| | | } |
| | |
| | | |
| | | # ????? 61001/62000 ?? |
| | | #??vsftpd |
| | | #1. service vsftpd restart |
| | | #2. ??ifconfig????vsftpd????? |
| | | #3. ???? ftp://?? |
| | | XDB_PATH=F:/project/marketData/websocketSerivce/src/main/resources/ip/csdn-ip2region.xdb |
| | | |
| | | ftp.server.ip=103.215.76.36 |
| | | ftp.user=ftp_stock |
| | | ftp.pass=123456 |
| | | #ftp.server.ip=47.56.200.145 |
| | | #ftp.user=ofsuccess |
| | | #ftp.pass=fdymdM34HHsS8iB6 |
| | | #ftp.server.http.prefix=http://www.img.yfkgzq.com/ |
| | | |
| | | # redis config start |
| | | redis1.ip=localhost |
| | | redis1.port=6379 |
| | | redis1.pwd= |
| | | redis1.timeout=10000 |
| | | #redis2.ip=47.52.34.37 |
| | | #redis2.port=6380 |
| | | redis.max.total=50 |
| | | redis.max.idle=10 |
| | | redis.min.idle=2 |
| | | redis.test.borrow=true |
| | | redis.test.return=true |
| | | redis.max.wait.millis=10000 |
| | | # redis config end |
| | | |
| | | #cookie config start |
| | | user.cookie.name=Usertoken |
| | | agent.cookie.name=agenttoken |
| | | admin.cookie.name=admintoken |
| | | |
| | | agent.key.prefix=Mi |
| | | admin.super.name=18916320007 |
| | | |
| | | |
| | | #?? ?? - ???? |
| | | admin.auth.email.subject=???? - ?????? |
| | | #?? ?? - ???? |
| | | admin.auth.email=navihold800@163.com |
| | | #?? ?? - ???? 118318asd XY118318asd |
| | | admin.auth.email.pwd=XY118318asd |
| | | #cookie config end |
| | | |
| | | # close order task config start |
| | | # ???? 50s ????????? 5s |
| | | close.order.task.time.hour=2 |
| | | lock.timeout=50000 |
| | | # close order task config start |
| | | user.password=abcd1234abcd1234 |
| | | #aliyun sms config |
| | | sms.aliyun.accessKeyId=LTAI4FqEYw8va2Bgak2fd9pL |
| | | sms.aliyun.accessKeySecret=WpOZQCHHwuJ9U9oo4yU73RiJY4CuLK |
| | | |
| | | #juhe api |
| | | juhe.stock.key=e27571e4f5f2f07440bf4996d01d5770 |
| | | juhe.ip.key=e5ad6f81997d4f101cc3d17409e18d96 |
| | | #??juhe.ip.key1=ea84726df1d952b8271e118eca51be34//a86451534a6e72728b8cea430dabc633//e5ad6f81997d4f101cc3d17409e18d96//ea84726df1d952b8271e118eca51be34 |
| | | |
| | | #juhe api end |
| | | |
| | | #site setting |
| | | site.email.auth.url=/api/admin/authCharge.do |
| | | site.pc.reg.url=/homes/#/register?code= |
| | | site.m.reg.url=/wap/#/register?code= |
| | | |
| | | #?????? |
| | | #pc.refresh.time=3000 |
| | | |
| | | |
| | | # ?? API ?? |
| | | #sina.market.url=https://hq.sinajs.cn/rn=1520407404627&list=s_sh000001,s_sz399001,s_sz399006,s_sz399300,s_sz399005,s_sz399673 |
| | | sina.market.url=https://hq.sinajs.cn/rn=1520407404627&list=s_sh000001,s_sz399001,s_sz399006,s_sz399300,s_sz399005,s_sz399673,s_sz399106,s_sz399004,s_sz399100 |
| | | sina.single.market.url=https://hq.sinajs.cn/rn=1520407404627&list=s_ |
| | | |
| | | sina.index.market.url=https://ws.api.cnyes.com/ws/api/v4/universal/quote?type=LITQ&column=L |
| | | |
| | | sina.single.stock.url=https://hq.sinajs.cn/list= |
| | | #???? |
| | | sina.single.stock.introduction.url=https://quotes.sina.cn/cn/api/openapi.php/CompanyF10Service.getCompanyInformation?market=cn&symbol= |
| | | nq.single.stock.url=http://192.168.10.5/stock/?type= |
| | | sina.single.stock.min.url=http://image.sinajs.cn/newchart/min/n/ |
| | | sina.single.stock.day.url=http://image.sinajs.cn/newchart/daily/n/ |
| | | sina.single.stock.week.url=http://image.sinajs.cn/newchart/weekly/n/ |
| | | sina.single.stock.month.url=http://image.sinajs.cn/newchart/monthly/n/ |
| | | getUrl=http://192.168.10.3 |
| | | #????cookle |
| | | cookle=xq_a_token=d269ad4aee7ece063038900846f9541a7d0ead07 |
| | | #???? |
| | | hk.stock.url = https://32.push2delay.eastmoney.com/api/qt/clist/get?pn=1&pz=9999&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&wbp2u=%7C0%7C0%7C0%7Cweb&fid=f3&fs=m:128+t:3,m:128+t:4,m:128+t:1,m:128+t:2&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152&_= |
| | | hk.stock.introduction.url =https://datacenter.eastmoney.com/securities/api/data/v1/get?reportName=RPT_HKF10_INFO_ORGPROFILE&columns=SECUCODE,SECURITY_CODE,ORG_NAME,ORG_EN_ABBR,BELONG_INDUSTRY,FOUND_DATE,CHAIRMAN,SECRETARY,ACCOUNT_FIRM,REG_ADDRESS,ADDRESS,YEAR_SETTLE_DAY,EMP_NUM,ORG_TEL,ORG_FAX,ORG_EMAIL,ORG_WEB,ORG_PROFILE,REG_PLACE"eColumns=&filter=(SECUCODE= |
| | | hk.index.url = https://56.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=9999&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&wbp2u=%7C0%7C0%7C0%7Cweb&fid=f5&fs=m:124,m:125,m:305&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152&_= |
| | | hk.index.introduction.url = https://newsinfo.eastmoney.com/kuaixun/v2/api/Channel/5/0/0/50 |
| | | #???? |
| | | us.stock.url = https://1.push2.eastmoney.com/api/qt/clist/get?cb=jQuery1124024849404112285045_1668165974609&pn=1&pz=99999999&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&wbp2u=%7C0%7C0%7C0%7Cweb&fid=f2&fs=m:105,m:106,m:107&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152&_= |
| | | us.stock.introduction.url =https://emweb.eastmoney.com/pc_usf10/CompanyInfo/PageAjax?fullCode= |
| | | us.stock.buy.url = https://push2.eastmoney.com/api/qt/stock/details/get?fields1=f1,f2,f3,f4&fields2=f51,f52,f53,f54,f55&fltt=2&pos=-14&secid= |
| | | us.index.url = https://56.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=999&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&wbp2u=%7C0%7C0%7C0%7Cweb&fid=f3&fs=i:100.NDX,i:100.DJIA,i:100.SPX&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107&_= |
| | | |
| | | #涨停板 |
| | | ztb.url =https://push2ex.eastmoney.com/getTopicZTPool?&ut=7eea3edcaed734bea9cbfc24409ed989&dpt=wz.ztzt&Pageindex=0&pagesize=999&sort=fbt%3Aasc&date=20221202&_= |
| | | |
| | | |
| | | #改变现价 |
| | | #changePrice.url =http://116.124.132.181/stock/base/cx_gp |
| | | #???? |
| | | home.index.recommend.url=https://guba.sina.cn/api/?s=community&a=get_hot_stock_list&type=cn&num=20&page=1&platform=ios&version=6.10.0 |
| | | |
| | | #???? |
| | | sina.single.futures.url=https://hq.sinajs.cn/list= |
| | | sina.single.futures.introduction.url=https://gu.sina.cn/ft/api/openapi.php/FuturesService.getInfoBySymbol?symbol= |
| | | #???? |
| | | sina.single.exchange.url=https://hq.sinajs.cn/list= |
| | | |
| | | # ????K?-??? |
| | | sina.k.min.url=http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData |
| | | sina.k.min.max.size=50 |
| | | # ????K?-??? |
| | | sina.futures.k.min.url=https://gu.sina.cn/ft/api/jsonp.php/var%20_XAU_{time}_{stamp}=/GlobalService.getMink?symbol={code}&type={time} |
| | | sina.futures.k.min.max.size=50 |
| | | # ????K?-??? |
| | | sina.futures.day.min.url=https://stock2.finance.sina.com.cn/futures/api/jsonp.php/var%20_{code}{date}=/GlobalFuturesService.getGlobalFuturesDailyKLine?symbol={code}&_={date}&source=web |
| | | sina.futures.day.min.max.size=50 |
| | | # ????K?-??? |
| | | sina.index.k.min.url=https://quotes.sina.cn/cn/api/jsonp_v2.php/var%20_{code}_{time}_{stamp}=/CN_MarketDataService.getKLineData?symbol={code}&scale={time}&ma=no&datalen=1023 |
| | | sina.index.k.min.max.size=50 |
| | | # ????K?-??? |
| | | sina.index.day.min.url=http://web.ifzq.gtimg.cn/appstock/app/fqkline/get?_var=kline_dayqfq¶m={code},day,,,50,qfq&r=0.8531244563261586 |
| | | sina.index.day.min.max.size=50 |
| | | # ??K?-?? |
| | | qq.k.min.url=http://data.gtimg.cn/flashdata/hushen/daily/20/code.js?visitDstTime=1 |
| | | qq.k.min.max.size=50 |
| | | #?????????? |
| | | qq.month.min.url=http://web.ifzq.gtimg.cn/appstock/app/fqkline/get?param=sz300750,month,,,320,qfq |
| | | #???API |
| | | sina.TwMarket.url=https://ws.api.cnyes.com/ws/api/v1/quote/quotes/ |
| | | sina.TwMarket.list.url=http://b.workingman.icu/stock/api/stock/getStockType?exchange=TAI |
| | | sina.StockType.list.url=http://b.workingman.icu/stock/api/stock/getStockType?exchange= |
| | | sina.StockCategory.list.url=http://b.workingman.icu/stock/api/stock/getWapStocks |
| | | |
| | | http.proxyHost = |
| | | http.proxyPort = |
| | | https.proxyHost = |
| | | https.proxyPort = |
| | | |
| | | # ???? |
| | | #???? |
| | | juhe1.pay.callbackurl=http://xx.com |
| | | #?????? |
| | | juhe1.pay.notifyurl=http://xx.com |
| | | |
| | | #Fly ?? |
| | | fly.pay.merchantid=SLPNXG |
| | | fly.pay.token=0a17a92f45816a88431fa326b3b61baf |
| | | |
| | | #Cmc ?? |
| | | #?????? |
| | | cmc.pay.key=0a17a92f45816a88431fa326b3b61baf |
| | | #????appid |
| | | cmc.pay.uid=74021809 |
| | | #?????? |
| | | cmc.pay.return_url=https://www.bldzb666888.com/homes/#/rechargelist |
| | | #?????? |
| | | cmc.pay.notify_url=https://www.bldzb666888.com/api/pay/juhenewpayNotify.do |
| | | #??????? |
| | | cmc.pay.url=http://pay.phu889.com/api.php/webRequest/tradePay |
| | | |
| | | |
| | | |
| | | fly.pay.serverbackurl=http://www.honghoo.top/api/pay/flyNotify.do |
| | | fly.pay.callbackurl=http://www.honghoo.top/wap/#/user |
| | | |
| | | fly.pay.payurl=https://zf.flyotcpay.com/payment/ |
| | | |
| | | |
| | | #???? |
| | | #??? |
| | | wj.sms.uid=yhi1993 |
| | | #?? |
| | | wj.sms.key=5802bf8c5e3c5bc46c48 |
| | | #??gbk/utf8 |
| | | wj.sms.coding=utf8 |
| | | #短信宝 |
| | | #dxb.sms.USERNAME=banbao |
| | | #dxb.sms.PASSWORD=a705312041274b72b77d43b0ce136913 |
| | | #????? |
| | | website.domain.url=http://www.huijuwang888.com |
| | | website.token=0DC8F78384C7AAFF3192A9C60A473FEE7F89C62888689616B98A06910E86B510 |
| | | #????? |
| | | news.main.url=http://eminfo.eastmoney.com |
| | | spring.main.allow-circular-references=true |
| | | |
| | | spring.mail.host=smtp.gmail.com |
| | | # 邮件服务器端口号 |
| | | spring.mail.port=587 |
| | | # 邮件发送方的电子邮件地址 |
| | | spring.mail.username=barclays5510@gmail.com |
| | | # 邮件发送方的密码或应用程序专用密码(如果启用了两步验证) |
| | | spring.mail.password=nppwibbarixvbnqk |
| | | # 启用TLS加密 |
| | | spring.mail.properties.mail.smtp.starttls.enable=true |
| | | # 验证邮件服务器的身份 |
| | | spring.mail.properties.mail.smtp.auth=true |
| | | # 邮件传输协议 |
| | | spring.mail.properties.mail.transport.protocol=smtp |
| | | |
| | | properties.mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory |
| | | |
| | | |
| | | |
| | | |