mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-17 23:07:43 +08:00
5.0
This commit is contained in:
@@ -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