Skip to content

Commit

Permalink
发布 v0.0.2 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
juzi214032 authored Jul 27, 2020
2 parents 0d52b12 + e4b2cc5 commit 8c9c745
Show file tree
Hide file tree
Showing 76 changed files with 1,759 additions and 353 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ version: 2
updates:
- package-ecosystem: "maven" # See documentation for possible values
directory: "/" # Location of package manifests
target-branch: "develop"
schedule:
interval: "daily"
11 changes: 7 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
run: mvn -B package --file pom.xml
deploy:
name: 部署
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- name: 拉取代码
Expand All @@ -36,15 +37,17 @@ jobs:
uses: easingthemes/[email protected]
env:
ARGS: "-rltgoDzvO"
SOURCE: "target/"
REMOTE_HOST: ${{ secrets.HOST }}
SOURCE: "target/oerp-*.jar"
REMOTE_HOST: ${{ secrets.SERVER_HOST }}
REMOTE_USER: ${{ secrets.USER }}
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
TARGET: ${{ secrets.REMOTE_TARGET }}
- name: 启动程序
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: sh /www/wwwroot/oerp.juzibiji.top/springboot/restart.sh
script: |
cd ${{ secrets.REMOTE_TARGET }}
sh restart.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
target/
assets/
#代码生成文件夹
ge/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
config/
19 changes: 17 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -91,7 +99,7 @@
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.3</version>
<version>4.5.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -104,7 +112,7 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-captcha</artifactId>
<version>5.3.9</version>
<version>5.3.10</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -120,6 +128,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.poi.xwpf.converter.xhtml</artifactId>
<version>2.0.2</version>
</dependency>

</dependencies>

<build>
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/com/juzi/oerp/common/aop/ControllerResponseAOP.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.juzi.oerp.common.aop;

import com.juzi.oerp.configuration.properties.CodeMessageProperties;
import com.juzi.oerp.model.vo.response.MessageResponseVO;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
* @author Juzi
* @date 2020/7/20 14:11
*/
@Aspect
@Component
public class ControllerResponseAOP {
@Autowired
private CodeMessageProperties codeMessageProperties;

@AfterReturning(returning = "messageResponseVO", pointcut = "execution(public * com.juzi.oerp.controller..*.*(..))")
public void doAfterReturning(MessageResponseVO messageResponseVO) {
if(messageResponseVO==null){
return;
}

int code = messageResponseVO.getCode();
String oldMessage = messageResponseVO.getMessage();
String newMessage = codeMessageProperties.getCodeMessage().get(code);

if (StringUtils.isEmpty(oldMessage)) {
messageResponseVO.setMessage(newMessage);
}

}
}
5 changes: 5 additions & 0 deletions src/main/java/com/juzi/oerp/common/constant/JWTConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ public class JWTConstants {
* JWT 签名密钥
*/
public static final String JWT_SECRET = "OERP is good!";

/**
* Token 头部字符串
*/
public static final String TOKEN_HEAD = "Bearer ";
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ public AuthenticationException(Integer code) {
super(code);
}

public AuthenticationException(Integer code, Throwable cause) {
super(code, cause);
}

private static final long serialVersionUID = 475369999619649095L;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.juzi.oerp.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;

/**
Expand All @@ -21,6 +19,11 @@ public class OERPException extends RuntimeException {
public OERPException() {
}

public OERPException(Integer code, Throwable cause) {
super(cause);
this.code = code;
}

public OERPException(Integer code) {
this.code = code;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.juzi.oerp.common.exception.AuthenticationException;
import com.juzi.oerp.common.store.LocalUserStore;
import com.juzi.oerp.util.BearerTokenUtils;
import com.juzi.oerp.util.JWTUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
Expand All @@ -25,13 +24,12 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String bearerToken = request.getHeader("Authorization");
if(StringUtils.isBlank(bearerToken)){
if (StringUtils.isBlank(bearerToken)) {
throw new AuthenticationException(40009);
}

String jwtToken = BearerTokenUtils.parseToken(bearerToken);
Integer userId = JWTUtils.parseToken(jwtToken);
log.debug("当前登录用户id为{}",userId);
Integer userId = JWTUtils.parseToken(bearerToken);
log.debug("当前登录用户id为{}", userId);
LocalUserStore.setLocalUser(userId);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.juzi.oerp.common.jackson;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.juzi.oerp.model.dto.param.CreateExamPlaceParamDTO;
import com.juzi.oerp.model.dto.param.UpdateExamParamDTO;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author Juzi
* @date 2020/7/25 21:10
*/
@Component
public class CreateExamParamDeserializer extends JsonDeserializer<UpdateExamParamDTO> {
@Override
public Class<?> handledType() {
return UpdateExamParamDTO.class;
}

@Override
public UpdateExamParamDTO deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
TreeNode treeNode = p.readValueAsTree();
String title = treeNode.get("title").toString().replaceAll("\"", "");
String description = treeNode.get("description").toString().replaceAll("\"", "");
BigDecimal price = new BigDecimal(treeNode.get("price").toString());
long beginTime = Long.parseLong(treeNode.get("beginTime").toString()) / 1000;
ZoneOffset zone = ZoneOffset.ofHours(8);
LocalDateTime beginTimeLocalDateTime = LocalDateTime.ofEpochSecond(beginTime, 0, zone);

long endTime = Long.parseLong(treeNode.get("endTime").toString()) / 1000;
LocalDateTime endTimeLocalDateTime = LocalDateTime.ofEpochSecond(endTime, 0, zone);

Map<LocalDateTime, List<CreateExamPlaceParamDTO>> timePlace = new HashMap<>();
TreeNode timePlaceTreeNode = treeNode.get("timePlace");
timePlaceTreeNode.fieldNames().forEachRemaining(time -> {
LocalDateTime examTime = LocalDateTime.ofEpochSecond(Long.parseLong(time) / 1000, 0, zone);
TreeNode timePlaceTressNodeArray = timePlaceTreeNode.get(time);
List<CreateExamPlaceParamDTO> createExamPlaceParamDTOList = new ArrayList<>();
for (int i = 0; i < timePlaceTressNodeArray.size(); i++) {
// 考试地点
String examPlace = timePlaceTressNodeArray.get(i).get("examPlace").toString().replaceAll("\"", "");
// 考试人数
int peopleNumber = Integer.parseInt(timePlaceTressNodeArray.get(i).get("peopleNumber").toString());
CreateExamPlaceParamDTO createExamPlaceParamDTO = new CreateExamPlaceParamDTO();
createExamPlaceParamDTO
.setExamPlace(examPlace)
.setPeopleNumber(peopleNumber);
createExamPlaceParamDTOList.add(createExamPlaceParamDTO);
}
timePlace.put(examTime, createExamPlaceParamDTOList);
});

UpdateExamParamDTO updateExamParamDTO = new UpdateExamParamDTO();
updateExamParamDTO
.setTitle(title)
.setDescription(description)
.setPrice(price)
.setBeginTime(beginTimeLocalDateTime)
.setEndTime(endTimeLocalDateTime)
.setTimePlace(timePlace);
return updateExamParamDTO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {

@Override
public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
long timestamp = jsonParser.getLongValue();
return LocalDateTime.ofEpochSecond(timestamp / 1000, 0, ZoneOffset.ofHours(8));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AliYunConfiguration {
private AliYunProperties aliYunProperties;

@Bean
public IAcsClient iAcsClient(){
public IAcsClient iAcsClient() {
DefaultProfile profile = DefaultProfile.getProfile(aliYunProperties.getRegionId(), aliYunProperties.getAccessKeyId(), aliYunProperties.getSecret());
return new DefaultAcsClient(profile);
}
Expand Down
Loading

0 comments on commit 8c9c745

Please sign in to comment.