feat: 1.RegionData2023.sql 增加四级区域默认sql
2.增加基础区域档案 3.增加基础地址档案
This commit is contained in:
parent
b409866314
commit
1463f6022b
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.wansenai.api.shop;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>商店档案</p>
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("shop")
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
public class ShopController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.wansenai.api.support;
|
||||||
|
|
||||||
|
import com.wansenai.dto.support.BasAddressDto;
|
||||||
|
import com.wansenai.service.support.BasAddressService;
|
||||||
|
import com.wansenai.utils.response.Response;
|
||||||
|
import com.wansenai.vo.support.BasAddressVo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>地址档案</p>
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("basAddress")
|
||||||
|
@Tag(name = "地址档案", description = "地址档案")
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
public class BasAddressController {
|
||||||
|
|
||||||
|
private final BasAddressService basAddressService;
|
||||||
|
|
||||||
|
@PostMapping("addOrUpdate")
|
||||||
|
@Operation(summary = "新增or更新地址", description = "新增or更新地址")
|
||||||
|
public Response<String> getList(@RequestBody BasAddressDto basAddressDto) {
|
||||||
|
basAddressService.addOrUpdate(basAddressDto);
|
||||||
|
return Response.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("getDetail")
|
||||||
|
@Operation(summary = "详情查询", description = "详情查询")
|
||||||
|
public Response<BasAddressVo> getDetail(@RequestParam(value = "id") Long id){
|
||||||
|
return Response.responseData(basAddressService.getDetail(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.wansenai.api.support;
|
||||||
|
|
||||||
|
import com.wansenai.dto.support.BasAreaDto;
|
||||||
|
import com.wansenai.service.support.BasAreaService;
|
||||||
|
import com.wansenai.utils.response.Response;
|
||||||
|
import com.wansenai.vo.support.BasAreaVo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>区域档案</p>
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("basArea")
|
||||||
|
@Tag(name = "区域档案", description = "系统内置四级区域档案")
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
public class BasAreaController {
|
||||||
|
|
||||||
|
private final BasAreaService basAreaService;
|
||||||
|
|
||||||
|
@PostMapping("getList")
|
||||||
|
@Operation(summary = "区域查询", description = "区域查询")
|
||||||
|
public Response<List<BasAreaVo>> getList(@RequestBody BasAreaDto basAreaDto) {
|
||||||
|
return Response.responseData(basAreaService.getList(basAreaDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("getDetail")
|
||||||
|
@Operation(summary = "详情查询", description = "详情查询")
|
||||||
|
public Response<BasAreaVo> getDetail(@RequestParam(value = "id") Long id){
|
||||||
|
return Response.responseData(basAreaService.getDetail(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -60,3 +60,6 @@ springdoc:
|
||||||
- group: '会员模块'
|
- group: '会员模块'
|
||||||
paths-to-match: '/**'
|
paths-to-match: '/**'
|
||||||
packages-to-scan: com.wansenai.api.basic
|
packages-to-scan: com.wansenai.api.basic
|
||||||
|
- group: '档案模块'
|
||||||
|
paths-to-match: '/**'
|
||||||
|
packages-to-scan: com.wansenai.api.support
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.wansenai.mappers.support;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.wansenai.entities.support.BasAddress;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BasAddressMapper extends BaseMapper<BasAddress> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.wansenai.mappers.support;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.wansenai.entities.support.BasArea;
|
||||||
|
|
||||||
|
public interface BasAreaMapper extends BaseMapper<BasArea> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.wansenai.mappers.support.BasAddressMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.wansenai.mappers.support.BasAreaMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.wansenai.dto.support;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BasAddressDto {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long CountryId;
|
||||||
|
|
||||||
|
private Long provinceId;
|
||||||
|
|
||||||
|
private Long cityId;
|
||||||
|
|
||||||
|
private Long regionId;
|
||||||
|
|
||||||
|
private String detail;
|
||||||
|
|
||||||
|
private String fullAddress;
|
||||||
|
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
|
private String contactPhone;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.wansenai.dto.support;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BasAreaDto {
|
||||||
|
|
||||||
|
@Schema(description = "主键")
|
||||||
|
private Long id;
|
||||||
|
@Schema(description = "名称")
|
||||||
|
private String name;
|
||||||
|
@Schema(description = "父级ID")
|
||||||
|
private Long parentId;
|
||||||
|
@Schema(description = "层级类型")
|
||||||
|
private String regionType;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.wansenai.entities.shop;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("bas_shop")
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BasShop implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String channel;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private Long addressId;
|
||||||
|
|
||||||
|
private String priceType;
|
||||||
|
|
||||||
|
@TableField(value = "field_1")
|
||||||
|
private String field1;
|
||||||
|
|
||||||
|
@TableField(value = "field_2")
|
||||||
|
private String field2;
|
||||||
|
|
||||||
|
@TableField(value = "field_3")
|
||||||
|
private String field3;
|
||||||
|
|
||||||
|
@TableField(value = "field_4")
|
||||||
|
private String field4;
|
||||||
|
|
||||||
|
@TableField(value = "field_5")
|
||||||
|
private String field5;
|
||||||
|
|
||||||
|
@TableField(value = "field_6")
|
||||||
|
private String field6;
|
||||||
|
|
||||||
|
@TableField(value = "field_7")
|
||||||
|
private String field7;
|
||||||
|
|
||||||
|
@TableField(value = "field_8")
|
||||||
|
private String field8;
|
||||||
|
|
||||||
|
@TableField(value = "field_9")
|
||||||
|
private String field9;
|
||||||
|
|
||||||
|
@TableField(value = "field_10")
|
||||||
|
private String field10;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.wansenai.entities.support;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("bas_address")
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BasAddress implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long CountryId;
|
||||||
|
|
||||||
|
private Long provinceId;
|
||||||
|
|
||||||
|
private Long cityId;
|
||||||
|
|
||||||
|
private Long regionId;
|
||||||
|
|
||||||
|
private String detail;
|
||||||
|
|
||||||
|
private String fullAddress;
|
||||||
|
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
|
private String contactPhone;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.wansenai.entities.support;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("bas_area")
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BasArea implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String statisCode;
|
||||||
|
|
||||||
|
private String fullName;
|
||||||
|
|
||||||
|
private String regionType;
|
||||||
|
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
private String isDel;
|
||||||
|
|
||||||
|
private String lat;
|
||||||
|
|
||||||
|
private String lng;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.wansenai.vo.support;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BasAddressVo {
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long CountryId;
|
||||||
|
|
||||||
|
private BasAreaVo country;
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long provinceId;
|
||||||
|
|
||||||
|
private BasAreaVo province;
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long cityId;
|
||||||
|
|
||||||
|
private BasAreaVo city;
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long regionId;
|
||||||
|
|
||||||
|
private BasAreaVo region;
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private String detail;
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private String fullAddress;
|
||||||
|
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
|
private String contactPhone;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.wansenai.vo.support;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BasAreaVo {
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "国际编码")
|
||||||
|
private String statisCode;
|
||||||
|
|
||||||
|
@Schema(description = "全称")
|
||||||
|
private String fullName;
|
||||||
|
|
||||||
|
@Schema(description = "层级")
|
||||||
|
private String regionType;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private String lat;
|
||||||
|
@Schema(description = "维度")
|
||||||
|
private String lng;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.wansenai.service.support;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.wansenai.dto.support.BasAddressDto;
|
||||||
|
import com.wansenai.entities.support.BasAddress;
|
||||||
|
import com.wansenai.vo.support.BasAddressVo;
|
||||||
|
|
||||||
|
public interface BasAddressService extends IService<BasAddress> {
|
||||||
|
|
||||||
|
void addOrUpdate(BasAddressDto basAddressDto);
|
||||||
|
|
||||||
|
BasAddressVo getDetail(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.wansenai.service.support;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.wansenai.dto.support.BasAreaDto;
|
||||||
|
import com.wansenai.entities.support.BasArea;
|
||||||
|
import com.wansenai.vo.support.BasAreaVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface BasAreaService extends IService<BasArea> {
|
||||||
|
|
||||||
|
|
||||||
|
List<BasAreaVo> getList(BasAreaDto basAreaDto);
|
||||||
|
|
||||||
|
BasAreaVo getDetail(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.wansenai.service.support.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.wansenai.dto.support.BasAddressDto;
|
||||||
|
import com.wansenai.entities.support.BasAddress;
|
||||||
|
import com.wansenai.mappers.support.BasAddressMapper;
|
||||||
|
import com.wansenai.service.support.BasAddressService;
|
||||||
|
import com.wansenai.service.support.BasAreaService;
|
||||||
|
import com.wansenai.service.user.ISysUserService;
|
||||||
|
import com.wansenai.utils.SnowflakeIdUtil;
|
||||||
|
import com.wansenai.vo.support.BasAddressVo;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
public class BasAddressServiceImpl extends ServiceImpl<BasAddressMapper, BasAddress> implements BasAddressService {
|
||||||
|
|
||||||
|
private final BasAreaService basAreaService;
|
||||||
|
private final ISysUserService sysUserService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOrUpdate(BasAddressDto basAddressDto) {
|
||||||
|
if(basAddressDto.getId() != null){
|
||||||
|
BasAddress address = this.getById(basAddressDto.getId());
|
||||||
|
BeanUtils.copyProperties(basAddressDto, address);
|
||||||
|
address.setUpdateBy(sysUserService.getCurrentUserName());
|
||||||
|
address.setUpdateTime(null);
|
||||||
|
this.updateById(address);
|
||||||
|
}else {
|
||||||
|
var address = new BasAddress();
|
||||||
|
BeanUtils.copyProperties(basAddressDto, address);
|
||||||
|
address.setId(SnowflakeIdUtil.nextId());
|
||||||
|
address.setCreateBy(sysUserService.getCurrentUserName());
|
||||||
|
this.save(address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasAddressVo getDetail(Long id) {
|
||||||
|
var result = new BasAddressVo();
|
||||||
|
BasAddress address = this.getById(id);
|
||||||
|
if(address == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
BeanUtils.copyProperties(address, result);
|
||||||
|
if(result.getCountryId() != null){
|
||||||
|
result.setCountry(basAreaService.getDetail(result.getCountryId()));
|
||||||
|
}
|
||||||
|
if(result.getProvinceId() != null){
|
||||||
|
result.setProvince(basAreaService.getDetail(result.getProvinceId()));
|
||||||
|
}
|
||||||
|
if(result.getCityId() != null){
|
||||||
|
result.setCity(basAreaService.getDetail(result.getCityId()));
|
||||||
|
}
|
||||||
|
if(result.getRegionId() != null){
|
||||||
|
result.setRegion(basAreaService.getDetail(result.getRegionId()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.wansenai.service.support.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.wansenai.dto.support.BasAreaDto;
|
||||||
|
import com.wansenai.entities.support.BasArea;
|
||||||
|
import com.wansenai.mappers.support.BasAreaMapper;
|
||||||
|
import com.wansenai.service.support.BasAreaService;
|
||||||
|
import com.wansenai.vo.support.BasAreaVo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class BasAreaServiceImpl extends ServiceImpl<BasAreaMapper, BasArea> implements BasAreaService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BasAreaVo> getList(BasAreaDto basAreaDto) {
|
||||||
|
var result = new ArrayList<BasAreaVo>();
|
||||||
|
var areas = this.lambdaQuery()
|
||||||
|
.eq(basAreaDto.getId() != null, BasArea::getId, basAreaDto.getId())
|
||||||
|
.eq(basAreaDto.getParentId() != null, BasArea::getParentId, basAreaDto.getParentId())
|
||||||
|
.eq(StringUtils.isNotEmpty(basAreaDto.getRegionType()), BasArea::getRegionType, basAreaDto.getRegionType())
|
||||||
|
.like(StringUtils.isNotEmpty(basAreaDto.getName()), BasArea::getName, basAreaDto.getName())
|
||||||
|
.list();
|
||||||
|
areas.forEach(model->{
|
||||||
|
BasAreaVo vo = new BasAreaVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
result.add(vo);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasAreaVo getDetail(Long id) {
|
||||||
|
var area = this.getById(id);
|
||||||
|
if(Optional.ofNullable(area).isEmpty()){
|
||||||
|
return null;
|
||||||
|
}else {
|
||||||
|
var result = new BasAreaVo();
|
||||||
|
BeanUtils.copyProperties(area, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue