+ * 读取状态码 + *
+ * + * @author DengMin + * @date Created in 2020/08/24 + */ +@Component +@ConfigurationProperties(prefix = "meishu") +@PropertySource(value = "classpath:code.properties", encoding = "UTF-8") +public class RemoteProperties { + + private static Map+ * 鉴权拦截器 + *
+ * + * @author DengMin + * @since 2021/4/14 + */ +@Component +public class AuthenticationInterceptor implements HandlerInterceptor { + + +} diff --git b/src/main/java/com/meishu/common/interceptor/LoginRequired.java a/src/main/java/com/meishu/common/interceptor/LoginRequired.java new file mode 100644 index 0000000..0dab707 --- /dev/null +++ a/src/main/java/com/meishu/common/interceptor/LoginRequired.java @@ -0,0 +1,20 @@ +package com.meishu.common.interceptor; + +import java.lang.annotation.*; + +/** + *+ * 自定义验证登陆注解 + *
+ * + * @author DengMin + * @since 2020/12/18 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface LoginRequired { + + String[] value(); +} \ No newline at end of file diff --git b/src/main/java/com/meishu/config/IpWhitelistInterceptor.java a/src/main/java/com/meishu/config/IpWhitelistInterceptor.java new file mode 100644 index 0000000..d75218b --- /dev/null +++ a/src/main/java/com/meishu/config/IpWhitelistInterceptor.java @@ -0,0 +1,41 @@ +package com.meishu.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; + +/** + * ip白名单拦截 + */ +@Component +public class IpWhitelistInterceptor implements HandlerInterceptor { + +// @Value("${auth.ip-whitelist}") +// private String ipWhitelist; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + String ip = getClientIp(request); + List+ * excel 字段 + *
+ * + * @author DengMin + * @date Created in 2020/08/28 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ExcelColumnUtil { + + String value() default ""; + + int col() default 0; +} diff --git b/src/main/java/com/meishu/util/excel/ExcelUtil.java a/src/main/java/com/meishu/util/excel/ExcelUtil.java new file mode 100644 index 0000000..3334bf9 --- /dev/null +++ a/src/main/java/com/meishu/util/excel/ExcelUtil.java @@ -0,0 +1,574 @@ +package com.meishu.util.excel; + +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.http.MediaType; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Excel工具 + * + * @author DengMin + * @date 2019/08/27 13:57 + **/ +@Slf4j +public class ExcelUtil { + + private final static String EXCEL2003 = "xls"; + + private final static String EXCEL2007 = "xlsx"; + + /** + * 导入excel文件 + * + * @param path + * @param cls + * @param file + * @param+ * ${table.comment!} 前端控制器 + *
+ * + * @author ${author} + * @since ${date} + */ +<#if restControllerStyle> +@RestController +@Api(tags = "${table.comment!}") +<#else> +@Controller +#if> +@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}#if>") +<#if kotlin> +class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()#if> +<#else> +<#if superControllerClass??> +public class ${table.controllerName} extends ${superControllerClass} { +<#else> +public class ${table.controllerName} { +#if> + +} +#if> diff --git b/src/main/resources/templates/entity.java.ftl a/src/main/resources/templates/entity.java.ftl new file mode 100644 index 0000000..c63bcc4 --- /dev/null +++ a/src/main/resources/templates/entity.java.ftl @@ -0,0 +1,156 @@ +package ${package.Entity}; + +<#list table.importPackages as pkg> +import ${pkg}; +#list> +<#if swagger2> +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +#if> +<#if entityLombokModel> +import lombok.Data; +import lombok.EqualsAndHashCode; + <#if chainModel> +import lombok.experimental.Accessors; + #if> +#if> + +/** + *+ * ${table.comment!} + *
+ * + * @author ${author} + * @since ${date} + */ +<#if entityLombokModel> +@Data + <#if superEntityClass??> +@EqualsAndHashCode(callSuper = true) + <#else> +@EqualsAndHashCode(callSuper = false) + #if> + <#if chainModel> +@Accessors(chain = true) + #if> +#if> +<#if table.convert> +@TableName("${table.name}") +#if> +<#if swagger2> +@ApiModel(value="${entity}对象", description="${table.comment!}") +#if> +<#if superEntityClass??> +public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}>#if> { +<#elseif activeRecord> +public class ${entity} extends Model<${entity}> { +<#else> +public class ${entity} implements Serializable { +#if> + +<#if entitySerialVersionUID> + private static final long serialVersionUID = 1L; +#if> +<#-- ---------- BEGIN 字段循环遍历 ----------> +<#list table.fields as field> + <#if field.keyFlag> + <#assign keyPropertyName="${field.propertyName}"/> + #if> + + <#if field.comment!?length gt 0> + <#if swagger2> + @ApiModelProperty(value = "${field.comment}") + <#else> + /** + * ${field.comment} + */ + #if> + #if> + <#if field.keyFlag> + <#-- 主键 --> + <#if field.keyIdentityFlag> + @TableId(value = "${field.annotationColumnName}", type = IdType.AUTO) + <#elseif idType??> + @TableId(value = "${field.annotationColumnName}", type = IdType.${idType}) + <#elseif field.convert> + @TableId("${field.annotationColumnName}") + #if> + <#-- 普通字段 --> + <#elseif field.fill??> + <#-- ----- 存在字段填充设置 -----> + <#if field.convert> + @TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill}) + <#else> + @TableField(fill = FieldFill.${field.fill}) + #if> + <#elseif field.convert> + @TableField("${field.annotationColumnName}") + #if> + <#-- 乐观锁注解 --> + <#if (versionFieldName!"") == field.name> + @Version + #if> + <#-- 逻辑删除注解 --> + <#if (logicDeleteFieldName!"") == field.name> + @TableLogic + #if> + private ${field.propertyType} ${field.propertyName}; +#list> +<#------------ END 字段循环遍历 ----------> + +<#if !entityLombokModel> + <#list table.fields as field> + <#if field.propertyType == "boolean"> + <#assign getprefix="is"/> + <#else> + <#assign getprefix="get"/> + #if> + public ${field.propertyType} ${getprefix}${field.capitalName}() { + return ${field.propertyName}; + } + + <#if chainModel> + public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + <#else> + public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + #if> + this.${field.propertyName} = ${field.propertyName}; + <#if chainModel> + return this; + #if> + } + #list> +#if> + +<#if entityColumnConstant> + <#list table.fields as field> + public static final String ${field.name?upper_case} = "${field.name}"; + + #list> +#if> +<#if activeRecord> + @Override + protected Serializable pkVal() { + <#if keyPropertyName??> + return this.${keyPropertyName}; + <#else> + return null; + #if> + } + +#if> +<#if !entityLombokModel> + @Override + public String toString() { + return "${entity}{" + + <#list table.fields as field> + <#if field_index==0> + "${field.propertyName}=" + ${field.propertyName} + + <#else> + ", ${field.propertyName}=" + ${field.propertyName} + + #if> + #list> + "}"; + } +#if> +} diff --git b/src/main/resources/templates/mapper.java.ftl a/src/main/resources/templates/mapper.java.ftl new file mode 100644 index 0000000..be08c59 --- /dev/null +++ a/src/main/resources/templates/mapper.java.ftl @@ -0,0 +1,22 @@ +package ${package.Mapper}; + +import ${package.Entity}.${entity}; +import ${superMapperClassPackage}; +import org.springframework.stereotype.Repository; + +/** + *+ * ${table.comment!} Mapper 接口 + *
+ * + * @author ${author} + * @since ${date} + */ +<#if kotlin> +interface ${table.mapperName} : ${superMapperClass}<${entity}> +<#else> + @Repository +public interface ${table.mapperName} extends ${superMapperClass}<${entity}> { + +} +#if> diff --git b/src/main/resources/templates/mapper.xml.ftl a/src/main/resources/templates/mapper.xml.ftl new file mode 100644 index 0000000..04c2359 --- /dev/null +++ a/src/main/resources/templates/mapper.xml.ftl @@ -0,0 +1,39 @@ + + ++ * ${table.comment!} 服务类 + *
+ * + * @author ${author} + * @since ${date} + */ +<#if kotlin> +interface ${table.serviceName} : ${superServiceClass}<${entity}> +<#else> +public interface ${table.serviceName} extends ${superServiceClass}<${entity}> { + +} +#if> diff --git b/src/main/resources/templates/serviceImpl.java.ftl a/src/main/resources/templates/serviceImpl.java.ftl new file mode 100644 index 0000000..aeebd14 --- /dev/null +++ a/src/main/resources/templates/serviceImpl.java.ftl @@ -0,0 +1,26 @@ +package ${package.ServiceImpl}; + +import ${package.Entity}.${entity}; +import ${package.Mapper}.${table.mapperName}; +import ${package.Service}.${table.serviceName}; +import ${superServiceImplClassPackage}; +import org.springframework.stereotype.Service; + +/** + *+ * ${table.comment!} 服务实现类 + *
+ * + * @author ${author} + * @since ${date} + */ +@Service +<#if kotlin> +open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} { + +} +<#else> +public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} { + +} +#if>