Ver código fonte

가맹점정보 api 수정

dwkim 2 anos atrás
pai
commit
bee8e3e804

+ 60 - 0
src/main/java/com/oqpo/api/service/oper/AfflService.java

@@ -2,6 +2,8 @@ package com.oqpo.api.service.oper;
2 2
 
3 3
 
4 4
 import com.oqpo.api.entity.oper.AfflEntity;
5
+import com.oqpo.api.entity.oper.AfflSaleInfoEntity;
6
+import com.oqpo.api.exception.GlobalException;
5 7
 import com.oqpo.api.mapper.oper.AfflMapper;
6 8
 import com.oqpo.api.service.CommonService;
7 9
 import com.oqpo.api.web.dto.request.GridRequest;
@@ -83,10 +85,68 @@ public class AfflService extends CommonService {
83 85
         return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
84 86
     }
85 87
 
88
+    /* 가맹점 정보 */
86 89
     public AfflShopInfoResponse selectAfflShopInfo(String afflShopId) throws Exception {
87 90
         return AfflShopInfoResponse.toDTO(afflMapper.selectAfflShopBaseInfo(afflShopId),
88 91
                   afflMapper.selectAfflSaleTargetList(afflShopId));
89 92
     }
90 93
 
94
+    /* 가맹점 저장 */
95
+    @Transactional
96
+    public void saveAfflList(String userId, SaveAfflRequest saveAfflRequest) throws Exception {
97
+        try {
98
+
99
+            AfflEntity entity = new AfflEntity();
100
+            entity.setAfflShopId (saveAfflRequest.getAfflShopId());
101
+            entity.setAfflShopNm (saveAfflRequest.getAfflShopNm());
102
+            entity.setStCd (saveAfflRequest.getStCd());
103
+            entity.setAfflAbbr (saveAfflRequest.getAfflAbbr().replaceAll(" ",""));
104
+            entity.setBsnsRegNo (saveAfflRequest.getBsnsRegNo().replaceAll("-",""));
105
+            entity.setCorpRegNo (saveAfflRequest.getCorpRegNo().replaceAll("-",""));
106
+            entity.setBsnsCndt (saveAfflRequest.getBsnsCndt());
107
+            entity.setCtgrBsns (saveAfflRequest.getCtgrBsns());
108
+            entity.setOwnerNm (saveAfflRequest.getOwnerNm());
109
+            entity.setOwnerTelNo (saveAfflRequest.getOwnerTelNo().replaceAll("-",""));
110
+            entity.setRprstFaxNo (saveAfflRequest.getRprstFaxNo().replaceAll("-",""));
111
+            entity.setRprstEmai (saveAfflRequest.getRprstEmai());
112
+            entity.setZipNo (saveAfflRequest.getZipNo());
113
+            entity.setAddr1 (saveAfflRequest.getAddr1());
114
+            entity.setAddr2 (saveAfflRequest.getAddr2());
115
+            entity.setRprstTelNo (saveAfflRequest.getRprstTelNo().replaceAll("-",""));
116
+            entity.setLatX (saveAfflRequest.getLatX());
117
+            entity.setLongY (saveAfflRequest.getLongY());
118
+            entity.setRegDt (saveAfflRequest.getRegDt().replaceAll(".",""));
119
+            entity.setJoinSttDt (saveAfflRequest.getJoinSttDt().replaceAll(".",""));
120
+            entity.setJoinEndDt (saveAfflRequest.getJoinEndDt().replaceAll(".",""));
121
+            entity.setCmpnyLogoFileNo (saveAfflRequest.getCmpnyLogoFileNo());
122
+            entity.setCorpType (saveAfflRequest.getCorpType());
123
+
124
+            if ("C".equals(saveAfflRequest.getViewCd())) {
125
+                // 상품코드 채번
126
+                afflMapper.insertAfflShopBaseInfo(userId, entity);
127
+            } else if ("U".equals(saveAfflRequest.getViewCd())) {
128
+                afflMapper.updateAfflShopBaseInfo(userId, entity);
129
+            }
130
+
131
+            //  영업담당자 상세 정보 저장
132
+            // 신규건
133
+            List<AfflSaleInfoEntity> gridInsertData = saveAfflRequest.toCodeEntities(saveAfflRequest.getGridInsertData());
134
+            if (gridInsertData.size() > 0) {
135
+                afflMapper.insertAfflSaleInfo(userId, gridInsertData) ;
136
+            }
137
+            // 삭제건
138
+            List<AfflSaleInfoEntity> gridDeleteData = saveAfflRequest.toCodeEntities(saveAfflRequest.getGridDeleteData());
139
+            if (gridDeleteData.size() > 0) {
140
+                afflMapper.deleteUserAuth(userId, gridDeleteData) ;
141
+            }
142
+
143
+        } catch (GlobalException e) {
144
+            e.getStackTrace();
145
+            throw new GlobalException(e.getSystemMessageCode());
146
+        } catch (Exception e) {
147
+            e.getStackTrace();
148
+            throw new RuntimeException();
149
+        }
150
+    }
91 151
 
92 152
 }

+ 23 - 1
src/main/java/com/oqpo/api/web/controller/oper/AfflController.java

@@ -1,9 +1,12 @@
1 1
 package com.oqpo.api.web.controller.oper;
2 2
 
3
+import com.oqpo.api.enums.SystemMessageCode;
3 4
 import com.oqpo.api.service.oper.AfflService;
4 5
 import com.oqpo.api.web.dto.request.oper.affl.AfflGridRequest;
5 6
 import com.oqpo.api.web.dto.request.oper.affl.AfflShopBaseInfoGridRequest;
7
+import com.oqpo.api.web.dto.request.oper.affl.SaveAfflRequest;
6 8
 import com.oqpo.api.web.dto.response.GridResponse;
9
+import com.oqpo.api.web.dto.response.SaveResponse;
7 10
 import com.oqpo.api.web.dto.response.oper.affl.AfflShopInfoResponse;
8 11
 import io.swagger.annotations.ApiImplicitParam;
9 12
 import io.swagger.annotations.ApiImplicitParams;
@@ -50,7 +53,7 @@ public class AfflController {
50 53
     @ApiImplicitParams({
51 54
             @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
52 55
     })
53
-    @ApiOperation(value = " 가맹 그리드 리스트")
56
+    @ApiOperation(value = " 가맹 그리드 리스트")
54 57
     @PostMapping("/detail-grid-list")
55 58
     public ResponseEntity<GridResponse> detailGridList(@RequestBody @Valid AfflShopBaseInfoGridRequest afflShopBaseInfoGridRequest) throws Exception {
56 59
         return ResponseEntity.ok(afflService.selectAfflShopGridList( afflShopBaseInfoGridRequest.getFromDt(), afflShopBaseInfoGridRequest.getToDt(), afflShopBaseInfoGridRequest.getSAfflShopNm(), afflShopBaseInfoGridRequest.getSStCd(),  afflShopBaseInfoGridRequest.toDTO(afflShopBaseInfoGridRequest)));
@@ -74,4 +77,23 @@ public class AfflController {
74 77
         return ResponseEntity.ok(afflService.selectAfflShopInfo(afflShopId));
75 78
     }
76 79
 
80
+
81
+    /**
82
+     * 설명 : 가맹점 정보 저장
83
+     *
84
+     * @param userId
85
+     * @param saveCodeRequest
86
+     * @return SaveResponse
87
+     * @throws Exception
88
+     */
89
+    @ApiImplicitParams({
90
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
91
+    })
92
+    @ApiOperation(value = "가맹점정보 저장")
93
+    @PostMapping("/save-code")
94
+    public ResponseEntity<SaveResponse> saveCode(@ApiIgnore String userId, @RequestBody @Valid SaveAfflRequest saveAfflRequest) throws Exception {
95
+        afflService.saveAfflList(userId, saveAfflRequest);
96
+        return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
97
+    }
98
+
77 99
 }

+ 2 - 3
src/main/java/com/oqpo/api/web/dto/request/oper/affl/SaveAfflRequest.java

@@ -116,12 +116,11 @@ public class SaveAfflRequest {
116 116
     @Builder
117 117
     @AllArgsConstructor(access = AccessLevel.PROTECTED)
118 118
     static class SaveAfflSale {
119
-        @NotBlank
120
-        @ApiModelProperty(value = "코드")
119
+        @ApiModelProperty(value = "가맹점아이디")
121 120
         private String afflShopId;
122 121
 
123 122
         @NotBlank
124
-        @ApiModelProperty(value = "상세코드")
123
+        @ApiModelProperty(value = "영업담당자아이디")
125 124
         private String saleMgrId;
126 125
 
127 126
     }

+ 2 - 2
src/main/resources/mybatis/sqlmaps/oper/Affl.xml

@@ -170,7 +170,7 @@
170 170
 
171 171
     <insert id="insertAfflSaleInfo" >
172 172
         insert into /** insertAfflSaleInfo */ affl_sale_info
173
-        (affl_shop_id, sale_mgr_id, sys_reg_dtm, sys_reg_id, sys_chg_dtm, sys_chg_id)
173
+        (affl_shop_id, sale_mgr_id, sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
174 174
         values
175 175
         <foreach collection="gridInsertData" item="item" separator=",">
176 176
             ( #{item.afflShopId},#{item.saleMgrId}, now(), #{userId}, now(), #{userId})
@@ -200,7 +200,7 @@
200 200
     </select>
201 201
 
202 202
     <select id="selectAfflSaleTargetList" resultType="com.oqpo.api.entity.oper.AfflSaleInfoEntity">
203
-        select sinfo.affl_shop_id , sinfo.sale_mgr_id, mgrm.sale_mgr_nm  as 'saleMgrInfo.sale_mget_nm', mgrm.rprst_emai as 'saleMgrInfo.rprst_emai'
203
+        select sinfo.affl_shop_id , sinfo.sale_mgr_id, mgrm.sale_mgr_nm  as 'saleMgrInfo.sale_mgr_nm', mgrm.rprst_emai as 'saleMgrInfo.rprst_emai'
204 204
         ,fn_get_telno(mgrm.rprst_tel_no)   as 'saleMgrInfo.rprst_tel_no'
205 205
         , mgrm.st_cd as 'saleMgrInfo.st_cd', fn_code_nm('ST_CD',mgrm.st_cd) as 'saleMgrInfo.st_nm'
206 206
         from affl_sale_info  sinfo