diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/DiyCity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/DiyCity.java index cd364a2..f08a635 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/DiyCity.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/DiyCity.java @@ -1,6 +1,7 @@ package com.ruoyi.system.domain; import java.util.Date; +import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -60,6 +61,8 @@ public class DiyCity extends BaseEntity @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private Date updatedAt; + private List children; + public void setId(Integer id) { this.id = id; @@ -170,6 +173,14 @@ public class DiyCity extends BaseEntity return updatedAt; } + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DiyCityServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DiyCityServiceImpl.java index a728a85..38b01a2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DiyCityServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DiyCityServiceImpl.java @@ -1,6 +1,9 @@ package com.ruoyi.system.service.impl; import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.ArrayList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.DiyCityMapper; @@ -40,7 +43,31 @@ public class DiyCityServiceImpl implements IDiyCityService @Override public List selectDiyCityList(DiyCity diyCity) { - return diyCityMapper.selectDiyCityList(diyCity); + List cities = diyCityMapper.selectDiyCityList(diyCity); + return buildTree(cities); + } + + private List buildTree(List cities) { + Map map = new HashMap<>(); + List roots = new ArrayList<>(); + + for (DiyCity city : cities) { + map.put(city.getId(), city); + city.setChildren(new ArrayList<>()); + } + + for (DiyCity city : cities) { + if (city.getParentId() == null) { + roots.add(city); + } else { + DiyCity parent = map.get(city.getParentId()); + if (parent != null) { + parent.getChildren().add(city); + } + } + } + + return roots; } /** diff --git a/ruoyi-system/src/main/resources/mapper/system/ContentMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ContentMapper.xml index caacb45..cd1a586 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ContentMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ContentMapper.xml @@ -46,9 +46,10 @@ link, sort, status, - created_at, - updated_at, deleted_at, + created_at, + updated_at + #{type}, @@ -58,9 +59,10 @@ #{link}, #{sort}, #{status}, - #{createdAt}, - #{updatedAt}, #{deletedAt}, + NOW(), + NOW() + diff --git a/ruoyi-system/src/main/resources/mapper/system/CooperateMapper.xml b/ruoyi-system/src/main/resources/mapper/system/CooperateMapper.xml index c1b9539..c0470d7 100644 --- a/ruoyi-system/src/main/resources/mapper/system/CooperateMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/CooperateMapper.xml @@ -51,8 +51,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" address, info, status, - created_at, - updated_at, + created_at, + updated_at #{uid}, @@ -62,8 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{address}, #{info}, #{status}, - #{createdAt}, - #{updatedAt}, + NOW(), + NOW() @@ -77,8 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" address = #{address}, info = #{info}, status = #{status}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, + updated_at=NOW() where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/CouponsMapper.xml b/ruoyi-system/src/main/resources/mapper/system/CouponsMapper.xml index f491b11..0ed63a1 100644 --- a/ruoyi-system/src/main/resources/mapper/system/CouponsMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/CouponsMapper.xml @@ -104,9 +104,10 @@ sort, cate_id, user_ids, - created_at, - updated_at, deleted_at, + created_at, + updated_at + #{title}, @@ -124,9 +125,10 @@ #{sort}, #{cateId}, #{userIds}, - #{createdAt}, - #{updatedAt}, #{deletedAt}, + NOW(), + NOW() + @@ -148,9 +150,9 @@ sort = #{sort}, cate_id = #{cateId}, user_ids = #{userIds}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, deleted_at = #{deletedAt}, + updated_at=NOW() + where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/DiyCityMapper.xml b/ruoyi-system/src/main/resources/mapper/system/DiyCityMapper.xml index f3565c8..9aa147d 100644 --- a/ruoyi-system/src/main/resources/mapper/system/DiyCityMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/DiyCityMapper.xml @@ -54,8 +54,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" province_id, city_id, district_id, - created_at, - updated_at, + created_at, + updated_at #{title}, @@ -66,8 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{provinceId}, #{cityId}, #{districtId}, - #{createdAt}, - #{updatedAt}, + NOW(), + NOW() @@ -82,8 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" province_id = #{provinceId}, city_id = #{cityId}, district_id = #{districtId}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, + updated_at=NOW() where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/GoodsCartMapper.xml b/ruoyi-system/src/main/resources/mapper/system/GoodsCartMapper.xml index da41c7b..00afb93 100644 --- a/ruoyi-system/src/main/resources/mapper/system/GoodsCartMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/GoodsCartMapper.xml @@ -42,16 +42,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" good_id, good_num, sku, - created_at, - updated_at, + created_at, + updated_at #{uid}, #{goodId}, #{goodNum}, #{sku}, - #{createdAt}, - #{updatedAt}, + NOW(), + NOW() @@ -62,8 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" good_id = #{goodId}, good_num = #{goodNum}, sku = #{sku}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, + updated_at=NOW() where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/GoodsOrderCursorMapper.xml b/ruoyi-system/src/main/resources/mapper/system/GoodsOrderCursorMapper.xml index 2e361c0..aad4d9b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/GoodsOrderCursorMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/GoodsOrderCursorMapper.xml @@ -48,8 +48,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sku, total_price, postage, - created_at, - updated_at, + created_at, + updated_at #{productId}, @@ -58,9 +58,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{sku}, #{totalPrice}, #{postage}, - #{createdAt}, - #{updatedAt}, - + NOW(), + NOW() + + @@ -72,8 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sku = #{sku}, total_price = #{totalPrice}, postage = #{postage}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, + updated_at=NOW() where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml index 66aff8c..09f7540 100644 --- a/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml @@ -91,8 +91,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mark, address_id, sku, - created_at, - updated_at, + created_at, + updated_at deleted_at, @@ -120,9 +120,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{mark}, #{addressId}, #{sku}, - #{createdAt}, - #{updatedAt}, - #{deletedAt}, + #{deletedAt}, + NOW(), + NOW() + @@ -153,9 +154,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mark = #{mark}, address_id = #{addressId}, sku = #{sku}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, - deleted_at = #{deletedAt}, + deleted_at = #{deletedAt}, + updated_at=NOW() + where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/IntegralCateMapper.xml b/ruoyi-system/src/main/resources/mapper/system/IntegralCateMapper.xml index 09d05c4..684b8ee 100644 --- a/ruoyi-system/src/main/resources/mapper/system/IntegralCateMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/IntegralCateMapper.xml @@ -39,15 +39,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" title, sort, status, - created_at, - updated_at, + created_at, + updated_at #{title}, #{sort}, #{status}, - #{createdAt}, - #{updatedAt}, + NOW(), + NOW() @@ -57,8 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" title = #{title}, sort = #{sort}, status = #{status}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, + updated_at=NOW() where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/IntegralLogMapper.xml b/ruoyi-system/src/main/resources/mapper/system/IntegralLogMapper.xml index 3287d1f..a201194 100644 --- a/ruoyi-system/src/main/resources/mapper/system/IntegralLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/IntegralLogMapper.xml @@ -48,8 +48,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" uid, type, num, - created_at, - updated_at, + created_at, + updated_at #{orderId}, @@ -58,8 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{uid}, #{type}, #{num}, - #{createdAt}, - #{updatedAt}, + NOW(), + NOW() @@ -72,8 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" uid = #{uid}, type = #{type}, num = #{num}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, + updated_at=NOW() where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/IntegralOrderLogMapper.xml b/ruoyi-system/src/main/resources/mapper/system/IntegralOrderLogMapper.xml index 757118a..6e068d0 100644 --- a/ruoyi-system/src/main/resources/mapper/system/IntegralOrderLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/IntegralOrderLogMapper.xml @@ -45,8 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" title, content, type, - created_at, - updated_at, + created_at, + updated_at #{oid}, @@ -54,8 +54,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{title}, #{content}, #{type}, - #{createdAt}, - #{updatedAt}, + NOW(), + NOW() @@ -67,8 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" title = #{title}, content = #{content}, type = #{type}, - created_at = #{createdAt}, - updated_at = #{updatedAt}, + updated_at=NOW() where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/SiteSkillMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SiteSkillMapper.xml index c5afe3a..007cb89 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SiteSkillMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SiteSkillMapper.xml @@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"