1 文件已重命名
5个文件已修改
12个文件已添加
| | |
| | | package com.ruoyi.company.api.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | |
| | | /** 主键 */ |
| | | @TableId |
| | | private Long id; |
| | | /** 企业用户id */ |
| | | private Long userId; |
| | | |
| | | /** 公司名称 */ |
| | | private String companyName; |
| | |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** 是否删除 */ |
| | | @TableLogic |
| | | private Boolean isDelete; |
| | | } |
New file |
| | |
| | | package com.ruoyi.company.api.domain.query; |
| | | |
| | | import com.ruoyi.common.core.page.BasePage; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2025/1/20 |
| | | */ |
| | | @Data |
| | | @Schema(name = "管理端企业列表查询对象") |
| | | public class MgtCompanyQuery extends BasePage { |
| | | private static final long serialVersionUID = 5429160619805017277L; |
| | | |
| | | @Schema(name = "企业信息") |
| | | private String companyInfo; |
| | | |
| | | @Schema(name = "法人信息") |
| | | private String legalPersonInfo; |
| | | |
| | | @Schema(name = "联系信息") |
| | | private String contactInfo; |
| | | } |
New file |
| | |
| | | package com.ruoyi.company.api.domain.vo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2025/1/20 |
| | | */ |
| | | @Data |
| | | @Schema(name = "管理端企业信息",description = "管理端企业信息") |
| | | public class MgtCompanyVO { |
| | | /** 主键 */ |
| | | @TableId |
| | | @Schema(description = "主键", example = "1") |
| | | private Long id; |
| | | |
| | | /** 公司名称 */ |
| | | @Schema(description = "公司名称", example = "某某科技有限公司") |
| | | private String companyName; |
| | | |
| | | /** 统一社会信用代码 */ |
| | | @Schema(description = "统一社会信用代码", example = "913100000000123") |
| | | private String socialCode; |
| | | |
| | | /** 省份代码 */ |
| | | @Schema(description = "省份代码", example = "01") |
| | | private String provinceCode; |
| | | |
| | | /** 城市代码 */ |
| | | @Schema(description = "城市代码", example = "020") |
| | | private String cityCode; |
| | | |
| | | /** 区域代码 */ |
| | | @Schema(description = "区域代码", example = "003") |
| | | private String districtCode; |
| | | |
| | | /** 经营地址 */ |
| | | @Schema(description = "经营地址", example = "北京市海淀区") |
| | | private String businessAddress; |
| | | |
| | | /** 身份证正面照片 */ |
| | | @Schema(description = "身份证正面照片 URL", example = "https://example.com/idcard-front.jpg") |
| | | private String idCardFrontUrl; |
| | | |
| | | /** 身份证反面照片 */ |
| | | @Schema(description = "身份证反面照片 URL", example = "https://example.com/idcard-back.jpg") |
| | | private String idCardBackUrl; |
| | | |
| | | /** 法人姓名 */ |
| | | @Schema(description = "法人姓名", example = "张三") |
| | | private String legalPersonName; |
| | | |
| | | /** 身份证号码 */ |
| | | @Schema(description = "身份证号码", example = "110101199001012345") |
| | | private String idCardNumber; |
| | | |
| | | /** 营业执照照片 */ |
| | | @Schema(description = "营业执照照片 URL", example = "https://example.com/business-license.jpg") |
| | | private String businessLicenseUrl; |
| | | |
| | | /** 资质类目:1-再生资源回收备案资质 2-家电拆解资质 3-报废机动车回收拆解资质 4-危险废物经营许可证 0-其他证书 */ |
| | | @Schema(description = "资质类目", example = "1", allowableValues = {"0", "1", "2", "3", "4"}) |
| | | private Integer category; |
| | | |
| | | /** 拆解企业资质证书图片地址 */ |
| | | @Schema(description = "拆解企业资质证书图片地址 URL", example = "https://example.com/certificate.jpg") |
| | | private String certificateUrl; |
| | | |
| | | /** 联系人姓名 */ |
| | | @Schema(description = "联系人姓名", example = "李四") |
| | | private String contactName; |
| | | |
| | | /** 联系人手机号 */ |
| | | @Schema(description = "联系人手机号", example = "13800138000") |
| | | private String contactPhone; |
| | | |
| | | /** 联系人邮箱 */ |
| | | @Schema(description = "联系人邮箱", example = "example@example.com") |
| | | private String email; |
| | | |
| | | /** 创建时间 */ |
| | | @Schema(description = "创建时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** 账号 */ |
| | | @Schema(description = "账号") |
| | | private String accountName; |
| | | |
| | | /** 手机号 */ |
| | | @Schema(description = "绑定手机号") |
| | | private String phone; |
| | | |
| | | } |
| | |
| | | <artifactId>hutool-all</artifactId> |
| | | </dependency> |
| | | |
| | | <!--lombok--> |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- SpringDoc webmvc --> |
| | | <dependency> |
| | | <groupId>org.springdoc</groupId> |
| | | <artifactId>springdoc-openapi-ui</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 数组工具类 |
| | | * @ClassName ArrayUtils |
| | | * @author wusongsong |
| | | * @since 2022/7/10 12:02 |
| | | * @version 1.0.0 |
| | | **/ |
| | | public class ArrayUtils extends ArrayUtil { |
| | | |
| | | |
| | | |
| | | /** |
| | | * 将源数组转换成指定类型的列表 |
| | | * |
| | | * @param originList 原始列表 |
| | | * @param targetClazz 转换后列表元素的类型 |
| | | * @param <R> 原始列表元素的类型 |
| | | * @param <T> 目标列表元素的类型 |
| | | * @return 目标类型的集合 |
| | | */ |
| | | public static <R, T> List<T> convert(R[] originList, Class<T> targetClazz) { |
| | | return convert(originList, targetClazz, null); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 将源数组转换成指定类型的列表 |
| | | * |
| | | * @param originList 原始列表 |
| | | * @param targetClazz 转换后列表元素的类型 |
| | | * @param convert 转换特殊字段接口 |
| | | * @param <R> 原始列表元素的类型 |
| | | * @param <T> 目标列表元素的类型 |
| | | * @return 目标类型的集合 |
| | | */ |
| | | public static <R, T> List<T> convert(R[] originList, Class<T> targetClazz, Convert<R, T> convert) { |
| | | if (isEmpty(originList)) { |
| | | return null; |
| | | } |
| | | |
| | | return Arrays.stream(originList) |
| | | .map(origin -> BeanUtils.copyBean(origin, targetClazz, convert)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Schema(name = "基础查询列表dto") |
| | | public class BasePage implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -6677391205868835849L; |
| | | /** |
| | | * 分页参数,当前页码 |
| | | */ |
| | | @Schema(name = "分页参数,当前页码") |
| | | private Integer pageCurr = 1; |
| | | /** |
| | | * 分页参数,每页数量 |
| | | */ |
| | | @Schema(name = "分页参数,每页数量,默认为10") |
| | | private Integer pageSize = 10; |
| | | |
| | | public Integer getPageCurr() { |
| | | return pageCurr; |
| | | } |
| | | |
| | | public void setPageCurr(Integer pageCurr) { |
| | | this.pageCurr = pageCurr; |
| | | } |
| | | |
| | | public Integer getPageSize() { |
| | | return pageSize; |
| | | } |
| | | |
| | | public void setPageSize(Integer pageSize) { |
| | | this.pageSize = pageSize; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "BasePage{" + |
| | | "pageCurr=" + pageCurr + |
| | | ", pageSize=" + pageSize + |
| | | '}'; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 继承自 hutool 的BeanUtil,增加了bean转换时自定义转换器的功能 |
| | | */ |
| | | public class BeanUtils extends BeanUtil { |
| | | |
| | | /** |
| | | * 将原对象转换成目标对象,对于字段不匹配的字段可以使用转换器处理 |
| | | * |
| | | * @param source 原对象 |
| | | * @param clazz 目标对象的class |
| | | * @param convert 转换器 |
| | | * @param <R> 原对象类型 |
| | | * @param <T> 目标对象类型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <R, T> T copyBean(R source, Class<T> clazz, Convert<R, T> convert) { |
| | | T target = copyBean(source, clazz); |
| | | if (convert != null) { |
| | | convert.convert(source, target); |
| | | } |
| | | return target; |
| | | } |
| | | /** |
| | | * 将原对象转换成目标对象,对于字段不匹配的字段可以使用转换器处理 |
| | | * |
| | | * @param source 原对象 |
| | | * @param clazz 目标对象的class |
| | | * @param <R> 原对象类型 |
| | | * @param <T> 目标对象类型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <R, T> T copyBean(R source, Class<T> clazz){ |
| | | if (source == null) { |
| | | return null; |
| | | } |
| | | return toBean(source, clazz); |
| | | } |
| | | |
| | | public static <R, T> List<T> copyList(List<R> list, Class<T> clazz) { |
| | | if (list == null || list.size() == 0) { |
| | | return CollUtils.emptyList(); |
| | | } |
| | | return copyToList(list, clazz); |
| | | } |
| | | |
| | | public static <R, T> List<T> copyList(List<R> list, Class<T> clazz, Convert<R, T> convert) { |
| | | if (list == null || list.size() == 0) { |
| | | return CollUtils.emptyList(); |
| | | } |
| | | return list.stream().map(r -> copyBean(r, clazz, convert)).collect(Collectors.toList()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | /** |
| | | * 实现后在接口访问时如果接口实现了这个接口 |
| | | * 会被自动自行接口check进行校验 |
| | | **/ |
| | | public interface Checker<T> { |
| | | |
| | | /** |
| | | * 用于实现validation不能校验的数据逻辑 |
| | | */ |
| | | default void check(){ |
| | | |
| | | } |
| | | |
| | | default void check(T data){ |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.collection.IterUtil; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 继承自 hutool 的集合工具类 |
| | | */ |
| | | public class CollUtils extends CollectionUtil { |
| | | |
| | | public static <T> List<T> emptyList() { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | public static <T> Set<T> emptySet() { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | public static <K,V> Map<K, V> emptyMap() { |
| | | return Collections.emptyMap(); |
| | | } |
| | | |
| | | public static <T> Set<T> singletonSet(T t) { |
| | | return Collections.singleton(t); |
| | | } |
| | | |
| | | public static <T> List<T> singletonList(T t) { |
| | | return Collections.singletonList(t); |
| | | } |
| | | |
| | | public static List<Integer> convertToInteger(List<String> originList){ |
| | | return CollUtils.isNotEmpty(originList) ? originList.stream().map(NumberUtils::parseInt).collect(Collectors.toList()) : null; |
| | | } |
| | | |
| | | public static List<Long> convertToLong(List<String> originLIst){ |
| | | return CollUtils.isNotEmpty(originLIst) ? originLIst.stream().map(NumberUtils::parseLong).collect(Collectors.toList()) : null; |
| | | } |
| | | |
| | | /** |
| | | * 以 conjunction 为分隔符将集合转换为字符串 如果集合元素为数组、Iterable或Iterator,则递归组合其为字符串 |
| | | * @param collection 集合 |
| | | * @param conjunction 分隔符 |
| | | * @param <T> 集合元素类型 |
| | | * @return 连接后的字符串 |
| | | * See Also: IterUtil.join(Iterator, CharSequence) |
| | | */ |
| | | public static <T> String join(Collection<T> collection, CharSequence conjunction) { |
| | | if (null == collection || collection.isEmpty()) { |
| | | return null; |
| | | } |
| | | return IterUtil.join(collection.iterator(), conjunction); |
| | | } |
| | | |
| | | public static <T> String joinIgnoreNull(Collection<T> collection, CharSequence conjunction) { |
| | | if (null == collection || collection.isEmpty()) { |
| | | return null; |
| | | } |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (T t : collection) { |
| | | if(t == null) continue; |
| | | sb.append(t).append(","); |
| | | } |
| | | if(sb.length() <= 0){ |
| | | return null; |
| | | } |
| | | return sb.deleteCharAt(sb.length() - 1).toString(); |
| | | } |
| | | |
| | | /** |
| | | * 集合校验逻辑 |
| | | * |
| | | * @param data 要校验的集合 |
| | | * @param checker 校验器 |
| | | * @param <T> 集合元素类型 |
| | | */ |
| | | public static <T> void check(List<T> data, Checker<T> checker){ |
| | | if(data == null){ |
| | | return; |
| | | } |
| | | for (T t : data){ |
| | | checker.check(t); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 集合校验逻辑 |
| | | * |
| | | * @param data 要校验的集合 |
| | | * @param <T> 集合元素类型 |
| | | */ |
| | | public static <T extends Checker<T>> void check(List<T> data){ |
| | | if(data == null){ |
| | | return; |
| | | } |
| | | for (T t : data){ |
| | | t.check(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将元素加入到集合中,为null的过滤掉 |
| | | * |
| | | * @param list 集合 |
| | | * @param data 要添加的数据 |
| | | * @param <T> 元素类型 |
| | | */ |
| | | public static <T> void add(Collection<T> list, T... data) { |
| | | if (list == null || ArrayUtils.isEmpty(data)) { |
| | | return; |
| | | } |
| | | for (T t : data) { |
| | | if (ObjectUtils.isNotEmpty(t)) { |
| | | list.add(t); |
| | | } |
| | | } |
| | | } |
| | | //将两个集合出现次数相加 |
| | | public static Map<Long, Integer> union(Map<Long, Integer> map1, Map<Long, Integer> map2) { |
| | | if (CollUtils.isEmpty(map1)) { |
| | | return map2; |
| | | } else if (CollUtils.isEmpty(map2)) { |
| | | return map1; |
| | | } |
| | | for (Map.Entry<Long, Integer> entry : map1.entrySet()) { |
| | | Integer num = map2.get(entry.getKey()); |
| | | map2.put(entry.getKey(), NumberUtils.null2Zero(num) + entry.getValue()); |
| | | } |
| | | return map2; |
| | | } |
| | | |
| | | public static <T,R> R getFiledOfFirst(List<T> list, Function<T, R> function) { |
| | | if (CollUtils.isEmpty(list)) { |
| | | return null; |
| | | } |
| | | return function.apply(list.get(0)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | /** |
| | | * 对原对象进行计算,设置到目标对象中 |
| | | **/ |
| | | public interface Convert<R,T>{ |
| | | void convert(R origin, T target); |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import cn.hutool.core.util.NumberUtil; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | public class NumberUtils extends NumberUtil { |
| | | |
| | | |
| | | /** |
| | | * 如果number为空,将number转换为0,否则原数字返回 |
| | | * |
| | | * @param number 原数值 |
| | | * @return 整型数字,0或原数字 |
| | | */ |
| | | public static Integer null2Zero(Integer number){ |
| | | return number == null ? 0 : number; |
| | | } |
| | | |
| | | /** |
| | | * 如果number为空,将number转换为0,否则原数字返回 |
| | | * |
| | | * @param number 原数值 |
| | | * @return 整型数字,0或原数字 |
| | | */ |
| | | public static Double null2Zero(Double number){ |
| | | return number == null ? 0 : number; |
| | | } |
| | | |
| | | /** |
| | | * 如果number为空,将number转换为0L,否则原数字返回 |
| | | * |
| | | * @param number 原数值 |
| | | * @return 长整型数字,0L或原数字 |
| | | */ |
| | | public static Long null2Zero(Long number){ |
| | | return number == null ? 0L : number; |
| | | } |
| | | |
| | | |
| | | public static Double setScale(Double number) { |
| | | return new BigDecimal(number) |
| | | .setScale(2, BigDecimal.ROUND_HALF_UP) |
| | | .doubleValue(); |
| | | } |
| | | /** |
| | | * 比较两个数字是否相同, |
| | | * @param number1 数值1 |
| | | * @param number2 数值2 |
| | | * @return 是否一致 |
| | | */ |
| | | public static boolean equals(Integer number1, Integer number2) { |
| | | if(number1 == null || number2 == null){ |
| | | return false; |
| | | } |
| | | return number1.equals(number2); |
| | | } |
| | | |
| | | /** |
| | | * 数字除法保留指定小数位 |
| | | * @param num1 被除数 |
| | | * @param num2 除数 |
| | | * @param scale 小数点位数 |
| | | * @return 结果 |
| | | */ |
| | | public static Double divToDouble(Integer num1, Integer num2, int scale){ |
| | | if(num2 == null || num2 ==0 || num1 == null || num1 == 0) { |
| | | return 0d; |
| | | } |
| | | return div(num1, num2, scale).doubleValue(); |
| | | } |
| | | |
| | | public static Double max(List<Double> data){ |
| | | if(CollUtils.isEmpty(data)){ |
| | | return null; |
| | | } |
| | | return data.stream() |
| | | .max(Comparator.comparingDouble(num -> num)) |
| | | .orElse(0d); |
| | | } |
| | | public static Double min(List<Double> data){ |
| | | if(CollUtils.isEmpty(data)){ |
| | | return null; |
| | | } |
| | | return data.stream() |
| | | .min(Comparator.comparingDouble(num -> num)) |
| | | .orElse(0d); |
| | | } |
| | | |
| | | public static Double average(List<Double> data){ |
| | | if(CollUtils.isEmpty(data)){ |
| | | return 0d; |
| | | } |
| | | return data.stream() |
| | | .collect(Collectors.averagingDouble(Double::doubleValue)); |
| | | |
| | | } |
| | | |
| | | public static Integer toInt(Object obj) { |
| | | return obj == null ? null |
| | | : obj instanceof Integer |
| | | ? (int) obj : null; |
| | | } |
| | | |
| | | /** |
| | | * 取绝对值,如果为null,返回0 |
| | | * @param number 数值 |
| | | * @return 绝对值 |
| | | */ |
| | | public static int abs(Integer number) { |
| | | return number == null |
| | | ? 0 |
| | | : Math.abs(number); |
| | | } |
| | | |
| | | /** |
| | | * 数字格式化字符串,不足位数补0 |
| | | * |
| | | * @param originNumber 原始数字 |
| | | * @param digit 数字位数 |
| | | * @return 字符串 |
| | | */ |
| | | public static String repair0(Integer originNumber, Integer digit){ |
| | | StringBuilder number = new StringBuilder(originNumber + ""); |
| | | while (number.length() < digit) { |
| | | number.insert(0, "0"); |
| | | } |
| | | return number.toString(); |
| | | } |
| | | |
| | | |
| | | public static String scaleToStr(Integer num, int offset) { |
| | | // 1.计算位数 |
| | | int m = (int) Math.pow(10, offset); |
| | | // 2.计算商 |
| | | int s = num / m; |
| | | // 3.计算余数 |
| | | int y = num % m; |
| | | if (y == 0) { |
| | | return Integer.toString(s); |
| | | } |
| | | // 2.计算余数 |
| | | return s + "." + y; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * Object操作工具 |
| | | **/ |
| | | public class ObjectUtils extends ObjectUtil { |
| | | |
| | | /** |
| | | * 为object设置默认值,对target中的基本类型进行默认值初始化, |
| | | * 为null的对象不操作 |
| | | * |
| | | * @param target 需要初始化的对象 |
| | | */ |
| | | public static void setDefault(Object target) { |
| | | if (target == null) { |
| | | return; |
| | | } |
| | | Class<?> clazz = target.getClass(); |
| | | Field[] declaredFields = clazz.getDeclaredFields(); |
| | | for (Field field : declaredFields) { |
| | | setDefault(field, target); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 给某个字段设置为默认值 |
| | | * |
| | | * @param field |
| | | * @param target |
| | | */ |
| | | private static void setDefault(Field field, Object target) { |
| | | field.setAccessible(true); |
| | | try { |
| | | Object value = field.get(target); |
| | | if (value != null) { |
| | | return; |
| | | } |
| | | String type = field.getGenericType().toString(); |
| | | Object defaultValue; |
| | | switch (type) { |
| | | case "class java.lang.String": |
| | | case "class java.lang.Character": |
| | | defaultValue = ""; |
| | | break; |
| | | case "class java.lang.Double": |
| | | defaultValue = 0.0d; |
| | | break; |
| | | case "class java.lang.Long": |
| | | defaultValue = 0L; |
| | | break; |
| | | case "class java.lang.Short": |
| | | defaultValue = (short) 0; |
| | | break; |
| | | case "class java.lang.Integer": |
| | | defaultValue = 0; |
| | | break; |
| | | case "class java.lang.Float": |
| | | defaultValue = 0f; |
| | | break; |
| | | case "class java.lang.Byte": |
| | | defaultValue = (byte) 0; |
| | | break; |
| | | case "class java.math.BigDecimal": |
| | | defaultValue = BigDecimal.ZERO; |
| | | break; |
| | | case "class java.lang.Boolean": |
| | | defaultValue = Boolean.FALSE; |
| | | break; |
| | | default: |
| | | defaultValue = null; |
| | | |
| | | } |
| | | field.set(target, defaultValue); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.util.List; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class PageDTO<T> { |
| | | protected Long total; |
| | | protected Long pages; |
| | | protected List<T> list; |
| | | |
| | | public static <T> PageDTO<T> empty(Long total, Long pages) { |
| | | return new PageDTO<>(total, pages, CollUtils.emptyList()); |
| | | } |
| | | public static <T> PageDTO<T> empty(Page<?> page) { |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), CollUtils.emptyList()); |
| | | } |
| | | |
| | | public static <T> PageDTO<T> of(Page<T> page) { |
| | | if(page == null){ |
| | | return new PageDTO<>(); |
| | | } |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return empty(page); |
| | | } |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), page.getRecords()); |
| | | } |
| | | public static <T,R> PageDTO<T> of(Page<R> page, Function<R, T> mapper) { |
| | | if(page == null){ |
| | | return new PageDTO<>(); |
| | | } |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return empty(page); |
| | | } |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), |
| | | page.getRecords().stream().map(mapper).collect(Collectors.toList())); |
| | | } |
| | | public static <T> PageDTO<T> of(Page<?> page, List<T> list) { |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), list); |
| | | } |
| | | |
| | | public static <T, R> PageDTO<T> of(Page<R> page, Class<T> clazz) { |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), BeanUtils.copyList(page.getRecords(), clazz)); |
| | | } |
| | | |
| | | public static <T, R> PageDTO<T> of(Page<R> page, Class<T> clazz, Convert<R, T> convert) { |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), BeanUtils.copyList(page.getRecords(), clazz, convert)); |
| | | } |
| | | |
| | | @JsonIgnore |
| | | public boolean isEmpty(){ |
| | | return list == null || list.size() == 0; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.gateway.config; |
| | | |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import com.alibaba.nacos.client.naming.event.InstancesChangeEvent; |
| | | import com.alibaba.nacos.common.notify.Event; |
| | | import com.alibaba.nacos.common.notify.NotifyCenter; |
| | | import com.alibaba.nacos.common.notify.listener.Subscriber; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import org.springdoc.core.AbstractSwaggerUiConfigProperties; |
| | | import org.springdoc.core.SwaggerUiConfigProperties; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.cloud.client.discovery.DiscoveryClient; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import com.alibaba.nacos.client.naming.event.InstancesChangeEvent; |
| | | import com.alibaba.nacos.common.notify.Event; |
| | | import com.alibaba.nacos.common.notify.NotifyCenter; |
| | | import com.alibaba.nacos.common.notify.listener.Subscriber; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * SpringDoc配置类 |
| | |
| | | @Autowired |
| | | private DiscoveryClient discoveryClient; |
| | | |
| | | private final static String[] EXCLUDE_ROUTES = new String[] { "ruoyi-gateway", "ruoyi-auth", "ruoyi-file", "ruoyi-monitor" }; |
| | | private final static String[] EXCLUDE_ROUTES = new String[] { "ruoyi-gateway", /*"ruoyi-auth",*/ "ruoyi-file", "ruoyi-monitor" }; |
| | | |
| | | public SwaggerDocRegister(SwaggerUiConfigProperties swaggerUiConfigProperties, DiscoveryClient discoveryClient) |
| | | { |
File was renamed from ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/UserController.java |
| | |
| | | package com.ruoyi.company.controller; |
| | | package com.ruoyi.company.controller.front; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.annotation.InnerAuth; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.company.api.domain.User; |
| | | import com.ruoyi.company.api.model.RegisterUser; |
| | | import com.ruoyi.company.api.model.UserDetail; |
| | | import com.ruoyi.company.service.UserService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @RestController |
| | | @RequestMapping("/user") |
| | | @RequestMapping("/front/user") |
| | | @RequiredArgsConstructor |
| | | public class UserController { |
| | | private final UserService userService; |
New file |
| | |
| | | package com.ruoyi.company.controller.management; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.page.PageDTO; |
| | | import com.ruoyi.company.api.domain.query.MgtCompanyQuery; |
| | | import com.ruoyi.company.api.domain.vo.MgtCompanyVO; |
| | | import com.ruoyi.company.service.CompanyService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2025/1/20 |
| | | */ |
| | | @Validated |
| | | @RestController |
| | | @RequestMapping("/mgt/company") |
| | | @Tag(name = "管理端企业列表相关接口") |
| | | @RequiredArgsConstructor |
| | | public class MgtCompanyController { |
| | | private final CompanyService companyService; |
| | | |
| | | @Operation(summary = "获取企业列表") |
| | | @PostMapping("/page") |
| | | public R<PageDTO<MgtCompanyVO>> queryPage(MgtCompanyQuery query) { |
| | | return R.ok(companyService.queryPage(query)); |
| | | } |
| | | @Operation(summary = "获取企业详情") |
| | | @GetMapping("/{id}") |
| | | public R<MgtCompanyVO> queryCompanyDetail(@Parameter(name = "id",description = "企业id",required = true) @PathVariable Long id) { |
| | | return R.ok(companyService.queryCompanyDetail(id)); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.company.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.PageDTO; |
| | | import com.ruoyi.company.api.domain.Company; |
| | | import com.ruoyi.company.api.domain.query.MgtCompanyQuery; |
| | | import com.ruoyi.company.api.domain.vo.MgtCompanyVO; |
| | | |
| | | public interface CompanyService extends IService<Company> { |
| | | /** |
| | | * 获取企业列表 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | PageDTO<MgtCompanyVO> queryPage(MgtCompanyQuery query); |
| | | |
| | | /** |
| | | * 获取企业详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | MgtCompanyVO queryCompanyDetail(Long id); |
| | | } |
| | |
| | | package com.ruoyi.company.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.page.BeanUtils; |
| | | import com.ruoyi.common.core.page.PageDTO; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.company.api.domain.Company; |
| | | import com.ruoyi.company.api.domain.User; |
| | | import com.ruoyi.company.api.domain.query.MgtCompanyQuery; |
| | | import com.ruoyi.company.api.domain.vo.MgtCompanyVO; |
| | | import com.ruoyi.company.mapper.CompanyMapper; |
| | | import com.ruoyi.company.service.CompanyService; |
| | | import com.ruoyi.company.service.UserService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements CompanyService { |
| | | private final UserService userService; |
| | | /** |
| | | * 获取企业列表 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtCompanyVO> queryPage(MgtCompanyQuery query) { |
| | | Page<Company> page = this.lambdaQuery() |
| | | .like(StringUtils.isNotBlank(query.getCompanyInfo()), Company::getCompanyName, query.getCompanyInfo()) |
| | | .like(StringUtils.isNotBlank(query.getCompanyInfo()), Company::getSocialCode, query.getCompanyInfo()) |
| | | .like(StringUtils.isNotBlank(query.getLegalPersonInfo()), Company::getLegalPersonName, query.getLegalPersonInfo()) |
| | | .like(StringUtils.isNotBlank(query.getLegalPersonInfo()), Company::getIdCardNumber, query.getLegalPersonInfo()) |
| | | .like(StringUtils.isNotBlank(query.getContactInfo()), Company::getContactName, query.getContactInfo()) |
| | | .like(StringUtils.isNotBlank(query.getContactInfo()), Company::getContactPhone, query.getContactInfo()) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | return PageDTO.of(page,MgtCompanyVO.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取企业详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MgtCompanyVO queryCompanyDetail(Long id) { |
| | | Company company = this.getById(id); |
| | | MgtCompanyVO mgtCompanyVO = BeanUtils.copyBean(company, MgtCompanyVO.class); |
| | | if (Objects.isNull(mgtCompanyVO)) { |
| | | mgtCompanyVO = new MgtCompanyVO(); |
| | | return mgtCompanyVO; |
| | | } |
| | | User user = userService.getById(company.getUserId()); |
| | | if (Objects.nonNull(user)) { |
| | | mgtCompanyVO.setPhone(user.getPhone()); |
| | | mgtCompanyVO.setAccountName(user.getAccountName()); |
| | | } |
| | | return mgtCompanyVO; |
| | | } |
| | | } |