Skip to content

Commit

Permalink
@dev 优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepybear1113 committed May 3, 2022
1 parent 0fc0795 commit 62fb1d6
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 82 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ build/
.vscode/
/out/

src/main/resources/application-tencent.yml
### 自定义 ###
application-tencent.yml
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.xjx</groupId>
<artifactId>ddt-crawler</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>
<name>ddt-crawler</name>
<description>ddt-crawler</description>
<properties>
Expand Down Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/xjx/ddtcrawler/domain/BaseDomain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.xjx.ddtcrawler.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

/**
* There is description
*
* @author sleepybear
* @date 2022/05/03 15:53
*/
@Data
public class BaseDomain implements Serializable {
@Serial
private static final long serialVersionUID = -5347501343901713024L;

@TableId(value = "id", type = IdType.AUTO)
private Long id;
@TableField("modify_time")
private Long modifyTime;
}
15 changes: 5 additions & 10 deletions src/main/java/com/xjx/ddtcrawler/domain/Template.java
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
package com.xjx.ddtcrawler.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xjx.ddtcrawler.utils.EncryptedUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serial;
import java.io.Serializable;

/**
* @author XJX
* @date 2021/8/1 20:56
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("template")
public class Template implements Serializable {
public class Template extends BaseDomain {
@Serial
private static final long serialVersionUID = 6076962907927806205L;

@TableId(value = "id", type = IdType.AUTO)
private Long id;
@TableField("name")
private String name;
@TableField("price")
private Double price;
@TableField("modify_time")
private Long modifyTime;
@TableField(exist = false)
private Boolean isEncrypted = false;

public void encryptId() {
if (this.isEncrypted) {
return;
}
this.id = EncryptedUtils.encryptTemplateId(this.id);
this.setId(EncryptedUtils.encryptTemplateId(this.getId()));
this.isEncrypted = true;
}

public void decryptId() {
if (!this.isEncrypted) {
return;
}
this.id = EncryptedUtils.decryptTemplateId(this.id);
this.setId(EncryptedUtils.decryptTemplateId(this.getId()));
this.isEncrypted = false;
}
}
5 changes: 4 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ spring:
datasource:
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&autoReconnect=true
url: jdbc:mysql://${mysql.url}/ddt?useUnicode=true&autoReconnect=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
connection-test-query: SELECT 1
Expand All @@ -21,6 +21,9 @@ logging:
xjx:
mapper : debug

# 自定义配置
mysql:
url: 127.0.0.1:3306
user-id:
admin: 10000,20000
common: 11111,22222
45 changes: 45 additions & 0 deletions src/main/resources/static/css/css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
td, th {
text-align: center;
border: 1px solid;
}

.table-item-name {
width: 200px;
}

.table-seller {
width: 200px;
}

.table-time {
width: 200px;
}

.bid-unit-black {
color: black;
}

.mouth-unit-black {
color: black;
}

.bid-unit-red {
color: red;
}

.mouth-unit-red {
color: red;
}

.has-buyer {
color: cadetblue;
}

.expected-price {
color: darkgray;
}

.has-border {
border: darkgray solid 1px;
display: inline-block;
}
53 changes: 4 additions & 49 deletions src/main/resources/static/ddt.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,14 @@
<head>
<meta charset="UTF-8">
<title>ddt</title>
<link href="css/css.css" rel="stylesheet">
</head>
<style>
td, th {
text-align: center;
border: 1px solid;
}

.table-item-name {
width: 200px;
}
<script src="lib/js/axios.min.js"></script>
<script src="js/conf/axios-conf.js"></script>
<script src="js/js.js"></script>

.table-seller {
width: 200px;
}

.table-time {
width: 200px;
}

.bid-unit-black {
color: black;
}

.mouth-unit-black {
color: black;
}

.bid-unit-red {
color: red;
}

.mouth-unit-red {
color: red;
}

.has-buyer {
color: cadetblue;
}

.expected-price {
color: darkgray;
}

.has-border {
border: darkgray solid 1px;
display: inline-block;
}
</style>
<body>

<script src="axios.min.js"></script>
<script src="js.js"></script>

<div style="border: black 1px solid; padding: 3px">
<div>
<label for="selfId">selfId </label><input id="selfId" value="">
Expand Down
32 changes: 32 additions & 0 deletions src/main/resources/static/js/conf/axios-conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// axios 全局拦截器
axios.interceptors.response.use(
// 如果返回的状态码为 200,说明接口请求成功,可以正常拿到数据
(response) => {
let res = response.data;
let code = res.code;
if (code === 0) {
return response
} else {
let message = res.message;
if (code > -10) {
alert(message);
} else {
alert("系统错误!\n" + message);
}
// 直接拒绝往下面返回结果信息
return Promise.reject(response);
}
},
// 否则的话抛出错误
(error) => {
let response = error.response;
if (response == null) {
alert(`请求失败,请检查网络`);
return Promise.reject(error);
}
let status = response.status;
let request = error.request;
alert(`请求失败,status = ${status}\n url:${request.responseURL}`);
return Promise.reject(error);
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ function saveUser() {
// 接口数据
let data = res.data;
console.log(data);
if (!processErrorResult(data)) {
return;
}

let success = data.result;
if (success) {
Expand All @@ -36,10 +33,6 @@ function createTemporaryLicense() {
}).then(res => {
// 接口数据
let data = res.data;
let success = processErrorResult(data);
if (!success) {
return;
}
console.log(data);
alert(data.result.message);
});
Expand All @@ -54,10 +47,6 @@ function deleteTemporaryLicense() {
}).then(res => {
// 接口数据
let data = res.data;
let success = processErrorResult(data);
if (!success) {
return;
}
console.log(data);
});
}
Expand Down Expand Up @@ -175,10 +164,6 @@ function getAuctionItems() {
}).then(res => {
// 接口数据
let data = res.data;
let success = processErrorResult(data);
if (!success) {
return;
}

console.log(data);
data = data.result;
Expand Down Expand Up @@ -223,10 +208,6 @@ function getAuctionPriceOder(priceType, sort) {
}).then(res => {
// 接口数据
let data = res.data;
let success = processErrorResult(data);
if (!success) {
return;
}

data = data.result;
console.log(data);
Expand Down
File renamed without changes.

0 comments on commit 62fb1d6

Please sign in to comment.