17 changed files with 721 additions and 38 deletions
@ -0,0 +1,38 @@ |
|||||
|
package com.zdxt.enforcementcode.controller.web.supervision; |
||||
|
|
||||
|
import cn.hutool.core.lang.tree.Tree; |
||||
|
import com.zdxt.enforcementcode.service.IDashboardAreaInfoService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.dromara.common.core.domain.R; |
||||
|
import org.dromara.common.web.core.BaseController; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 大屏-基础信息-行政区 |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2026-06-05 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/web/dashboard/areaInfo") |
||||
|
public class DashboardAreaInfoController extends BaseController { |
||||
|
|
||||
|
private final IDashboardAreaInfoService dashboardAreaInfoService; |
||||
|
|
||||
|
/** |
||||
|
* 查询大屏-基础信息-行政区列表 |
||||
|
* 树状结构 |
||||
|
*/ |
||||
|
@GetMapping("/getAreaInfo") |
||||
|
public R<List<Tree<String>>> getAreaInfo() { |
||||
|
List<Tree<String>> areaTree = dashboardAreaInfoService.buildAreaTree(); |
||||
|
return R.ok(areaTree); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,61 @@ |
|||||
|
package com.zdxt.enforcementcode.domain.bean; |
||||
|
|
||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
|
||||
|
/** |
||||
|
* 大屏-基础信息-行政区对象 dashboard_area_info |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2026-06-05 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("dashboard_area_info") |
||||
|
public class DashboardAreaInfo extends BaseEntity { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键ID(自增) |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 编码 |
||||
|
*/ |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 父级编码 |
||||
|
*/ |
||||
|
private String parentCode; |
||||
|
|
||||
|
/** |
||||
|
* 排序号,数字越小越靠前 |
||||
|
*/ |
||||
|
private Long sort; |
||||
|
|
||||
|
/** |
||||
|
* 级别 |
||||
|
*/ |
||||
|
private Long level; |
||||
|
|
||||
|
/** |
||||
|
* 逻辑删除:0-否 1-是 |
||||
|
*/ |
||||
|
private String isDelete; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,62 @@ |
|||||
|
package com.zdxt.enforcementcode.domain.bo; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.domain.bean.DashboardAreaInfo; |
||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
|
||||
|
/** |
||||
|
* 大屏-基础信息-行政区业务对象 dashboard_area_info |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2026-06-05 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@AutoMapper(target = DashboardAreaInfo.class, reverseConvertGenerate = false) |
||||
|
public class DashboardAreaInfoBo extends BaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* 主键ID(自增) |
||||
|
*/ |
||||
|
@NotNull(message = "主键ID(自增)不能为空", groups = { EditGroup.class }) |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 编码 |
||||
|
*/ |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 父级编码 |
||||
|
*/ |
||||
|
private String parentCode; |
||||
|
|
||||
|
/** |
||||
|
* 排序号,数字越小越靠前 |
||||
|
*/ |
||||
|
@NotNull(message = "排序号,数字越小越靠前不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Long sort; |
||||
|
|
||||
|
/** |
||||
|
* 级别 |
||||
|
*/ |
||||
|
@NotNull(message = "级别不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Long level; |
||||
|
|
||||
|
/** |
||||
|
* 逻辑删除:0-否 1-是 |
||||
|
*/ |
||||
|
private String isDelete; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
package com.zdxt.enforcementcode.domain.bo; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.domain.bean.DashboardOverview; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import jakarta.validation.constraints.NotBlank; |
||||
|
import jakarta.validation.constraints.NotNull; |
||||
|
import lombok.Data; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 大屏总览业务对象 dashboard_overview |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2026-05-27 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GenerateDataBo implements Serializable { |
||||
|
|
||||
|
/** |
||||
|
* 类型:1-大屏总览数据 |
||||
|
*/ |
||||
|
private Integer type; |
||||
|
|
||||
|
/** |
||||
|
* 年份 |
||||
|
*/ |
||||
|
private Integer year; |
||||
|
|
||||
|
/** |
||||
|
* 月份 |
||||
|
*/ |
||||
|
private Integer month; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,73 @@ |
|||||
|
package com.zdxt.enforcementcode.domain.vo; |
||||
|
|
||||
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import cn.idev.excel.annotation.ExcelProperty; |
||||
|
import com.zdxt.enforcementcode.domain.bean.DashboardAreaInfo; |
||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat; |
||||
|
import org.dromara.common.excel.convert.ExcelDictConvert; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 大屏-基础信息-行政区视图对象 dashboard_area_info |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2026-06-05 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
@AutoMapper(target = DashboardAreaInfo.class) |
||||
|
public class DashboardAreaInfoVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键ID(自增) |
||||
|
*/ |
||||
|
@ExcelProperty(value = "主键ID", converter = ExcelDictConvert.class) |
||||
|
@ExcelDictFormat(readConverterExp = "自=增") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 编码 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "编码") |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 名称 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "名称") |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 父级编码 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "父级编码") |
||||
|
private String parentCode; |
||||
|
|
||||
|
/** |
||||
|
* 排序号,数字越小越靠前 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "排序号,数字越小越靠前") |
||||
|
private Long sort; |
||||
|
|
||||
|
/** |
||||
|
* 级别 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "级别") |
||||
|
private Long level; |
||||
|
|
||||
|
/** |
||||
|
* 逻辑删除:0-否 1-是 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "逻辑删除:0-否 1-是") |
||||
|
private String isDelete; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package com.zdxt.enforcementcode.mapper; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.domain.bean.DashboardAreaInfo; |
||||
|
import com.zdxt.enforcementcode.domain.vo.DashboardAreaInfoVo; |
||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
||||
|
|
||||
|
/** |
||||
|
* 大屏-基础信息-行政区Mapper接口 |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2026-06-05 |
||||
|
*/ |
||||
|
public interface DashboardAreaInfoMapper extends BaseMapperPlus<DashboardAreaInfo, DashboardAreaInfoVo> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,71 @@ |
|||||
|
package com.zdxt.enforcementcode.service; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.domain.vo.DashboardAreaInfoVo; |
||||
|
import com.zdxt.enforcementcode.domain.bo.DashboardAreaInfoBo; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import cn.hutool.core.lang.tree.Tree; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 大屏-基础信息-行政区Service接口 |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2026-06-05 |
||||
|
*/ |
||||
|
public interface IDashboardAreaInfoService { |
||||
|
|
||||
|
/** |
||||
|
* 查询大屏-基础信息-行政区 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 大屏-基础信息-行政区 |
||||
|
*/ |
||||
|
DashboardAreaInfoVo queryById(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 分页查询大屏-基础信息-行政区列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 大屏-基础信息-行政区分页列表 |
||||
|
*/ |
||||
|
TableDataInfo<DashboardAreaInfoVo> queryPageList(DashboardAreaInfoBo bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的大屏-基础信息-行政区列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 大屏-基础信息-行政区列表 |
||||
|
*/ |
||||
|
List<DashboardAreaInfoVo> queryList(DashboardAreaInfoBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 新增大屏-基础信息-行政区 |
||||
|
* |
||||
|
* @param bo 大屏-基础信息-行政区 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
Boolean insertByBo(DashboardAreaInfoBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 修改大屏-基础信息-行政区 |
||||
|
* |
||||
|
* @param bo 大屏-基础信息-行政区 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
Boolean updateByBo(DashboardAreaInfoBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除大屏-基础信息-行政区信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
||||
|
|
||||
|
List<Tree<String>> buildAreaTree(); |
||||
|
} |
||||
@ -0,0 +1,113 @@ |
|||||
|
package com.zdxt.enforcementcode.service.impl; |
||||
|
|
||||
|
import com.zdxt.enforcementcode.domain.bean.DashboardAreaInfo; |
||||
|
import org.dromara.common.core.utils.MapstructUtils; |
||||
|
import org.dromara.common.core.utils.StringUtils; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.zdxt.enforcementcode.domain.bo.DashboardAreaInfoBo; |
||||
|
import com.zdxt.enforcementcode.domain.vo.DashboardAreaInfoVo; |
||||
|
import com.zdxt.enforcementcode.mapper.DashboardAreaInfoMapper; |
||||
|
import com.zdxt.enforcementcode.service.IDashboardAreaInfoService; |
||||
|
import cn.hutool.core.lang.tree.Tree; |
||||
|
import org.dromara.common.core.utils.TreeBuildUtils; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Collection; |
||||
|
|
||||
|
@Slf4j |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class DashboardAreaInfoServiceImpl implements IDashboardAreaInfoService { |
||||
|
|
||||
|
private final DashboardAreaInfoMapper baseMapper; |
||||
|
|
||||
|
@Override |
||||
|
public DashboardAreaInfoVo queryById(Long id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public TableDataInfo<DashboardAreaInfoVo> queryPageList(DashboardAreaInfoBo bo, PageQuery pageQuery) { |
||||
|
LambdaQueryWrapper<DashboardAreaInfo> lqw = buildQueryWrapper(bo); |
||||
|
Page<DashboardAreaInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
||||
|
return TableDataInfo.build(result); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<DashboardAreaInfoVo> queryList(DashboardAreaInfoBo bo) { |
||||
|
LambdaQueryWrapper<DashboardAreaInfo> lqw = buildQueryWrapper(bo); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<DashboardAreaInfo> buildQueryWrapper(DashboardAreaInfoBo bo) { |
||||
|
Map<String, Object> params = bo.getParams(); |
||||
|
LambdaQueryWrapper<DashboardAreaInfo> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.orderByAsc(DashboardAreaInfo::getSort); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getCode()), DashboardAreaInfo::getCode, bo.getCode()); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getName()), DashboardAreaInfo::getName, bo.getName()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getParentCode()), DashboardAreaInfo::getParentCode, bo.getParentCode()); |
||||
|
lqw.eq(bo.getSort() != null, DashboardAreaInfo::getSort, bo.getSort()); |
||||
|
lqw.eq(bo.getLevel() != null, DashboardAreaInfo::getLevel, bo.getLevel()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getIsDelete()), DashboardAreaInfo::getIsDelete, bo.getIsDelete()); |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Boolean insertByBo(DashboardAreaInfoBo bo) { |
||||
|
DashboardAreaInfo add = MapstructUtils.convert(bo, DashboardAreaInfo.class); |
||||
|
validEntityBeforeSave(add); |
||||
|
boolean flag = baseMapper.insert(add) > 0; |
||||
|
if (flag) { |
||||
|
bo.setId(add.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Boolean updateByBo(DashboardAreaInfoBo bo) { |
||||
|
DashboardAreaInfo update = MapstructUtils.convert(bo, DashboardAreaInfo.class); |
||||
|
validEntityBeforeSave(update); |
||||
|
return baseMapper.updateById(update) > 0; |
||||
|
} |
||||
|
|
||||
|
private void validEntityBeforeSave(DashboardAreaInfo entity){ |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
||||
|
if(isValid){ |
||||
|
} |
||||
|
return baseMapper.deleteByIds(ids) > 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Tree<String>> buildAreaTree() { |
||||
|
DashboardAreaInfoBo bo = new DashboardAreaInfoBo(); |
||||
|
bo.setIsDelete("0"); |
||||
|
List<DashboardAreaInfoVo> areaList = queryList(bo); |
||||
|
|
||||
|
if (areaList == null || areaList.isEmpty()) { |
||||
|
return List.of(); |
||||
|
} |
||||
|
|
||||
|
return TreeBuildUtils.buildMultiRoot( |
||||
|
areaList, |
||||
|
DashboardAreaInfoVo::getCode, |
||||
|
DashboardAreaInfoVo::getParentCode, |
||||
|
(node, tree) -> tree |
||||
|
.setId(node.getCode()) |
||||
|
.setParentId(node.getParentCode()) |
||||
|
.setName(node.getName()) |
||||
|
.setWeight(node.getSort() != null ? node.getSort().intValue() : 0) |
||||
|
.putExtra("level", node.getLevel()) |
||||
|
); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue