Browse Source

공지사항 리스트 출력

dwkim 2 years ago
parent
commit
4469783376

+ 5 - 0
src/main/java/com/oqpo/api/entity/oper/NticeEntity.java

@@ -1,5 +1,6 @@
1 1
 package com.oqpo.api.entity.oper;
2 2
 
3
+import io.swagger.annotations.ApiModelProperty;
3 4
 import lombok.Getter;
4 5
 import lombok.Setter;
5 6
 import lombok.ToString;
@@ -12,6 +13,10 @@ import java.io.Serializable;
12 13
 public class NticeEntity implements Serializable {
13 14
     private static final long serialVersionUID = -3590936033715917450L;
14 15
 
16
+    private String afflShopId;
17
+    private String afflShopNm;
18
+    private String brandId;
19
+    private String brandNm;
15 20
     private String nticeNo;
16 21
     private String targetCd;
17 22
     private String targetNm;

+ 7 - 4
src/main/java/com/oqpo/api/mapper/oper/NticeMapper.java

@@ -11,10 +11,13 @@ import java.util.List;
11 11
 
12 12
 @Mapper
13 13
 public interface NticeMapper {
14
-    List<NticeEntity> selectNticeGridList(@Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("schDt") String schDt,
15
-                                          @Param("userId") String userId, @Param("sNticeTitl") String sNticeTitl, GridRequest gridRequest)throws Exception;
16
-    int selectNticeGridCnt(@Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("schDt") String schDt,
17
-                           @Param("userId") String userId, @Param("sNticeTitl") String sNticeTitl) throws Exception;
14
+    List<NticeEntity> selectNticeGridList(@Param("afflShopId") String afflShopId, @Param("brandId") String brandId, @Param("authTpCd") String authTpCd,
15
+                                          @Param("sAfflShopId") String sAfflShopId, @Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt,
16
+                                          @Param("sNticeTitl") String sNticeTitl, GridRequest gridRequest)throws Exception;
17
+
18
+    int selectNticeGridCnt(@Param("afflShopId") String afflShopId, @Param("brandId") String brandId, @Param("authTpCd") String authTpCd,
19
+                           @Param("sAfflShopId") String sAfflShopId, @Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt,
20
+                           @Param("sNticeTitl") String sNticeTitl) throws Exception;
18 21
 
19 22
     List<NticeTargetEntity> selectNticeTargetGridList(@Param("nticeNo") String nticeNo, GridRequest gridRequest)throws Exception;
20 23
     int selectNticeTargetGridCnt(@Param("nticeNo") String nticeNo) throws Exception;

+ 12 - 6
src/main/java/com/oqpo/api/service/oper/NticeService.java

@@ -29,29 +29,35 @@ public class NticeService extends CommonService {
29 29
     /*
30 30
       공지 검색 리스트 조회
31 31
      */
32
-    public GridResponse selectNticeGridList(String fromDt, String toDt, String schDt, String userId, String sNticeTitl, GridRequest gridRequest) throws Exception {
32
+
33
+    public GridResponse selectNticeGridList(String afflShopId, String brandId, String authTpCd, String sAfflShopId, String sBrandId, String fromDt, String toDt, String sNticeTitl, GridRequest gridRequest) throws Exception {
33 34
         int gridPage = gridRequest.getGridPage();
34 35
         int gridSize = gridRequest.getGridSize();
35 36
 
36 37
         fromDt = fromDt == null ? null : fromDt.replace(".", "");
37 38
         toDt = toDt == null ? null : toDt.replace(".", "");
38
-        schDt = schDt == null ? null : schDt.replace(".", "");
39 39
 
40
-        int gridRecords = nticeMapper.selectNticeGridCnt(fromDt, toDt, schDt, userId, sNticeTitl);
40
+        int gridRecords = nticeMapper.selectNticeGridCnt(afflShopId, brandId, authTpCd, sAfflShopId, sBrandId, fromDt, toDt, sNticeTitl);
41 41
         int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
42
-        List<NticeEntity> entities = nticeMapper.selectNticeGridList(fromDt, toDt, schDt, userId, sNticeTitl, gridRequest);
42
+        List<NticeEntity> entities = nticeMapper.selectNticeGridList(afflShopId, brandId, authTpCd, sAfflShopId, sBrandId, fromDt, toDt, sNticeTitl, gridRequest);
43
+
43 44
         List<Object> gridRows = entities.stream()
44 45
                 .map(m -> NticeSearchResponse.builder()
45 46
                         .viewCd("R")
47
+                        .afflShopId(m.getAfflShopId()  == null ? "" : m.getAfflShopId() )
48
+                        .afflShopNm(m.getAfflShopNm()  == null ? "" : m.getAfflShopNm() )
49
+                        .brandId(m.getBrandId()  == null ? "" : m.getBrandId())
50
+                        .brandNm(m.getBrandNm()  == null ? "" : m.getBrandNm())
46 51
                         .nticeNo(m.getNticeNo())
47 52
                         .nticeTitl(m.getNticeTitl() == null ? "" : m.getNticeTitl())
48
-                        .targetCd(m.getTargetCd())
49
-                        .targetNm(m.getTargetNm())
53
+                        .targetCd(m.getTargetCd() == null ? "" : m.getTargetCd())
54
+                        .targetNm(m.getTargetNm() == null ? "" : m.getTargetNm())
50 55
                         .nticeStatNm(m.getNticeStatNm())
51 56
                         .notiStDay(m.getNotiStDay())
52 57
                         .addDt(m.getAddDt())
53 58
                         .build())
54 59
                 .collect(Collectors.toList());
60
+
55 61
         return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
56 62
     }
57 63
 

+ 3 - 3
src/main/java/com/oqpo/api/web/controller/oper/NticeController.java

@@ -37,14 +37,14 @@ public class NticeController {
37 37
      * @return
38 38
      * @throws Exception
39 39
      */
40
+
40 41
     @ApiImplicitParams({
41 42
             @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
42 43
     })
43 44
     @ApiOperation(value = " 공지 그리드 리스트")
44 45
     @PostMapping("/detail-grid-list")
45
-    public ResponseEntity<GridResponse> detailGridList(@RequestBody @Valid NticeGridRequest nticeGridRequest) throws Exception {
46
-        return ResponseEntity.ok(nticeService.selectNticeGridList(nticeGridRequest.getFromDt(), nticeGridRequest.getToDt(), nticeGridRequest.getSchDt(),
47
-                nticeGridRequest.getUserId(), nticeGridRequest.getSNticeTitl(), nticeGridRequest.toDTO(nticeGridRequest)));
46
+    public ResponseEntity<GridResponse> detailGridList(@ApiIgnore String afflShopId,@ApiIgnore String brandId,@ApiIgnore String authTpCd,@RequestBody @Valid NticeGridRequest nticeGridRequest) throws Exception {
47
+        return ResponseEntity.ok(nticeService.selectNticeGridList( afflShopId, brandId, authTpCd, nticeGridRequest.getSAfflShopId(), nticeGridRequest.getSBrandId(), nticeGridRequest.getFromDt(), nticeGridRequest.getToDt(), nticeGridRequest.getSNticeTitl(),  nticeGridRequest.toDTO(nticeGridRequest)));
48 48
     }
49 49
 
50 50
     /**

+ 6 - 8
src/main/java/com/oqpo/api/web/dto/request/oper/ntice/NticeGridRequest.java

@@ -10,23 +10,21 @@ import lombok.Setter;
10 10
 @Setter
11 11
 public class NticeGridRequest extends GridRequest {
12 12
 
13
+    @ApiModelProperty(value = "가맹점아이디")
14
+    private String sAfflShopId;
15
+
16
+    @ApiModelProperty(value = "브랜드아이디")
17
+    private String sBrandId;
18
+
13 19
     @ApiModelProperty(value = "시작일")
14 20
     private String fromDt;
15 21
 
16 22
     @ApiModelProperty(value = "종료일")
17 23
     private String toDt;
18 24
 
19
-    @ApiModelProperty(value = "조회일자")
20
-    private String schDt;
21
-
22 25
     @ApiModelProperty(value = "타이틀")
23 26
     private String sNticeTitl;
24 27
 
25
-    @ApiModelProperty(value = "상태")
26
-    private String sNticeStatNm;
27
-
28
-    @ApiModelProperty(value = "사용자ID")
29
-    private String userId;
30 28
 
31 29
     protected NticeGridRequest(Integer gridSize, Integer gridPage, String sidx, String sord, Boolean pagingYn, Integer gridFirst) {
32 30
         super(gridSize, gridPage, sidx, sord, pagingYn, gridFirst);

+ 12 - 0
src/main/java/com/oqpo/api/web/dto/response/oper/ntice/NticeSearchResponse.java

@@ -14,6 +14,18 @@ public class NticeSearchResponse {
14 14
     @ApiModelProperty(value = "CRUD")
15 15
     private String viewCd;
16 16
 
17
+    @ApiModelProperty(value = "가맹점아이디")
18
+    private String afflShopId;
19
+
20
+    @ApiModelProperty(value = "가맹점명")
21
+    private String afflShopNm;
22
+
23
+    @ApiModelProperty(value = "브랜드아이디")
24
+    private String brandId;
25
+
26
+    @ApiModelProperty(value = "브랜드명")
27
+    private String brandNm;
28
+
17 29
     @ApiModelProperty(value = "공지번호")
18 30
     private String nticeNo;
19 31
 

+ 51 - 20
src/main/resources/mybatis/sqlmaps/oper/Ntice.xml

@@ -4,30 +4,46 @@
4 4
 <mapper namespace="com.oqpo.api.mapper.oper.NticeMapper">
5 5
     <select id="selectNticeGridList" resultType="com.oqpo.api.entity.oper.NticeEntity">
6 6
         select /* Ntice.selectNticeGridList*/
7
+                A.affl_shop_id, A.brand_id, fn_affl_nm(A.affl_shop_id) as affl_shop_nm, fn_brand_nm(A.brand_id) as brand_nm,
7 8
                 A.ntice_no, A.ntice_titl, A.target_cd, fn_code_nm('TARGET_CD', A.target_cd) as target_nm
8 9
                 , case when  date_format(now(),'%Y%m%d') <![CDATA[ >= ]]> A.noti_st_day and date_format(now(),'%Y%m%d') <![CDATA[ <= ]]> A.noti_ed_day then '공지중'
9 10
                 when  date_format(now(),'%Y%m%d') <![CDATA[ < ]]> A.noti_st_day then '대기'
10 11
                 when  date_format(now(),'%Y%m%d') <![CDATA[ > ]]> A.noti_ed_day then '공지종료' end as ntice_stat_nm
11 12
                 ,date_format(A.noti_st_day ,'%Y.%m.%d') as noti_st_day, date_format(A.add_dt ,'%Y.%m.%d') as add_dt
12 13
         from np_ntice A
13
-        <if test="schDt != null and schDt != '' ">
14
-        left join np_ntice_target B on A.ntice_no = B.ntice_no and B.user_id = #{userId}
15
-        </if>
16 14
         where 1=1
17
-        <if test="fromDt != null and fromDt != '' and toDt != null and toDt != '' ">
18
-            and A.noti_st_day  between #{fromDt} and #{toDt}
15
+        and A.brand_id in (select B.brand_id from np_ntice_target B where B.ntice_no = A.ntice_no )
16
+        <if test="authTpCd == '30'">
17
+         and A.affl_shop_id = #{afflShopId}
18
+        </if>
19
+        <if test="authTpCd == '40' ">
20
+            and A.brand_id = #{brandId}
21
+            and A.brand_chk = 'Y'
22
+        </if>
23
+        <if test="authTpCd == '50' ">
24
+            and A.brand_id = #{brandId}
25
+            and A.shop_chk = 'Y'
26
+        </if>
27
+        <if test="authTpCd == '60' ">
28
+            and A.brand_id = #{brandId}
29
+            and A.supply_chk = 'Y'
30
+        </if>
31
+        <if test="sAfflShopId != null and sAfflShopId != ''">
32
+            and    affl_shop_id = #{sAfflShopId}
33
+        </if>
34
+        <if test="sBrandId != null and sBrandId != ''">
35
+            and    brand_id = #{sBrandId}
19 36
         </if>
20
-        <if test="schDt != null and schDt != '' ">
37
+        <if test="fromDt != null and fromDt != '' and  toDt != null and toDt != ''  ">
21 38
             <![CDATA[
22
-            and A.noti_st_day <= #{schDt}
23
-            and A.noti_ed_day >= #{schDt}
24
-            and A.del_yn = 'N'
25
-            and (A.target_cd = 'A' or (A.target_cd = 'T' and B.user_id is not null))
39
+            and A.noti_st_day >= #{fromDt}
40
+            and A.noti_ed_day <= #{toDt}
26 41
             ]]>
27 42
         </if>
28 43
         <if test="sNticeTitl != null and sNticeTitl != '' ">
29 44
         and A.ntice_titl like concat('%', #{sNticeTitl}, '%')
30 45
         </if>
46
+        and A.del_yn = 'N'
31 47
         <choose>
32 48
             <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
33 49
                 <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
@@ -51,24 +67,39 @@
51 67
     <select id="selectNticeGridCnt" resultType="int">
52 68
         select count(*) as cnt  /* Ntice.selectNticeGridCnt*/
53 69
         from np_ntice A
54
-        <if test="schDt != null and schDt != '' ">
55
-            left join np_ntice_target B on A.ntice_no = B.ntice_no and B.user_id = #{userId}
56
-        </if>
57 70
         where 1=1
58
-        <if test="fromDt != null and fromDt != '' and toDt != null and toDt != '' ">
59
-            and A.noti_st_day  between #{fromDt} and #{toDt}
71
+        and A.brand_id in (select B.brand_id from np_ntice_target B where B.ntice_no = A.ntice_no )
72
+        <if test="authTpCd == '30'">
73
+            and A.affl_shop_id = #{afflShopId}
74
+        </if>
75
+        <if test="authTpCd == '40' ">
76
+            and A.brand_id = #{brandId}
77
+            and A.brand_chk = 'Y'
78
+        </if>
79
+        <if test="authTpCd == '50' ">
80
+            and A.brand_id = #{brandId}
81
+            and A.shop_chk = 'Y'
82
+        </if>
83
+        <if test="authTpCd == '60' ">
84
+            and A.brand_id = #{brandId}
85
+            and A.supply_chk = 'Y'
86
+        </if>
87
+        <if test="afflShopId != null and afflShopId != ''">
88
+            and    affl_shop_id = #{afflShopId}
89
+        </if>
90
+        <if test="brandId != null and brandId != ''">
91
+            and    brand_id = #{brandId}
60 92
         </if>
61
-        <if test="schDt != null and schDt != '' ">
93
+        <if test="fromDt != null and fromDt != '' and  toDt != null and toDt != ''  ">
62 94
             <![CDATA[
63
-            and A.noti_st_day <= #{schDt}
64
-            and A.noti_ed_day >= #{schDt}
65
-            and A.del_yn = 'N'
66
-            and (A.target_cd = 'A' or (A.target_cd = 'T' and B.user_id is not null))
95
+            and A.noti_st_day >= #{fromDt}
96
+            and A.noti_ed_day <= #{toDt}
67 97
             ]]>
68 98
         </if>
69 99
         <if test="sNticeTitl != null and sNticeTitl != '' ">
70 100
             and A.ntice_titl like concat('%', #{sNticeTitl}, '%')
71 101
         </if>
102
+        and A.del_yn = 'N'
72 103
     </select>
73 104
 
74 105
     <select id="selectNticeInfo" resultType="com.oqpo.api.entity.oper.NticeEntity">