Skip to content

Commit

Permalink
🎨 art from idea problems
Browse files Browse the repository at this point in the history
  • Loading branch information
ispong committed Oct 24, 2022
1 parent fe39a53 commit a0a98b5
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 60 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
[Spring Oxygen](https://github.com/isxcode/spring-oxygen) is rapid development integration framework for [Spring](https://spring.io/) .
**Important statement, enterprise-level development is recommended to be used with caution!**
For instructions on use, please check the [website](https://spring-oxygen.isxcode.com) carefully.
Welcome to develop and maintain together, please follow the [github development](https://spring-oxygen.isxcode.com/#/en-us/contributing) specification.
Welcome to develop and maintain together, please follow the [GitHub development](https://spring-oxygen.isxcode.com/#/en-us/contributing) specification.

## 📦 Installation

Expand Down
2 changes: 1 addition & 1 deletion docs/_homepage.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
[Spring Oxygen](https://github.com/isxcode/spring-oxygen) is rapid development integration framework for [Spring](https://spring.io/) .
**Important statement, enterprise-level development is recommended to be used with caution!**
For instructions on use, please check the [website](https://spring-oxygen.isxcode.com) carefully.
Welcome to develop and maintain together, please follow the [github development](https://spring-oxygen.isxcode.com/#/en-us/contributing) specification.
Welcome to develop and maintain together, please follow the [GitHub development](https://spring-oxygen.isxcode.com/#/en-us/contributing) specification.

## 📦 Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
@Slf4j
public class CommandUtils {

public static String LINUX_BASH = "/bin/sh";
public static String WINDOWS_CMD = "C:\\Windows\\System32\\cmd.exe";
public static long DEFAULT_WAITING_TIME = 60000;
public static final String LINUX_BASH = "/bin/sh";
public static final String WINDOWS_CMD = "C:\\Windows\\System32\\cmd.exe";
public static final long DEFAULT_WAITING_TIME = 60000;

/**
* execute command to log file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.DefaultResourceLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ public KeyPair generateKeyPair() throws OxygenException {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(SecretConstants.RSA);
keyPairGenerator.initialize(2048);
return keyPairGenerator.generateKeyPair();

// System.out.println("publicKey:");
//
// System.out.println(Base64.getEncoder().encodeToString(keyPair.getPublic().getEncoded()));
//
// System.out.println("privateKey:");
//
// System.out.println(Base64.getEncoder().encodeToString(keyPair.getPrivate().getEncoded()));
} catch (NoSuchAlgorithmException e) {
log.error(e.getMessage());
throw new OxygenException(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.isxcode.oxygen.core.file.FileUtils;
import com.isxcode.oxygen.core.freemarker.FreemarkerUtils;
import com.isxcode.oxygen.core.pojo.Dog;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
Expand Down Expand Up @@ -33,6 +35,10 @@ public class FreemarkerUtilsTests {
@Test
public void testContentToFile() {

if (Files.exists(Paths.get("freemarker1.txt"))) {
FileUtils.recursionDeleteFile("freemarker1.txt");
}

try {
FreemarkerUtils.contentToFile(templateContent, dog, "freemarker1.txt");
} catch (OxygenException e) {
Expand All @@ -55,6 +61,10 @@ public void testContentToString() {
@Test
public void testTemplateToFile() {

if (Files.exists(Paths.get("freemarker2.txt"))) {
FileUtils.recursionDeleteFile("freemarker2.txt");
}

try {
FreemarkerUtils.templateToFile(templateName, dog, "freemarker2.txt");
} catch (OxygenException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@SpringBootTest
@ContextConfiguration(classes = {OxygenCoreAutoConfiguration.class, FreeMarkerConfigurer.class})
public class SecretUtilsTasks {
public class SecretUtilsTest {

@Test
public void testAesNoKey() {
Expand Down
2 changes: 1 addition & 1 deletion spring-oxygen-flysql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ dependencies {
runtimeOnly 'com.oracle.database.jdbc:ojdbc8'

// jasypt
compile 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.3'
compile 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.4'
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
@Data
public class BaseEntity {

// @RowId
// private String id;

@CreatedDate
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.isxcode.oxygen.flysql.common;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
Expand All @@ -17,8 +16,7 @@
public class LocalDateDeserializer extends JsonDeserializer<LocalDate> {

@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return LocalDate.parse(p.getText(), dtf);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.isxcode.oxygen.flysql.common;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
Expand All @@ -17,8 +16,7 @@
public class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {

@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

return LocalDateTime.ofEpochSecond(p.getLongValue() / 1000, 0, ZoneOffset.ofHours(8));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
@Slf4j
public abstract class AbstractSqlBuilder<T> implements FlysqlCondition<T> {

public List<SqlCondition> sqlConditions = new ArrayList<>();
public final List<SqlCondition> sqlConditions = new ArrayList<>();

public List<String> sqlOrderByConditions = new ArrayList<>();
public final List<String> sqlOrderByConditions = new ArrayList<>();

public Map<String, ColumnProperties> columnsMap;
public final Map<String, ColumnProperties> columnsMap;

public DataBaseType dataBaseType;
public final DataBaseType dataBaseType;

public AbstractSqlBuilder(Class<?> genericType, DataBaseType dataBaseType) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ public void doUpdate() {
FlysqlConstants.LAST_MODIFIED_DATE,
addSingleQuote(
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now()))));
executeUpdate();
}

private void executeUpdate() {
String sqlString =
parseSqlConditions(initUpdateSql(), sqlConditions, sqlOrderByConditions, "UPADTE");

Expand Down Expand Up @@ -247,17 +251,7 @@ public void doIsDelete() {
addSingleQuote(
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now()))));
sqlConditions.add(new SqlCondition(UPDATE, FlysqlConstants.IS_DELETE_COL, "1"));
String sqlString =
parseSqlConditions(initUpdateSql(), sqlConditions, sqlOrderByConditions, "UPADTE");

printSql(sqlString);

try {
flysqlKey.getJdbcTemplate().update(sqlString);
} catch (BadSqlGrammarException e) {
log.error(e.getMessage());
throw new FlysqlException(e.getCause().getMessage());
}
executeUpdate();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
* 排序
Expand All @@ -20,5 +19,5 @@ public enum OrderType {
ASC("asc"),
;

@Getter @Setter private String orderType;
@Getter private final String orderType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,3 @@
* limitations under the License.
*/
package com.isxcode.oxygen.flysql;

/**
* 通过FlysqlAutoConfiguration初始化Flysql对象。初始化所有的template对象(jdbcTemplate/mongoTemplate) 接着用户指定数据库类型和名称
* 生成指定的FlysqlBuilder
*/
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public String getLocalDateTimeValue(String val) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
return "TO_DATE('"
+ sdf2.format(sdf.parse(String.valueOf(val)))
+ "', 'YYYY-MM-DD HH24:MI:SS')";
return "TO_DATE('" + sdf2.format(sdf.parse(val)) + "', 'YYYY-MM-DD HH24:MI:SS')";
} catch (ParseException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public String getLocalDateTimeValue(String val) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
try {
return "N'" + sdf2.format(sdf.parse(String.valueOf(val))) + "'";
return "N'" + sdf2.format(sdf.parse(val)) + "'";
} catch (ParseException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.isxcode.oxygen.flysql.response;

import com.isxcode.oxygen.flysql.common.BaseResponse;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
Expand Down Expand Up @@ -96,11 +97,12 @@ public ResponseEntity<BaseResponse<?>> allException(Exception exception) {
}

@Override
@NonNull
protected ResponseEntity<Object> handleMethodArgumentNotValid(
MethodArgumentNotValidException ex,
HttpHeaders headers,
HttpStatus status,
WebRequest request) {
@NonNull HttpHeaders headers,
@NonNull HttpStatus status,
@NonNull WebRequest request) {
ObjectError objectError = ex.getBindingResult().getAllErrors().get(0);
return new ResponseEntity<>(
new BaseResponse<>("400", objectError.getDefaultMessage(), ""), HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static Map<String, ColumnProperties> parseBeanProperties(Class<?> generic

/* get table name
*
* @param targetClass targetClass
* @param targetClass tCls
* @return tableName
* @since 0.0.1
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ public void testFlysql() {
List<Dog> dogQuery = flysql.build().select(Dog.class).query();
dogQuery.forEach(System.out::println);

// System.out.println("=========================== show page data
// ====================================");
// FlysqlPage<Dog> dogQueryPage = flysql.build().select(Dog.class).queryPage(1, 2);
// System.out.println(dogQueryPage);

System.out.println(
"============================ show single data ===================================");
Dog dogGetOne = flysql.build().select(Dog.class).eq("name", "rose").getOne();
Expand Down

0 comments on commit a0a98b5

Please sign in to comment.