parent
3d1120a6f6
commit
9234f26201
25 changed files with 497 additions and 282 deletions
@ -0,0 +1,16 @@ |
||||
package org.springblade.desk.quality.pojo.request; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.ToString; |
||||
import org.springblade.desk.quality.pojo.entity.RemindMsg; |
||||
|
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ToString(callSuper = true) |
||||
public class RemindMsgSearch extends RemindMsg { |
||||
|
||||
@Schema(description = "零件名称") |
||||
private String partName; |
||||
} |
||||
@ -0,0 +1,31 @@ |
||||
package org.springblade.desk.util.json; |
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator; |
||||
import com.fasterxml.jackson.databind.SerializerProvider; |
||||
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* 自定义Integer序列化器:0值 或 null 序列化为空字符串,其他值正常序列化 |
||||
*/ |
||||
public class Integer0ToEmptyStringSerializer extends StdScalarSerializer<Integer> { |
||||
|
||||
/** |
||||
* 提供无参构造器,指定处理的类型为Integer |
||||
*/ |
||||
public Integer0ToEmptyStringSerializer() { |
||||
super(Integer.class); |
||||
} |
||||
|
||||
@Override |
||||
public void serialize(Integer value, JsonGenerator gen, SerializerProvider provider) |
||||
throws IOException { |
||||
// 核心逻辑:判断值是否为null或0,是则写空字符串,否则写原数值
|
||||
if (value == null || value == 0) { |
||||
gen.writeString(""); // 0或null时返回空字符串
|
||||
} else { |
||||
gen.writeNumber(value); // 非0数值正常返回数字
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@ |
||||
package org.springblade.desk.util.json; |
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator; |
||||
import com.fasterxml.jackson.databind.SerializerProvider; |
||||
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public class IntegerAllToStringSerializer extends StdScalarSerializer<Integer> { |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public IntegerAllToStringSerializer() { |
||||
super(Integer.class); |
||||
} |
||||
|
||||
@Override |
||||
public void serialize(Integer value, JsonGenerator gen, SerializerProvider provider) |
||||
throws IOException { |
||||
if (value == null || value == 0) { |
||||
gen.writeString(""); |
||||
} else { |
||||
gen.writeString("" + value); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,52 @@ |
||||
package org.springblade.desk.basic.util; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
|
||||
public class RoleUtil { |
||||
|
||||
/** |
||||
* @param roleAlias 角色别名 |
||||
* @return 登录用户是否有角色 |
||||
*/ |
||||
public static Boolean hasRole(String roleAlias) { |
||||
if (StringUtils.isBlank(roleAlias)) { |
||||
throw new IllegalArgumentException("roleAlias参数错误"); |
||||
} |
||||
return AuthUtil.getUserRole().contains(roleAlias); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param roleAliasArray |
||||
* @return 登录用户是否有所有角色(逻辑与关系) |
||||
*/ |
||||
public static Boolean hasAllRole(String... roleAliasArray) { |
||||
if (roleAliasArray == null || roleAliasArray.length == 0) { |
||||
throw new IllegalArgumentException("roleAliasArray参数错误"); |
||||
} |
||||
for (String roleAlias : roleAliasArray) { |
||||
if (!hasRole(roleAlias)) { |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param roleAliasArray |
||||
* @return 登录用户是否有任意角色(逻辑或关系) |
||||
*/ |
||||
public static Boolean hasAnyRole(String... roleAliasArray) { |
||||
if (roleAliasArray == null || roleAliasArray.length == 0) { |
||||
throw new IllegalArgumentException("roleAliasArray参数错误"); |
||||
} |
||||
for (String roleAlias : roleAliasArray) { |
||||
if (hasRole(roleAlias)) { |
||||
return true; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
@ -1,21 +0,0 @@ |
||||
package org.springblade.desk.quality.util; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
|
||||
public class RoleUtil { |
||||
|
||||
|
||||
/** |
||||
* API权限 |
||||
* todo: |
||||
* @param roleAlias |
||||
* @return |
||||
*/ |
||||
public static Boolean hasRole(String roleAlias) { |
||||
if (StringUtils.isBlank(roleAlias)) { |
||||
throw new IllegalArgumentException("roleAlias参数错误"); |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue