mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -2,27 +2,28 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-parent</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-common</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>sop-bridge-nacos</module>
|
||||
<module>sop-gateway-common</module>
|
||||
<module>sop-service-common</module>
|
||||
</modules>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>6.1.11</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@@ -0,0 +1,32 @@
|
||||
package com.gitee.sop.common.bean;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public class SpringContext {
|
||||
|
||||
private static ApplicationContext ctx;
|
||||
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return ctx.getBean(clazz);
|
||||
}
|
||||
|
||||
public static Object getBean(String beanName) {
|
||||
return ctx.getBean(beanName);
|
||||
}
|
||||
|
||||
public static void setApplicationContext(ApplicationContext ctx) {
|
||||
SpringContext.ctx = ctx;
|
||||
}
|
||||
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public static void publishEvent(ApplicationEvent event) {
|
||||
ctx.publishEvent(event);
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.gitee.sop.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Getter
|
||||
public enum StatusEnum {
|
||||
DISABLED((byte)2),
|
||||
ENABLE((byte)1),
|
||||
SET_PWD((byte)3),
|
||||
;
|
||||
|
||||
private final int status;
|
||||
|
||||
public static StatusEnum of(Integer value) {
|
||||
for (StatusEnum statusEnum : StatusEnum.values()) {
|
||||
if (Objects.equals(statusEnum.status, value)) {
|
||||
return statusEnum;
|
||||
}
|
||||
}
|
||||
return DISABLED;
|
||||
}
|
||||
|
||||
StatusEnum(byte style) {
|
||||
this.status = style;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.gitee.sop.common.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class IdParam {
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.gitee.sop.common.req;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.req.IdParam;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class StatusUpdateParam extends IdParam {
|
||||
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.gitee.sop.common.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author thc
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> {
|
||||
|
||||
private static final Result<?> RESULT = new Result<>();
|
||||
|
||||
private String code = "0";
|
||||
private T data;
|
||||
private String msg = "success";
|
||||
|
||||
public static Result<?> ok() {
|
||||
return RESULT;
|
||||
}
|
||||
|
||||
public static <E> Result<E> ok(E obj) {
|
||||
Result<E> result = new Result<>();
|
||||
result.setData(obj);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <E> Result<E> err(String msg) {
|
||||
Result<E> result = new Result<>();
|
||||
result.setCode("1");
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <E> Result<E> err(String code, String msg) {
|
||||
Result<E> result = new Result<>();
|
||||
result.setCode(code);
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean getSuccess() {
|
||||
return Objects.equals("0", code);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user