Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
641be5524e
|
@ -2,16 +2,17 @@ package com.ruoyi.business.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AddTreeSelect;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.TreeSelect;
|
import com.ruoyi.common.core.domain.TreeSelect;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.database.domain.BaseAddressInfo;
|
||||||
import com.ruoyi.database.domain.BusinessTripApproval;
|
import com.ruoyi.database.domain.BusinessTripApproval;
|
||||||
import com.ruoyi.database.domain.PoliceLeaveApproval;
|
import com.ruoyi.database.service.BaseAddressInfoService;
|
||||||
import com.ruoyi.database.service.BusinessTripApprovalService;
|
import com.ruoyi.database.service.BusinessTripApprovalService;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
import com.ruoyi.system.service.ISysDictDataService;
|
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
@ -21,9 +22,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description BusinessTripApprovalController
|
* @Description BusinessTripApprovalController
|
||||||
|
@ -40,7 +40,7 @@ public class BusinessTripApprovalController extends BaseController {
|
||||||
private final BusinessTripApprovalService businessTripApprovalService;
|
private final BusinessTripApprovalService businessTripApprovalService;
|
||||||
private final ISysUserService sysUserService;
|
private final ISysUserService sysUserService;
|
||||||
private final ISysDeptService sysDeptService;
|
private final ISysDeptService sysDeptService;
|
||||||
private final ISysDictDataService dictDataService;
|
private final BaseAddressInfoService baseAddressInfoService;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
|
@ -139,9 +139,34 @@ public class BusinessTripApprovalController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/addressList")
|
||||||
|
@ApiOperation("查询地址信息列表")
|
||||||
|
public AjaxResult addressList() {
|
||||||
|
List<BaseAddressInfo> allAddresses = baseAddressInfoService.list();
|
||||||
|
Map<Long, List<BaseAddressInfo>> addressMap = allAddresses.stream()
|
||||||
|
.collect(Collectors.groupingBy(BaseAddressInfo::getTopId));
|
||||||
|
List<AddTreeSelect> tree = buildTree(addressMap, 0L);
|
||||||
|
return AjaxResult.success(tree);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AddTreeSelect> buildTree(
|
||||||
|
Map<Long, List<BaseAddressInfo>> addressMap,
|
||||||
|
Long parentId
|
||||||
|
) {
|
||||||
|
List<BaseAddressInfo> children = addressMap.get(parentId);
|
||||||
|
if (children == null) return Collections.emptyList();
|
||||||
|
|
||||||
|
return children.stream()
|
||||||
|
.map(info -> {
|
||||||
|
AddTreeSelect node = new AddTreeSelect();
|
||||||
|
node.setId(info.getId());
|
||||||
|
node.setLabel(info.getAddName());
|
||||||
|
node.setValue(info.getId().toString());
|
||||||
|
node.setChildren(buildTree(addressMap, info.getId()));
|
||||||
|
return node;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.ruoyi.database.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntityMini;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName(value = "base_address_info")
|
||||||
|
@ApiModel(value = "BaseAddressInfo", description = "地址信息表")
|
||||||
|
public class BaseAddressInfo extends BaseEntityMini {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("主键")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("地址编码")
|
||||||
|
private String addCode;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("地址名称")
|
||||||
|
private String addName;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("上级id")
|
||||||
|
private Long topId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.ruoyi.database.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.database.domain.BaseAddressInfo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BaseAddressInfoMapper extends BaseMapper<BaseAddressInfo> {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.ruoyi.database.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.database.domain.BaseAddressInfo;
|
||||||
|
|
||||||
|
public interface BaseAddressInfoService extends IService<BaseAddressInfo> {
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.ruoyi.database.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.database.domain.BaseAddressInfo;
|
||||||
|
import com.ruoyi.database.mapper.BaseAddressInfoMapper;
|
||||||
|
import com.ruoyi.database.service.BaseAddressInfoService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BaseAddressInfoServiceImpl extends ServiceImpl<BaseAddressInfoMapper, BaseAddressInfo> implements BaseAddressInfoService {
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Treeselect树结构实体类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class AddTreeSelect implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子节点
|
||||||
|
*/
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
private List<AddTreeSelect> children;
|
||||||
|
|
||||||
|
public AddTreeSelect() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddTreeSelect(SysDept dept) {
|
||||||
|
this.id = dept.getDeptId();
|
||||||
|
this.label = dept.getDeptName();
|
||||||
|
this.children = dept.getChildren().stream().map(AddTreeSelect::new).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddTreeSelect(SysMenu menu) {
|
||||||
|
this.id = menu.getMenuId();
|
||||||
|
this.label = menu.getMenuName();
|
||||||
|
this.children = menu.getChildren().stream().map(AddTreeSelect::new).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AddTreeSelect> getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildren(List<AddTreeSelect> children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue