【7.2.5】【rule】新增对json返回字段格式化的接口

pull/37/head
fengshuonan 2022-09-06 13:41:09 +08:00
parent 34b05577dd
commit ac2287833f
4 changed files with 169 additions and 0 deletions

View File

@ -0,0 +1,55 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.rule.annotation;
import cn.stylefeng.roses.kernel.rule.base.JsonFieldFormatProcess;
import cn.stylefeng.roses.kernel.rule.enums.FormatTypeEnum;
import java.lang.annotation.*;
/**
* jsonidcode
*
* @author fengshuonan
* @date 2022/9/6 11:34
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface JsonFieldFormat {
/**
* {@link FormatTypeEnum}
* <p>
*
*/
FormatTypeEnum formatType() default FormatTypeEnum.WRAPPER;
/**
*
*/
Class<? extends JsonFieldFormatProcess> process();
}

View File

@ -0,0 +1,31 @@
package cn.stylefeng.roses.kernel.rule.base;
/**
* json
*
* @author fengshuonan
* @date 2022/9/6 11:54
*/
public interface JsonFieldFormatProcess {
/**
*
*
* @param originValue
* @return true
* @author fengshuonan
* @date 2022/9/6 13:16
*/
boolean canFormat(Object originValue);
/**
*
*
* @param originValue
* @return
* @author fengshuonan
* @date 2022/9/6 13:28
*/
Object formatProcess(Object originValue);
}

View File

@ -0,0 +1,58 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.rule.base;
/**
* keyvalue
* <p>
* keyid
* valueString
*
* @author fengshuonan
* @date 2022/9/6 11:27
*/
public interface ReadableEnum {
/**
* key
* <p>
* 1 2
*
* @author fengshuonan
* @date 2022/9/6 11:29
*/
Object getKey();
/**
* value
* <p>
* "启用" "禁用"
*
* @author fengshuonan
* @date 2022/9/6 11:30
*/
Object getValue();
}

View File

@ -0,0 +1,25 @@
package cn.stylefeng.roses.kernel.rule.enums;
/**
*
*
* @author fengshuonan
* @date 2022/9/6 11:48
*/
public enum FormatTypeEnum {
/**
*
* <p>
* userId=1001userId=
*/
REPLACE,
/**
* +Wrapper"
* <p>
* userId=1001userIdWrapper=
*/
WRAPPER
}