浏览代码

農家インターフェースの変更

zdsong 2 周之前
父节点
当前提交
375de23411

+ 2 - 1
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/domain/vo/MastFarmerVo.java

@@ -1,5 +1,6 @@
 package jp.yamoto.farm.crm.biz.master.domain.vo;
 
+import jp.yamoto.farm.common.core.domain.BaseEntity;
 import lombok.Data;
 
 /**
@@ -8,7 +9,7 @@ import lombok.Data;
  * @author nextosd
  */
 @Data
-public class MastFarmerVo {
+public class MastFarmerVo extends BaseEntity {
 
     /**
      * ID

+ 1 - 1
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/mapper/MastFarmerMapper.java

@@ -18,7 +18,7 @@ public interface MastFarmerMapper {
      * @param id 農家マスタプライマリ・キー
      * @return 農家マスタ
      */
-    public MastFarmer selectById(String id);
+    public MastFarmerVo selectById(String id);
 
     /**
      * 農家マスタを検索リスト

+ 2 - 10
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/service/IMastFarmerService.java

@@ -30,20 +30,12 @@ public interface IMastFarmerService {
     public List<MastFarmerVo> selectList(MastFarmerBo mastFarmerBo);
 
     /**
-     * 農家マスタの追加
+     * 農家マスタの保存
      *
      * @param mastFarmerBo 農家マスタパラメータ対象
      * @return 結果
      */
-    public int insert(MastFarmerBo mastFarmerBo);
-
-    /**
-     * 農家マスタの修正
-     *
-     * @param mastFarmerBo 農家マスタパラメータ対象
-     * @return 結果
-     */
-    public int update(MastFarmerBo mastFarmerBo);
+    public int save(MastFarmerBo mastFarmerBo);
 
     /**
      * 農家マスタの一括削除

+ 52 - 28
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/service/impl/MastFarmerServiceImpl.java

@@ -3,22 +3,20 @@ 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.MessageUtils;
-import jp.yamoto.farm.common.utils.SecurityUtils;
-import jp.yamoto.farm.common.utils.ValueUtils;
+import jp.yamoto.farm.common.utils.*;
 import jp.yamoto.farm.common.utils.uuid.IdUtils;
 import jp.yamoto.farm.crm.biz.master.domain.bo.MastFarmerBo;
 import jp.yamoto.farm.crm.biz.master.domain.entity.MastFarmer;
 import jp.yamoto.farm.crm.biz.master.domain.vo.MastFarmerVo;
 import jp.yamoto.farm.crm.biz.master.mapper.MastFarmerMapper;
 import jp.yamoto.farm.crm.biz.master.service.IMastFarmerService;
+import lombok.SneakyThrows;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import jp.yamoto.farm.common.utils.DateUtils;
 import java.util.List;
 
 /**
@@ -40,16 +38,15 @@ public class MastFarmerServiceImpl implements IMastFarmerService {
      */
     @Override
     public MastFarmerVo selectById(String id) {
-        MastFarmer mastFarmer = mastFarmerMapper.selectById(id);
+        MastFarmerVo mastFarmerVo = mastFarmerMapper.selectById(id);
 
-        if (mastFarmer == null) {
+        if (mastFarmerVo == null) {
             throw new ServiceException(MessageUtils.message("E0007"));
         }
-        MastFarmerVo item = new MastFarmerVo();
-        BeanUtils.copyProperties(mastFarmer, item);
-        // デコードページにはアイテムが表示されます
-        this.deEncodingPageItems(item);
-        return item;
+
+        // 検索結果をリセット
+        this.restSearchData4View(mastFarmerVo);
+        return mastFarmerVo;
     }
 
     /**
@@ -66,31 +63,48 @@ public class MastFarmerServiceImpl implements IMastFarmerService {
         BeanUtils.copyProperties(mastFarmerBo, mastFarmer);
         // エリによってリストが返されました。
         List<MastFarmerVo> farmerLst =  mastFarmerMapper.selectList(mastFarmer);
-        farmerLst.forEach(p->{
-            this.deEncodingPageItems(p);
-        });
+        for (MastFarmerVo p : farmerLst) {
+            this.restSearchData4View(p);
+        }
         return farmerLst;
     }
 
     /**
-     * 農家マスタの追加
+     * 農家マスタの保存
      *
      * @param mastFarmerBo 農家マスタパラメータ対象
      * @return 結果
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public int insert(MastFarmerBo mastFarmerBo) {
+    public int save(MastFarmerBo mastFarmerBo) {
+
+        if (ValueUtils.isEmpty(mastFarmerBo.getId())) {
+            // 農家マスタの追加
+            return this.insert(mastFarmerBo);
+        } else {
+            // 農家マスタの編集
+            return this.update(mastFarmerBo);
+        }
+    }
+
+    /**
+     * 農家マスタの追加
+     *
+     * @param mastFarmerBo 農家マスタパラメータ対象
+     * @return 結果
+     */
+    private int insert(MastFarmerBo mastFarmerBo) {
         MastFarmer mastFarmer = new MastFarmer();
         BeanUtils.copyProperties(mastFarmerBo, mastFarmer);
 
         // その他の情報を構築します。
-        this.buildMastFarmerInfo(mastFarmer);
+        this.buildFarmerInfo4Save(mastFarmer);
 
         // 農家IDの重複チェック
         int mastFarmerCount = mastFarmerMapper.getFarmerIdCount(mastFarmerBo.getFarmerId());
         if (mastFarmerCount > 0) {
-            throw new ServiceException(MessageUtils.message("E0001", MessageUtils.message("label.nokaCd")));
+            throw new ServiceException(MessageUtils.message("E0001", MessageUtils.message("label.farmerId")));
         }
 
         return mastFarmerMapper.insert(mastFarmer);
@@ -102,13 +116,11 @@ public class MastFarmerServiceImpl implements IMastFarmerService {
      * @param mastFarmerBo 農家マスタパラメータ対象
      * @return 結果
      */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public int update(MastFarmerBo mastFarmerBo) {
+    private int update(MastFarmerBo mastFarmerBo) {
         MastFarmer mastFarmer = new MastFarmer();
         BeanUtils.copyProperties(mastFarmerBo, mastFarmer);
         // その他の情報を構築します。
-        this.buildMastFarmerInfo(mastFarmer);
+        this.buildFarmerInfo4Save(mastFarmer);
 
         int result = mastFarmerMapper.update(mastFarmer);
         if (result < 1) {
@@ -139,11 +151,11 @@ public class MastFarmerServiceImpl implements IMastFarmerService {
      *
      * @param mastFarmer 農家マスタ情報
      */
-    private void  buildMastFarmerInfo(MastFarmer mastFarmer) {
+    private void buildFarmerInfo4Save(MastFarmer mastFarmer) {
         // ログインユーザー情報を取得します
         LoginUser loginUser = SecurityUtils.getLoginUser();
         // ID が空の場合は、ID を設定します。
-        if(ValueUtils.isEmpty(mastFarmer.getId())) {
+        if (ValueUtils.isEmpty(mastFarmer.getId())) {
             // ID
             mastFarmer.setId(IdUtils.nextIdStr());
             // 発行者
@@ -151,6 +163,9 @@ public class MastFarmerServiceImpl implements IMastFarmerService {
             // 発行日
             mastFarmer.setIssuedDate(DateUtils.getDate());
         }
+
+        // データを暗号化
+        // パスワード
         if (mastFarmer.getUserPassword() != null && !mastFarmer.getUserPassword().isEmpty()) {
             mastFarmer.setUserPassword(SecurityUtils.encryptPassword(mastFarmer.getUserPassword()));
         }
@@ -161,18 +176,27 @@ public class MastFarmerServiceImpl implements IMastFarmerService {
 
         // メールアドレス
         if (ValueUtils.isNotEmpty(mastFarmer.getMailAddress())) {
-            mastFarmer.setMailAddress(SecurityUtils.encryptPassword(mastFarmer.getMailAddress()));
+//            mastFarmer.setMailAddress(DecryptUtils.encryptAES(mastFarmer.getMailAddress()));
+        }
+        // 電話番号
+        if (ValueUtils.isNotEmpty(mastFarmer.getMailAddress())) {
+//            mastFarmer.setPhoneNumber(DecryptUtils.encryptAES(mastFarmer.getPhoneNumber()));
         }
 
     }
 
     /**
-     * デコードページにはアイテムが表示されます
+     * 検索結果をリセット
      *
-     * @param mastFarmer 農家マスタ情報
+     * @param mastFarmerVo 農家マスタ詳細情報Vo
      */
-    private void deEncodingPageItems(MastFarmerVo mastFarmer) {
+    @SneakyThrows
+    private void restSearchData4View(MastFarmerVo mastFarmerVo) {
+        // デコードページにはアイテムが表示されます
 
+        // 電話番号
+//        String PhoneNumber = DecryptUtils.decryptAES(mastFarmerVo.getPhoneNumber());
+//        mastFarmerVo.setPhoneNumber(PhoneNumber);
     }
 
 }

+ 5 - 5
farm-crm-biz/src/main/resources/mapper/crm/MastFarmerMapper.xml

@@ -4,7 +4,7 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="jp.yamoto.farm.crm.biz.master.mapper.MastFarmerMapper">
 
-    <resultMap type="MastFarmer" id="MastFarmerResult">
+    <resultMap type="MastFarmerVo" id="MastFarmerResult">
         <result property="id" column="id"/>
         <result property="farmerId" column="farmer_id"/>
         <result property="farmerName" column="farmer_name"/>
@@ -21,8 +21,8 @@
         <result property="issuedBy" column="issued_by"/>
         <result property="issuedDate" column="issued_date"/>
         <result property="loginCnt" column="login_cnt"/>
-        <result property="rakuuruCartId" column="rakuuru_cat_id"/>
-        <result property="rakuuruCartPwd" column="rakuuru_cat_pwd"/>
+        <result property="rakuuruCartId" column="rakuuru_cart_id"/>
+        <result property="rakuuruCartPwd" column="rakuuru_cart_pwd"/>
         <result property="userPassword" column="user_password"/>
         <result property="discontinuedFlg" column="discontinued_flg"/>
         <result property="discontinuedDate" column="discontinued_date"/>
@@ -54,8 +54,8 @@
         issued_by,
         issued_date,
         login_cnt,
-        rakuuru_cat_id,
-        rakuuru_cat_pwd,
+        rakuuru_cart_id,
+        rakuuru_cart_pwd,
         user_password,
         discontinued_flg,
         discontinued_date,

+ 5 - 15
farm-crm/src/main/java/jp/yamoto/farm/crm/web/controller/master/MastFarmerController.java

@@ -23,7 +23,7 @@ import java.util.List;
  * @author nextosd
  */
 @RestController
-@RequestMapping("/master/mast_farmer")
+@RequestMapping("/api/farmer")
 public class MastFarmerController extends BaseController {
 
     @Autowired
@@ -50,23 +50,13 @@ public class MastFarmerController extends BaseController {
     }
 
     /**
-     * 農家マスタの追加
+     * 農家マスタの保存
      */
     @PreAuthorize("@ss.hasPermi('crm:mastNoka:add')")
     @Log(title = "農家マスタ", businessType = BusinessType.INSERT)
-    @PostMapping("/add")
-    public AjaxResult add(@RequestBody @Validated({ValidatorGroup.AddGroup.class}) MastFarmerBo mastNokaBo) {
-        return toAjax(mastFarmerService.insert(mastNokaBo));
-    }
-
-    /**
-     * 農家マスタの修正
-     */
-    @PreAuthorize("@ss.hasPermi('crm:mastNoka:edit')")
-    @Log(title = "農家マスタ", businessType = BusinessType.UPDATE)
-    @PostMapping("/edit")
-    public AjaxResult edit(@RequestBody @Validated({ValidatorGroup.AddGroup.class}) MastFarmerBo mastFarmerBo) {
-        return toAjax(mastFarmerService.update(mastFarmerBo));
+    @PostMapping("/save")
+    public AjaxResult add(@RequestBody @Validated({ValidatorGroup.AddGroup.class}) MastFarmerBo mastFarmerBo) {
+        return toAjax(mastFarmerService.save(mastFarmerBo));
     }
 
     /**

+ 2 - 1
farm-crm/src/main/resources/i18n/messages.properties

@@ -74,9 +74,10 @@ I0004=\u53D6\u8FBC\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002
 I0008=\u30ED\u30B0\u30A4\u30F3\u3057\u307E\u3057\u305F\u3002
 I0009=\u30ED\u30B0\u30A2\u30A6\u30C8\u3057\u307E\u3057\u305F\u3002
 
+#\u8FB2\u5BB6
+label.farmerId=\u8FB2\u5BB6ID
 label.farmerName=\u8FB2\u5BB6\u540D
 label.farmerNameKn=\u8FB2\u5BB6\u540D\uFF08\u30AB\u30CA\uFF09
-label.farmerId=\u8FB2\u5BB6ID
 label.phoneNumber=\u96FB\u8A71\u756A\u53F7
 label.rakuuruCartId=\u3089\u304F\u3046\u308B\u30AB\u30FC\u30C8ID
 label.rakuuruCartPwd=\u3089\u304F\u3046\u308B\u30AB\u30FC\u30C8\u30D1\u30B9\u30EF\u30FC\u30C9