home 2 gadi atpakaļ
vecāks
revīzija
cbb209a23f

+ 1 - 1
hx-common/code-generator/src/main/java/com/fjhx/modular/Victoriatourist.java

@@ -12,7 +12,7 @@ public class Victoriatourist {
         CodeGenerator.MODULAR_NAME = "victoriatourist";
 
         // 需要生成的表名称,多表用,隔开
-        CodeGenerator.INCLUDE = "purchase";
+        CodeGenerator.INCLUDE = "customer_info";
 
         // mysql连接
         CodeGenerator.MYSQL_URL = "36.134.91.96:17330";

+ 42 - 0
hx-common/common-client-util/src/main/java/com/fjhx/utils/RegionClientUtil.java

@@ -48,5 +48,47 @@ public class RegionClientUtil {
 
     }
 
+    public static void setEntityRegionName(List<? extends region> list) {
+        IRegionClient regionClient = getRegionClient();
+
+        HashSet<String> regionSet = new HashSet<>();
+
+        for (region region : list) {
+            // 查询国省市
+            regionSet.add(region.getCountryId());
+            regionSet.add(region.getProvinceId());
+            regionSet.add(region.getCityId());
+        }
+
+        regionSet.remove(null);
+
+        R<Map<String, String>> r = regionClient.getChineseNameById(regionSet);
+        Map<String, String> regionMap = Assert.result(r);
+
+        for (region region : list) {
+            // 赋值国省市
+            region.setCountryName(regionMap.get(region.getCountryId()));
+            region.setProvinceName(regionMap.get(region.getProvinceId()));
+            region.setCityName(regionMap.get(region.getCityId()));
+        }
+
+    }
+
+    public interface region {
+
+        String getCountryId();
+
+        String getProvinceId();
+
+        String getCityId();
+
+        void setCountryName(String countryName);
+
+        void setProvinceName(String provinceName);
+
+        void setCityName(String cityName);
+
+    }
+
 
 }

+ 12 - 0
hx-common/common-tool/src/main/java/com/fjhx/utils/PageUtil.java

@@ -1,6 +1,8 @@
 package com.fjhx.utils;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 
 import java.util.Map;
@@ -34,4 +36,14 @@ public class PageUtil {
         return new Page<>(getCurrent(condition), getSize(condition));
     }
 
+    public static <T> Page<T> copyPage(IPage<?> page, Class<T> cls) {
+        Page<T> result = new Page<>();
+        result.setRecords(BeanUtil.copyToList(page.getRecords(), cls));
+        result.setTotal(page.getTotal());
+        result.setCurrent(page.getCurrent());
+        result.setSize(page.getSize());
+        result.setPages(page.getPages());
+        return result;
+    }
+
 }

+ 2 - 2
hx-common/common-tool/src/main/java/com/fjhx/utils/wrapperUtil/IWrapper.java

@@ -130,12 +130,12 @@ public class IWrapper<T> extends AbstractWrapper<T, String, IWrapper<T>> impleme
 
     public IWrapper<T> periodTime(String field) {
         Object beginTime = getValue("beginTime");
-        if (ObjectUtil.isNull(beginTime)) {
+        if (ObjectUtil.isEmpty(beginTime)) {
             return this;
         }
 
         Object endTime = getValue("endTime");
-        if (ObjectUtil.isNull(endTime)) {
+        if (ObjectUtil.isEmpty(endTime)) {
             return this;
         }
 

+ 7 - 0
hx-service-api/victoriatourist-api/pom.xml

@@ -17,10 +17,17 @@
     </properties>
 
     <dependencies>
+
         <dependency>
             <groupId>com.fjhx</groupId>
             <artifactId>service-file-api</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>common-client-util</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 84 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/customer/CustomerInfo.java

@@ -0,0 +1,84 @@
+package com.fjhx.entity.customer;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.Version;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fjhx.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 客户
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class CustomerInfo extends BaseEntity {
+
+
+    /**
+     * 客户编码
+     */
+    private String code;
+
+    /**
+     * 客户名称
+     */
+    private String name;
+
+    /**
+     * 国家
+     */
+    private String countryId;
+
+    /**
+     * 省
+     */
+    private String provinceId;
+
+    /**
+     * 市
+     */
+    private String cityId;
+
+    /**
+     * 详细地址
+     */
+    private String detailedAddress;
+
+    /**
+     * 联系人
+     */
+    private String contacts;
+
+    /**
+     * 联系电话
+     */
+    private Long phone;
+
+    /**
+     * 联系电话前缀类型
+     */
+    private Integer phonePrefixType;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 逻辑删除 0未删除 1已删除
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Integer delFlag;
+
+
+}

+ 24 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/customer/CustomerInfoEx.java

@@ -0,0 +1,24 @@
+package com.fjhx.params.customer;
+
+import com.fjhx.entity.customer.CustomerInfo;
+import com.fjhx.utils.RegionClientUtil;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 客户
+ *
+ * @author ${author}
+ * @since 2022-12-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class CustomerInfoEx extends CustomerInfo implements RegionClientUtil.region {
+
+    private String countryName;
+
+    private String provinceName;
+
+    private String cityName;
+
+}

+ 22 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/customer/CustomerInfoVo.java

@@ -0,0 +1,22 @@
+package com.fjhx.params.customer;
+
+import com.fjhx.entity.FileInfo;
+import com.fjhx.entity.customer.CustomerInfo;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 客户
+ *
+ * @author ${author}
+ * @since 2022-12-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class CustomerInfoVo extends CustomerInfo {
+
+    List<FileInfo> fileInfoList;
+
+}

+ 56 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/controller/customer/CustomerInfoController.java

@@ -0,0 +1,56 @@
+package com.fjhx.controller.customer;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.params.customer.CustomerInfoEx;
+import org.springblade.core.tool.api.R;
+import com.fjhx.params.customer.CustomerInfoVo;
+import com.fjhx.service.customer.CustomerInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 客户 前端控制器
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-02
+ */
+@RestController
+@RequestMapping("/customerInfo")
+public class CustomerInfoController {
+
+    @Autowired
+    private CustomerInfoService customerInfoService;
+
+    @PostMapping("/page")
+    public R page(@RequestBody Map<String, Object> condition){
+        Page<CustomerInfoEx> result = customerInfoService.getPage(condition);
+        return R.success(result);
+    }
+
+    @PostMapping("/add")
+    public R add(@RequestBody CustomerInfoVo customerInfoVo){
+        customerInfoService.add(customerInfoVo);
+        return R.success();
+    }
+
+    @PostMapping("/edit")
+    public R edit(@RequestBody CustomerInfoVo customerInfoVo){
+        customerInfoService.edit(customerInfoVo);
+        return R.success();
+    }
+
+    @PostMapping("/delete")
+    public R delete(@RequestBody CustomerInfoVo customerInfoVo){
+        customerInfoService.delete(customerInfoVo);
+        return R.success();
+    }
+
+}
+

+ 16 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/mapper/customer/CustomerInfoMapper.java

@@ -0,0 +1,16 @@
+package com.fjhx.mapper.customer;
+
+import com.fjhx.entity.customer.CustomerInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 客户 Mapper 接口
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-02
+ */
+public interface CustomerInfoMapper extends BaseMapper<CustomerInfo> {
+
+}

+ 5 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/mapper/customer/CustomerInfoMapper.xml

@@ -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.fjhx.mapper.customer.CustomerInfoMapper">
+
+</mapper>

+ 29 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/customer/CustomerInfoService.java

@@ -0,0 +1,29 @@
+package com.fjhx.service.customer;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.entity.customer.CustomerInfo;
+import com.fjhx.params.customer.CustomerInfoEx;
+import com.fjhx.params.customer.CustomerInfoVo;
+import com.fjhx.base.BaseService;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 客户 服务类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-02
+ */
+public interface CustomerInfoService extends BaseService<CustomerInfo> {
+
+    Page<CustomerInfoEx> getPage(Map<String, Object> condition);
+
+    void add(CustomerInfoVo customerInfoVo);
+
+    void edit(CustomerInfoVo customerInfoVo);
+
+    void delete(CustomerInfoVo customerInfoVo);
+
+}

+ 74 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/customer/impl/CustomerInfoServiceImpl.java

@@ -0,0 +1,74 @@
+package com.fjhx.service.customer.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.entity.customer.CustomerInfo;
+import com.fjhx.mapper.customer.CustomerInfoMapper;
+import com.fjhx.params.customer.CustomerInfoEx;
+import com.fjhx.params.customer.CustomerInfoVo;
+import com.fjhx.service.customer.CustomerInfoService;
+import com.fjhx.utils.FileClientUtil;
+import com.fjhx.utils.PageUtil;
+import com.fjhx.utils.RegionClientUtil;
+import com.fjhx.utils.wrapperUtil.IWrapper;
+import com.fjhx.utils.wrapperUtil.KeywordData;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 客户 服务实现类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-02
+ */
+@Service
+public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, CustomerInfo> implements CustomerInfoService {
+
+    @Override
+    public Page<CustomerInfoEx> getPage(Map<String, Object> condition) {
+
+        IWrapper<CustomerInfo> wrapper = IWrapper.getWrapper(condition);
+        wrapper.keyword(new KeywordData(CustomerInfo::getName), new KeywordData(CustomerInfo::getCode))
+                .like(CustomerInfo::getName)
+                .like(CustomerInfo::getCode)
+                .eq(CustomerInfo::getCountryId)
+                .eq(CustomerInfo::getProvinceId)
+                .eq(CustomerInfo::getCityId);
+
+        Page<CustomerInfo> itemPage = page(condition, wrapper);
+
+        // 复制分页信息
+        Page<CustomerInfoEx> page = PageUtil.copyPage(itemPage, CustomerInfoEx.class);
+
+        // 赋值地理位置信息
+        RegionClientUtil.setEntityRegionName(page.getRecords());
+
+        return page;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void add(CustomerInfoVo customerInfoVo) {
+        save(customerInfoVo);
+        FileClientUtil.bindingFile(customerInfoVo.getId(), customerInfoVo.getFileInfoList());
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void edit(CustomerInfoVo customerInfoVo) {
+        updateById(customerInfoVo);
+        FileClientUtil.againBindingFile(customerInfoVo.getId(), customerInfoVo.getFileInfoList());
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void delete(CustomerInfoVo customerInfoVo) {
+        removeById(customerInfoVo.getId());
+        FileClientUtil.relieveBindingFile(customerInfoVo.getId());
+    }
+
+}