浏览代码

顾客インターフェース修正

zdsong 2 周之前
父节点
当前提交
9ef8ebe33f

+ 161 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/domain/bo/MastCustomerBo.java

@@ -0,0 +1,161 @@
+package jp.yamoto.farm.crm.biz.master.domain.bo;
+
+import jp.yamoto.farm.common.core.domain.BaseEntity;
+import jp.yamoto.farm.common.validator.annotation.LmLength;
+import jp.yamoto.farm.common.validator.annotation.LmNotBlank;
+import jp.yamoto.farm.common.validator.annotation.LmPhoneNo;
+import jp.yamoto.farm.common.validator.utils.ValidatorGroup;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 顧客マスタ サービスパラメータ対象
+ *
+ * @author nextosd
+ */
+@Data
+public class MastCustomerBo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    private String id;
+
+    /**
+     * 顧客ID
+     */
+    @LmNotBlank(params = {"{customerId}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    @LmLength(min = 1, max = 20, params = {"{customerId}", "20"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String customerId;
+
+    /**
+     * 氏名(姓)
+     */
+    private String firstName;
+
+    /**
+     * 氏名(名)
+     */
+    private String lastName;
+
+    /**
+     * 顧客名
+     */
+    @LmNotBlank(params = {"{customerName}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    @LmLength(min = 1, max = 128, params = {"{customerName}", "128"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String customerName;
+
+    /**
+     * 電話番号
+     */
+    @LmNotBlank(params = {"{phoneNumber}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    @LmLength(min = 1, max = 32, params = {"{phoneNumber}", "32"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    @LmPhoneNo(params = {"{phoneNumber}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String phoneNumber;
+
+    /**
+     * システム顧客番号
+     */
+    private String sysCustomerId;
+
+    /**
+     * 会員ID
+     */
+    private String memberId;
+
+    /**
+     * 氏名フリガナ(セイ)
+     */
+    private String furiganaSei;
+
+    /**
+     * 氏名フリガナ(メイ)
+     */
+    private String furiganaMei;
+
+    /**
+     * 会社名
+     */
+    private String companyName;
+
+    /**
+     * 部署名
+     */
+    private String departmentName;
+
+    /**
+     * 郵便番号
+     */
+    @LmLength(min = 1, max = 8, params = {"{postalCode}", "8"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String postalCode;
+
+    /**
+     * 都道府県
+     */
+    private String prefecture;
+
+    /**
+     * 市区町村
+     */
+    private String city;
+
+    /**
+     * 町域・番地
+     */
+    private String townStreetArea;
+
+    /**
+     * ビル等
+     */
+    private String buildingEtc;
+
+    /**
+     * 住所
+     */
+    @LmNotBlank(params = {"{address}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    @LmLength(min = 1, max = 256, params = {"{address}", "256"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String address;
+
+    /**
+     * メールアドレス
+     */
+    @LmNotBlank(params = {"{mailAddress}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    @LmLength(min = 1, max = 128, params = {"{mailAddress}", "128"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String mailAddress;
+
+    /**
+     * 携帯電話番号
+     */
+    private String mobile;
+
+    /**
+     * FAX番号
+     */
+    private String fax;
+
+    /**
+     * 農家ID
+     */
+    private String farmerId;
+
+    /**
+     * 廃止フラグ
+     */
+    private Integer discontinuedFlg;
+
+    /**
+     * 廃止日
+     */
+    private String discontinuedDate;
+
+    /**
+     * リビジョン
+     */
+    private Integer version;
+
+}

+ 147 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/domain/entity/MastCustomer.java

@@ -0,0 +1,147 @@
+package jp.yamoto.farm.crm.biz.master.domain.entity;
+
+import jp.yamoto.farm.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import java.math.BigDecimal;
+
+/**
+ * 顧客マスタ (mast_customer)
+ *
+ * @author nextosd
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class MastCustomer extends BaseEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    private String id;
+
+    /**
+     * 顧客ID
+     */
+    private String customerId;
+
+    /**
+     * 氏名(姓)
+     */
+    private String firstName;
+
+    /**
+     * 氏名(名)
+     */
+    private String lastName;
+
+    /**
+     * 顧客名
+     */
+    private String customerName;
+
+    /**
+     * 電話番号
+     */
+    private String phoneNumber;
+
+    /**
+     * システム顧客番号
+     */
+    private String sysCustomerId;
+
+    /**
+     * 会員ID
+     */
+    private String memberId;
+
+    /**
+     * 氏名フリガナ(セイ)
+     */
+    private String furiganaSei;
+
+    /**
+     * 氏名フリガナ(メイ)
+     */
+    private String furiganaMei;
+
+    /**
+     * 会社名
+     */
+    private String companyName;
+
+    /**
+     * 部署名
+     */
+    private String departmentName;
+
+    /**
+     * 郵便番号
+     */
+    private String postalCode;
+
+    /**
+     * 都道府県
+     */
+    private String prefecture;
+
+    /**
+     * 市区町村
+     */
+    private String city;
+
+    /**
+     * 町域・番地
+     */
+    private String townStreetArea;
+
+    /**
+     * ビル等
+     */
+    private String buildingEtc;
+
+    /**
+     * 住所
+     */
+    private String address;
+
+    /**
+     * メールアドレス
+     */
+    private String mailAddress;
+
+    /**
+     * 携帯電話番号
+     */
+    private String mobile;
+
+    /**
+     * FAX番号
+     */
+    private String fax;
+
+    /**
+     * 農家ID
+     */
+    private String farmerId;
+
+    /**
+     * 廃止フラグ
+     */
+    private Integer discontinuedFlg;
+
+    /**
+     * 廃止日
+     */
+    private String discontinuedDate;
+
+    /**
+     * リビジョン
+     */
+    private Integer version;
+
+}

+ 145 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/domain/vo/MastCustomerVo.java

@@ -0,0 +1,145 @@
+package jp.yamoto.farm.crm.biz.master.domain.vo;
+
+import jp.yamoto.farm.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+
+/**
+ * 顧客マスタ詳細情報Vo
+ *
+ * @author nextosd
+ */
+@Data
+public class MastCustomerVo extends BaseEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    private String id;
+
+    /**
+     * 顧客ID
+     */
+    private String customerId;
+
+    /**
+     * 氏名(姓)
+     */
+    private String firstName;
+
+    /**
+     * 氏名(名)
+     */
+    private String lastName;
+
+    /**
+     * 顧客名
+     */
+    private String customerName;
+
+    /**
+     * 電話番号
+     */
+    private String phoneNumber;
+
+    /**
+     * システム顧客番号
+     */
+    private String sysCustomerId;
+
+    /**
+     * 会員ID
+     */
+    private String memberId;
+
+    /**
+     * 氏名フリガナ(セイ)
+     */
+    private String furiganaSei;
+
+    /**
+     * 氏名フリガナ(メイ)
+     */
+    private String furiganaMei;
+
+    /**
+     * 会社名
+     */
+    private String companyName;
+
+    /**
+     * 部署名
+     */
+    private String departmentName;
+
+    /**
+     * 郵便番号
+     */
+    private String postalCode;
+
+    /**
+     * 都道府県
+     */
+    private String prefecture;
+
+    /**
+     * 市区町村
+     */
+    private String city;
+
+    /**
+     * 町域・番地
+     */
+    private String townStreetArea;
+
+    /**
+     * ビル等
+     */
+    private String buildingEtc;
+
+    /**
+     * 住所
+     */
+    private String address;
+
+    /**
+     * メールアドレス
+     */
+    private String mailAddress;
+
+    /**
+     * 携帯電話番号
+     */
+    private String mobile;
+
+    /**
+     * FAX番号
+     */
+    private String fax;
+
+    /**
+     * 農家ID
+     */
+    private String farmerId;
+
+    /**
+     * 廃止フラグ
+     */
+    private Integer discontinuedFlg;
+
+    /**
+     * 廃止日
+     */
+    private String discontinuedDate;
+
+    /**
+     * リビジョン
+     */
+    private Integer version;
+
+}

+ 63 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/mapper/MastCustomerMapper.java

@@ -0,0 +1,63 @@
+package jp.yamoto.farm.crm.biz.master.mapper;
+
+import jp.yamoto.farm.crm.biz.master.domain.entity.MastCustomer;
+import jp.yamoto.farm.crm.biz.master.domain.vo.MastCustomerVo;
+import java.util.List;
+
+
+/**
+ * 顧客マスタ Mapperインタフェース
+ *
+ * @author nextosd
+ */
+public interface MastCustomerMapper {
+
+     /**
+     *顧客マスタを検索
+     *
+     * @param id 顧客マスタプライマリ・キー
+     * @return 顧客マスタ
+     */
+    public MastCustomerVo selectById(String id);
+
+     /**
+     *顧客マスタを検索リスト
+     *
+     * @param mastCustomer 顧客マスタ
+     * @return 顧客マスタリスト
+     */
+    public List<MastCustomerVo> selectList(MastCustomer mastCustomer);
+
+    /**
+     * 顧客CDの件数のクエリ
+     *
+     * @param customerId 顧客ID
+     * @return 結果
+     */
+    public int getCustomerIdCount(String customerId);
+
+     /**
+     *顧客マスタを登録
+     *
+     * @param mastCustomer 顧客マスタ
+     * @return  結果
+     */
+    public int insert(MastCustomer mastCustomer);
+
+     /**
+     *顧客マスタを修正
+     *
+     * @param mastCustomer 顧客マスタ
+     * @return  結果
+     */
+    public int update(MastCustomer mastCustomer);
+
+    /**
+     * 一覧表示項目スタの論理削除
+     *
+     * @param mastCustomer 一覧表示項目
+     * @return 結果
+     */
+    public int deleteLogicByIdAndVersion(MastCustomer mastCustomer);
+
+}

+ 55 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/service/IMastCustomerService.java

@@ -0,0 +1,55 @@
+package jp.yamoto.farm.crm.biz.master.service;
+
+import jp.yamoto.farm.crm.biz.master.domain.bo.MastCustomerBo;
+import jp.yamoto.farm.crm.biz.master.domain.entity.MastCustomer;
+import jp.yamoto.farm.crm.biz.master.domain.vo.MastCustomerVo;
+
+import java.util.List;
+
+/**
+ * 顧客マスタ Serviceインタフェース
+ *
+ * @author nextosd
+ */
+public interface IMastCustomerService {
+
+    /**
+     * 顧客マスタの検索
+     *
+     * @param id 顧客マスタプライマリ・キー
+     * @return 顧客マスタ
+     */
+    public MastCustomerVo selectById(String id);
+
+    /**
+     * 顧客マスタのリストを検索
+     *
+     * @param mastCustomerBo 顧客マスタパラメータ対象
+     * @return 顧客マスタリスト
+     */
+    public List<MastCustomerVo> selectList(MastCustomerBo mastCustomerBo);
+
+    /**
+     * 顧客マスタの保存
+     *
+     * @param mastCustomerBo 顧客マスタパラメータ対象
+     * @return 結果
+     */
+    public int save(MastCustomerBo mastCustomerBo);
+
+    /**
+     * 顧客マスタの お問い合わせから保存
+     *
+     * @param mastCustomerBo 顧客マスタパラメータ対象
+     * @return 結果
+     */
+    public void saveCustomerWithBssAsk(MastCustomerBo mastCustomerBo);
+
+    /**
+     * 顧客マスタの一括削除
+     *
+     * @param mastCustomer 顧客マスタ
+     * @return 結果
+     */
+    public int deleteLogicByIdAndVersion(MastCustomer mastCustomer);
+}

+ 216 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/service/impl/MastCustomerServiceImpl.java

@@ -0,0 +1,216 @@
+package jp.yamoto.farm.crm.biz.master.service.impl;
+
+import jp.yamoto.farm.common.core.domain.model.LoginUser;
+import jp.yamoto.farm.common.core.enums.DelFlgEnum;
+import jp.yamoto.farm.common.exception.ServiceException;
+import jp.yamoto.farm.common.utils.DateUtils;
+import jp.yamoto.farm.common.utils.MessageUtils;
+import jp.yamoto.farm.common.utils.SecurityUtils;
+import jp.yamoto.farm.common.utils.ValueUtils;
+import jp.yamoto.farm.common.utils.uuid.IdUtils;
+import jp.yamoto.farm.crm.biz.master.domain.bo.MastCustomerBo;
+import jp.yamoto.farm.crm.biz.master.domain.entity.MastCustomer;
+import jp.yamoto.farm.crm.biz.master.domain.entity.MastFarmer;
+import jp.yamoto.farm.crm.biz.master.domain.vo.MastCustomerVo;
+import jp.yamoto.farm.crm.biz.master.domain.vo.MastFarmerVo;
+import jp.yamoto.farm.crm.biz.master.mapper.MastCustomerMapper;
+import jp.yamoto.farm.crm.biz.master.service.IMastCustomerService;
+import lombok.SneakyThrows;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+
+/**
+ * 顧客マスタ Service業務処理
+ *
+ * @author nextosd
+ */
+@Service
+public class MastCustomerServiceImpl implements IMastCustomerService {
+
+    @Autowired
+    private MastCustomerMapper mastCustomerMapper;
+
+    /**
+     * 顧客マスタの検索
+     *
+     * @param id 顧客マスタプライマリ・キー
+     * @return 顧客マスタ
+     */
+    @Override
+    public MastCustomerVo selectById(String id) {
+        MastCustomerVo mastCustomerVo = mastCustomerMapper.selectById(id);
+
+        if (mastCustomerVo == null) {
+            throw new ServiceException(MessageUtils.message("E0007"));
+        }
+
+        return mastCustomerVo;
+    }
+
+    /**
+     * 顧客マスタのリストを検索
+     *
+     * @param mastCustomerBo 顧客マスタパラメータ対象
+     * @return 顧客マスタリスト
+     */
+    @Override
+    public List<MastCustomerVo> selectList(MastCustomerBo mastCustomerBo) {
+        // 未削除フラグ設定
+        mastCustomerBo.setDiscontinuedFlg(DelFlgEnum.OFF.getCode());
+        MastCustomer mastCustomer = new MastCustomer();
+        // データを取得
+        List<MastCustomerVo> list = mastCustomerMapper.selectList(mastCustomer);
+        for(MastCustomerVo item : list) {
+            this.restSearchData4View(item);
+        }
+        return list;
+    }
+
+    /**
+     * 顧客マスタの保存
+     *
+     * @param mastCustomerBo 顧客マスタパラメータ対象
+     * @return 結果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int save(MastCustomerBo mastCustomerBo) {
+        if (ValueUtils.isEmpty(mastCustomerBo.getId())) {
+            return this.insert(mastCustomerBo);
+        } else {
+            return this.update(mastCustomerBo);
+        }
+    }
+
+    /**
+     * 顧客マスタの お問い合わせから保存
+     *
+     * @param mastCustomerBo 顧客マスタパラメータ対象
+     */
+    public void saveCustomerWithBssAsk(MastCustomerBo mastCustomerBo) {
+        MastCustomer mastCustomer = new MastCustomer();
+        mastCustomer.setDiscontinuedFlg(DelFlgEnum.OFF.getCode());
+        mastCustomer.setPhoneNumber(mastCustomerBo.getPhoneNumber());
+        // データを取得
+        List<MastCustomerVo> list = mastCustomerMapper.selectList(mastCustomer);
+        if(CollectionUtils.isEmpty(list)) {
+            this.insert(mastCustomerBo);
+            return;
+        }
+        for(MastCustomerVo item : list) {
+            if(ValueUtils.isEqual(mastCustomerBo.getCustomerName(), item.getCustomerName())) {
+                continue;
+            }
+            this.update(mastCustomerBo);
+        }
+
+    }
+
+    /**
+     * 顧客マスタの追加
+     *
+     * @param mastCustomerBo 顧客マスタパラメータ対象
+     * @return 結果
+     */
+    private int insert(MastCustomerBo mastCustomerBo) {
+        MastCustomer mastCustomer = new MastCustomer();
+        BeanUtils.copyProperties(mastCustomerBo, mastCustomer);
+
+        // 顧客コードの重複チェック
+        int mastCustomerCount = mastCustomerMapper.getCustomerIdCount(mastCustomerBo.getCustomerId());
+        if (mastCustomerCount > 0) {
+            throw new ServiceException(MessageUtils.message("E0001", MessageUtils.message("label.customerId")));
+        }
+
+        // 保存前にデータを構築
+        this.buildCustomerInfo4Save(mastCustomer);
+
+        return mastCustomerMapper.insert(mastCustomer);
+    }
+
+    /**
+     * 顧客マスタの編集
+     *
+     * @param mastCustomerBo 顧客マスタパラメータ対象
+     * @return 結果
+     */
+    private int update(MastCustomerBo mastCustomerBo) {
+        MastCustomer mastCustomer = new MastCustomer();
+        BeanUtils.copyProperties(mastCustomerBo, mastCustomer);
+
+        // 保存前にデータを構築
+        this.buildCustomerInfo4Save(mastCustomer);
+
+        // データの変更
+        int result = mastCustomerMapper.update(mastCustomer);
+        if (result < 1) {
+            throw new ServiceException(MessageUtils.message("E0007"));
+        }
+        return result;
+    }
+
+    /**
+     * 顧客マスタの論理削除
+     *
+     * @param mastCustomer 顧客マスタ
+     * @return 結果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteLogicByIdAndVersion(MastCustomer mastCustomer) {
+        // 該当データは既に別のユーザーより削除されました。
+        int result = mastCustomerMapper.deleteLogicByIdAndVersion(mastCustomer);
+        if (result < 1) {
+            throw new ServiceException(MessageUtils.message("E0007"));
+        }
+        return result;
+    }
+
+    /**
+     * 保存前にデータを構築
+     *
+     * @param mastCustomer 農家マスタ情報
+     */
+    private void buildCustomerInfo4Save(MastCustomer mastCustomer) {
+        // ログインユーザー情報を取得します
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        // ID が空の場合は、ID を設定します。
+        if (ValueUtils.isEmpty(mastCustomer.getId())) {
+            // ID
+            mastCustomer.setId(IdUtils.nextIdStr());
+
+        }
+
+        // データを暗号化
+
+        // メールアドレス
+        if (ValueUtils.isNotEmpty(mastCustomer.getMailAddress())) {
+//            mastFarmer.setMailAddress(DecryptUtils.encryptAES(mastFarmer.getMailAddress()));
+        }
+        // 電話番号
+        if (ValueUtils.isNotEmpty(mastCustomer.getMailAddress())) {
+//            mastFarmer.setPhoneNumber(DecryptUtils.encryptAES(mastFarmer.getPhoneNumber()));
+        }
+
+    }
+
+    /**
+     * 検索結果をリセット
+     *
+     * @param mastCustomeVo 農家マスタ詳細情報Vo
+     */
+    @SneakyThrows
+    private void restSearchData4View(MastCustomerVo mastCustomeVo) {
+        // デコードページにはアイテムが表示されます
+
+        // 電話番号
+//        String phoneNumber = DecryptUtils.decryptAES(mastCustomer.getPhoneNumber());
+//        mastCustomer.setPhoneNumber(phoneNumber);
+    }
+
+}

+ 500 - 0
farm-crm-biz/src/main/resources/mapper/crm/MastCustomerMapper.xml

@@ -0,0 +1,500 @@
+<?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="jp.yamoto.farm.crm.biz.master.mapper.MastCustomerMapper">
+   <resultMap type="MastCustomerVo" id="MastCustomerResult">
+        <result property="id" column="id"/>
+        <result property="customerId" column="customer_id"/>
+        <result property="firstName" column="first_name"/>
+        <result property="lastName" column="last_name"/>
+        <result property="customerName" column="customer_name"/>
+        <result property="phoneNumber" column="phone_number"/>
+        <result property="sysCustomerId" column="sys_customer_id"/>
+        <result property="memberId" column="member_id"/>
+        <result property="furiganaSei" column="furigana_sei"/>
+        <result property="furiganaMei" column="furigana_mei"/>
+        <result property="companyName" column="company_name"/>
+        <result property="departmentName" column="department_name"/>
+        <result property="postalCode" column="postal_code"/>
+        <result property="prefecture" column="prefecture"/>
+        <result property="city" column="city"/>
+        <result property="townStreetArea" column="town_street_area"/>
+        <result property="buildingEtc" column="building_etc"/>
+        <result property="address" column="address"/>
+        <result property="mailAddress" column="mail_address"/>
+        <result property="mobile" column="mobile"/>
+        <result property="fax" column="fax"/>
+        <result property="farmerId" column="farmer_id"/>
+        <result property="discontinuedFlg" column="discontinued_flg"/>
+        <result property="discontinuedDate" column="discontinued_date"/>
+        <result property="createTime" column="create_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createPgId" column="create_pg_id"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updatePgId" column="update_pg_id"/>
+        <result property="version" column="version"/>
+
+    </resultMap>
+    <sql id="selectMastCustomerVo">
+        select
+          id,
+          customer_id,
+          first_name,
+          last_name,
+          customer_name,
+          phone_number,
+          sys_customer_id,
+          member_id,
+          furigana_sei,
+          furigana_mei,
+          company_name,
+          department_name,
+          postal_code,
+          prefecture,
+          city,
+          town_street_area,
+          building_etc,
+          address,
+          mail_address,
+          mobile,
+          fax,
+          farmer_id,
+          discontinued_flg,
+          discontinued_date,
+          create_time,
+          create_by,
+          create_pg_id,
+          update_time,
+          update_by,
+          update_pg_id,
+          version
+        from mast_customer
+    </sql>
+    <select id="selectList" parameterType="MastCustomer" resultMap="MastCustomerResult">
+        <include refid="selectMastCustomerVo"/>
+        <where>
+            <if test="id != null  and id != ''">
+                and id = #{id}
+            </if>
+            <if test="customerId != null  and customerId != ''">
+                and customer_id = #{customerId}
+            </if>
+            <if test="firstName != null  and firstName != ''">
+                and first_name = #{firstName}
+            </if>
+            <if test="lastName != null  and lastName != ''">
+                and last_name = #{lastName}
+            </if>
+            <if test="customerName != null  and customerName != ''">
+                and customer_name = #{customerName}
+            </if>
+            <if test="phoneNumber != null  and phoneNumber != ''">
+                and phone_number = #{phoneNumber}
+            </if>
+            <if test="sysCustomerId != null  and sysCustomerId != ''">
+                and sys_customer_id = #{sysCustomerId}
+            </if>
+            <if test="memberId != null  and memberId != ''">
+                and member_id = #{memberId}
+            </if>
+            <if test="furiganaSei != null  and furiganaSei != ''">
+                and furigana_sei = #{furiganaSei}
+            </if>
+            <if test="furiganaMei != null  and furiganaMei != ''">
+                and furigana_mei = #{furiganaMei}
+            </if>
+            <if test="companyName != null  and companyName != ''">
+                and company_name = #{companyName}
+            </if>
+            <if test="departmentName != null  and departmentName != ''">
+                and department_name = #{departmentName}
+            </if>
+            <if test="postalCode != null  and postalCode != ''">
+                and postal_code = #{postalCode}
+            </if>
+            <if test="prefecture != null  and prefecture != ''">
+                and prefecture = #{prefecture}
+            </if>
+            <if test="city != null  and city != ''">
+                and city = #{city}
+            </if>
+            <if test="townStreetArea != null  and townStreetArea != ''">
+                and town_street_area = #{townStreetArea}
+            </if>
+            <if test="buildingEtc != null  and buildingEtc != ''">
+                and building_etc = #{buildingEtc}
+            </if>
+            <if test="address != null  and address != ''">
+                and address = #{address}
+            </if>
+            <if test="mailAddress != null  and mailAddress != ''">
+                and mail_address = #{mailAddress}
+            </if>
+            <if test="mobile != null  and mobile != ''">
+                and mobile = #{mobile}
+            </if>
+            <if test="fax != null  and fax != ''">
+                and fax = #{fax}
+            </if>
+            <if test="farmerId != null  and farmerId != ''">
+                and farmer_id = #{farmerId}
+            </if>
+            <if test="discontinuedFlg != null ">
+                and discontinued_flg = #{discontinuedFlg}
+            </if>
+            <if test="discontinuedDate != null  and discontinuedDate != ''">
+                and discontinued_date = #{discontinuedDate}
+            </if>
+
+        </where>
+    </select>
+
+    <select id="selectById" parameterType="String"  resultMap="MastCustomerResult">
+        <include refid="selectMastCustomerVo"/>
+        where id = #{id}
+
+    </select>
+
+    <select id="getCustomerIdCount" parameterType="String" resultType="java.lang.Integer">
+        SELECT
+        count(1)
+        FROM
+        mast_customer
+        <where>
+            <if test="customerId != null  and customerId != ''">
+                and customer_id = #{customerId}
+            </if>
+        </where>
+    </select>
+
+    <insert id="insert" parameterType="MastCustomer">
+        insert into mast_customer
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="customerId != null">
+                customer_id,
+            </if>
+            <if test="firstName != null">
+                first_name,
+            </if>
+            <if test="lastName != null">
+                last_name,
+            </if>
+            <if test="customerName != null">
+                customer_name,
+            </if>
+            <if test="phoneNumber != null">
+                phone_number,
+            </if>
+            <if test="sysCustomerId != null">
+                sys_customer_id,
+            </if>
+            <if test="memberId != null">
+                member_id,
+            </if>
+            <if test="furiganaSei != null">
+                furigana_sei,
+            </if>
+            <if test="furiganaMei != null">
+                furigana_mei,
+            </if>
+            <if test="companyName != null">
+                company_name,
+            </if>
+            <if test="departmentName != null">
+                department_name,
+            </if>
+            <if test="postalCode != null">
+                postal_code,
+            </if>
+            <if test="prefecture != null">
+                prefecture,
+            </if>
+            <if test="city != null">
+                city,
+            </if>
+            <if test="townStreetArea != null">
+                town_street_area,
+            </if>
+            <if test="buildingEtc != null">
+                building_etc,
+            </if>
+            <if test="address != null">
+                address,
+            </if>
+            <if test="mailAddress != null">
+                mail_address,
+            </if>
+            <if test="mobile != null">
+                mobile,
+            </if>
+            <if test="fax != null">
+                fax,
+            </if>
+            <if test="farmerId != null">
+                farmer_id,
+            </if>
+            <if test="discontinuedFlg != null">
+                discontinued_flg,
+            </if>
+            <if test="discontinuedDate != null">
+                discontinued_date,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="createBy != null">
+                create_by,
+            </if>
+            <if test="createPgId != null">
+                create_pg_id,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+            <if test="updateBy != null">
+                update_by,
+            </if>
+            <if test="updatePgId != null">
+                update_pg_id,
+            </if>
+            <if test="version != null">
+                version,
+            </if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id},
+            </if>
+            <if test="customerId != null">
+                #{customerId},
+            </if>
+            <if test="firstName != null">
+                #{firstName},
+            </if>
+            <if test="lastName != null">
+                #{lastName},
+            </if>
+            <if test="customerName != null">
+                #{customerName},
+            </if>
+            <if test="phoneNumber != null">
+                #{phoneNumber},
+            </if>
+            <if test="sysCustomerId != null">
+                #{sysCustomerId},
+            </if>
+            <if test="memberId != null">
+                #{memberId},
+            </if>
+            <if test="furiganaSei != null">
+                #{furiganaSei},
+            </if>
+            <if test="furiganaMei != null">
+                #{furiganaMei},
+            </if>
+            <if test="companyName != null">
+                #{companyName},
+            </if>
+            <if test="departmentName != null">
+                #{departmentName},
+            </if>
+            <if test="postalCode != null">
+                #{postalCode},
+            </if>
+            <if test="prefecture != null">
+                #{prefecture},
+            </if>
+            <if test="city != null">
+                #{city},
+            </if>
+            <if test="townStreetArea != null">
+                #{townStreetArea},
+            </if>
+            <if test="buildingEtc != null">
+                #{buildingEtc},
+            </if>
+            <if test="address != null">
+                #{address},
+            </if>
+            <if test="mailAddress != null">
+                #{mailAddress},
+            </if>
+            <if test="mobile != null">
+                #{mobile},
+            </if>
+            <if test="fax != null">
+                #{fax},
+            </if>
+            <if test="farmerId != null">
+                #{farmerId},
+            </if>
+            <if test="discontinuedFlg != null">
+                #{discontinuedFlg},
+            </if>
+            <if test="discontinuedDate != null">
+                #{discontinuedDate},
+            </if>
+            <if test="createTime != null">
+                #{createTime},
+            </if>
+            <if test="createBy != null">
+                #{createBy},
+            </if>
+            <if test="createPgId != null">
+                #{createPgId},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime},
+            </if>
+            <if test="updateBy != null">
+                #{updateBy},
+            </if>
+            <if test="updatePgId != null">
+                #{updatePgId},
+            </if>
+            <if test="version != null">
+                #{version},
+            </if>
+
+        </trim>
+    </insert>
+
+    <update id="update" parameterType="MastCustomer">
+        update mast_customer
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="id != null">
+                id = #{id},
+            </if>
+            <if test="customerId != null">
+                customer_id = #{customerId},
+            </if>
+            <if test="firstName != null">
+                first_name = #{firstName},
+            </if>
+            <if test="lastName != null">
+                last_name = #{lastName},
+            </if>
+            <if test="customerName != null">
+                customer_name = #{customerName},
+            </if>
+            <if test="phoneNumber != null">
+                phone_number = #{phoneNumber},
+            </if>
+            <if test="sysCustomerId != null">
+                sys_customer_id = #{sysCustomerId},
+            </if>
+            <if test="memberId != null">
+                member_id = #{memberId},
+            </if>
+            <if test="furiganaSei != null">
+                furigana_sei = #{furiganaSei},
+            </if>
+            <if test="furiganaMei != null">
+                furigana_mei = #{furiganaMei},
+            </if>
+            <if test="companyName != null">
+                company_name = #{companyName},
+            </if>
+            <if test="departmentName != null">
+                department_name = #{departmentName},
+            </if>
+            <if test="postalCode != null">
+                postal_code = #{postalCode},
+            </if>
+            <if test="prefecture != null">
+                prefecture = #{prefecture},
+            </if>
+            <if test="city != null">
+                city = #{city},
+            </if>
+            <if test="townStreetArea != null">
+                town_street_area = #{townStreetArea},
+            </if>
+            <if test="buildingEtc != null">
+                building_etc = #{buildingEtc},
+            </if>
+            <if test="address != null">
+                address = #{address},
+            </if>
+            <if test="mailAddress != null">
+                mail_address = #{mailAddress},
+            </if>
+            <if test="mobile != null">
+                mobile = #{mobile},
+            </if>
+            <if test="fax != null">
+                fax = #{fax},
+            </if>
+            <if test="farmerId != null">
+                farmer_id = #{farmerId},
+            </if>
+            <if test="discontinuedFlg != null">
+                discontinued_flg = #{discontinuedFlg},
+            </if>
+            <if test="discontinuedDate != null">
+                discontinued_date = #{discontinuedDate},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+            <if test="createBy != null">
+                create_by = #{createBy},
+            </if>
+            <if test="createPgId != null">
+                create_pg_id = #{createPgId},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime},
+            </if>
+            <if test="updateBy != null">
+                update_by = #{updateBy},
+            </if>
+            <if test="updatePgId != null">
+                update_pg_id = #{updatePgId},
+            </if>
+            version = version + 1
+
+        </trim>
+        where
+        id = #{id}
+
+        and version = #{version}
+    </update>
+
+    <delete id="deleteById" parameterType="String">
+        delete
+        from
+        mast_customer
+        where
+        id = #{id}
+
+    </delete>
+
+    <update id="deleteLogicByIdAndVersion" parameterType="MastOkyakusama">
+        update
+        mast_customer
+        set
+        haisi_flg = 1,
+        version = version + 1,
+        <if test="updateBy != null">
+            update_by = #{updateBy},
+        </if>
+        <if test="updateTime != null">
+            update_time = #{updateTime}
+        </if>
+        <where>
+            <if test="customerId != null  and customerId != ''">
+                and customer_id = #{customerId}
+            </if>
+            and version = #{version}
+            and haisi_flg = 0
+        </where>
+    </update>
+
+ </mapper>

+ 74 - 0
farm-crm/src/main/java/jp/yamoto/farm/crm/web/controller/master/MastCustomerController.java

@@ -0,0 +1,74 @@
+package jp.yamoto.farm.crm.web.controller.master;
+
+import jp.yamoto.farm.common.annotation.Log;
+import jp.yamoto.farm.common.core.controller.BaseController;
+import jp.yamoto.farm.common.core.domain.AjaxResult;
+import jp.yamoto.farm.common.core.page.TableDataInfo;
+import jp.yamoto.farm.common.enums.BusinessType;
+import jp.yamoto.farm.common.validator.utils.ValidatorGroup;
+import jp.yamoto.farm.crm.biz.master.domain.bo.MastCustomerBo;
+
+import jp.yamoto.farm.crm.biz.master.domain.entity.MastCustomer;
+
+import jp.yamoto.farm.crm.biz.master.domain.vo.MastCustomerVo;
+
+import jp.yamoto.farm.crm.biz.master.service.IMastCustomerService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 顧客マスタController
+ *
+ * @author nextosd
+ */
+@RestController
+@RequestMapping("/api/customer")
+public class MastCustomerController extends BaseController {
+
+    @Autowired
+    private IMastCustomerService mastCustomerService;
+
+    /**
+     * 顧客マスタのリスト
+     */
+    @PreAuthorize("@ss.hasPermi('crm:mastCustomer:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(MastCustomerBo mastCustomerBo) {
+        startPage();
+        List<MastCustomerVo> list = mastCustomerService.selectList(mastCustomerBo);
+        return getDataTable(list);
+    }
+
+    /**
+     * 顧客マスタの詳細情報
+     */
+    @GetMapping(value = "/info/{id}")
+    public AjaxResult getInfo(@PathVariable("id") String id) {
+        return success(mastCustomerService.selectById(id));
+    }
+
+    /**
+     * 顧客マスタの追加
+     */
+    @PreAuthorize("@ss.hasPermi('crm:mastCustomer:save')")
+    @Log(title = "顧客マスタ", businessType = BusinessType.SAVE)
+    @PostMapping("/save")
+    public AjaxResult save(@RequestBody @Validated({ValidatorGroup.AddGroup.class}) MastCustomerBo mastCustomerBo) {
+        return toAjax(mastCustomerService.save(mastCustomerBo));
+    }
+
+    /**
+     * 顧客マスタの論理削除
+     */
+    @PreAuthorize("@ss.hasPermi('crm:mastCustomer:remove')")
+    @Log(title = "顧客マスタ", businessType = BusinessType.UPDATE)
+    @PostMapping("/deleteLogic")
+    public AjaxResult deleteLogic(@RequestBody MastCustomer mastCustomer) {
+        return toAjax(mastCustomerService.deleteLogicByIdAndVersion(mastCustomer));
+    }
+}