사용자관리 MERGE DELETE 추가,
STORE 즐겨찾기 API 추가
This commit is contained in:
parent
e55f0a6b00
commit
90364b8185
@ -0,0 +1,34 @@
|
||||
package com.interplug.qcast.biz.storeFavorite;
|
||||
|
||||
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteRequest;
|
||||
import com.interplug.qcast.biz.user.dto.UserResponse;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/store-favorite")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "StoreFavorite", description = "Store Favorite 관련 API")
|
||||
public class StoreFavoriteController {
|
||||
private final StoreFavoriteService storeFavService;
|
||||
|
||||
@Operation(description = "Store Favorite 정보를 등록/수정 한다.(동기화)")
|
||||
@PutMapping("/store-favorite-save")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public UserResponse setStoreFavoriteSave(@RequestBody StoreFavoriteRequest req) {
|
||||
UserResponse userResponse = new UserResponse();
|
||||
|
||||
int resultCnt = storeFavService.setStoreFavoriteSave(req);
|
||||
|
||||
if (resultCnt > 0) userResponse.setCode("200");
|
||||
else userResponse.setCode("500");
|
||||
|
||||
return userResponse;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.interplug.qcast.biz.storeFavorite;
|
||||
|
||||
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface StoreFavoriteMapper {
|
||||
|
||||
int setStoreFavoriteSave(StoreFavoriteRequest req);
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.interplug.qcast.biz.storeFavorite;
|
||||
|
||||
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StoreFavoriteService {
|
||||
private final StoreFavoriteMapper storeFavoriteMapper;
|
||||
|
||||
public int setStoreFavoriteSave(StoreFavoriteRequest req) {
|
||||
return storeFavoriteMapper.setStoreFavoriteSave(req);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.interplug.qcast.biz.storeFavorite.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StoreFavoriteRequest {
|
||||
private String userId;
|
||||
private String saleStoreId;
|
||||
private String dispOrder;
|
||||
private String delFlg;
|
||||
private String registDatetime;
|
||||
private String lastEditDatetime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -47,4 +47,18 @@ public class UserController {
|
||||
|
||||
return userResponse;
|
||||
}
|
||||
|
||||
@Operation(description = "판매점 Sap 정보를 등록/수정 한다.(동기화)")
|
||||
@PutMapping("/store-sap-info-save")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public UserResponse setStoreSapCdSave(@RequestBody StoreRequest storeReq) {
|
||||
UserResponse userResponse = new UserResponse();
|
||||
|
||||
int resultCnt = userService.setStoreSapCdSave(storeReq);
|
||||
|
||||
if (resultCnt > 0) userResponse.setCode("200");
|
||||
else userResponse.setCode("500");
|
||||
|
||||
return userResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,4 @@ public interface UserMapper {
|
||||
|
||||
int setUserSave(UserRequest userReqList);
|
||||
|
||||
int deleteUser(UserRequest userReqList);
|
||||
|
||||
}
|
||||
@ -13,23 +13,23 @@ public class UserService {
|
||||
private final UserMapper userMapper;
|
||||
|
||||
public int setStoreSave(StoreRequest storeReq) {
|
||||
int resultCnt = userMapper.setStoreSave(storeReq);
|
||||
userMapper.setStoreSapCdSave(storeReq);
|
||||
return userMapper.setStoreSave(storeReq);
|
||||
return resultCnt;
|
||||
}
|
||||
|
||||
public int setUserSave(List<UserRequest> userReqList) {
|
||||
int resultCnt = 0;
|
||||
if (!userReqList.isEmpty()) {
|
||||
for (UserRequest userReq : userReqList) {
|
||||
if ("1".equals(userReq.getDelFlg())) { // 삭제
|
||||
resultCnt += userMapper.deleteUser(userReq);
|
||||
} else {
|
||||
resultCnt += userMapper.setUserSave(userReq);
|
||||
}
|
||||
|
||||
resultCnt += userMapper.setUserSave(userReq);
|
||||
}
|
||||
}
|
||||
return resultCnt;
|
||||
}
|
||||
|
||||
public int setStoreSapCdSave(StoreRequest storeReq) {
|
||||
return userMapper.setStoreSapCdSave(storeReq);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
<?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.interplug.qcast.biz.storeFavorite.StoreFavoriteMapper">
|
||||
<insert id="setStoreFavoriteSave" parameterType="com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteRequest" >
|
||||
/* sqlid : com.interplug.qcast.storeFavorite.setStoreFavoriteSave */
|
||||
MERGE M_SALES_STORE_FAV AS A
|
||||
USING
|
||||
( SELECT #{userId} AS USER_ID, #{saleStoreId} AS SALE_STORE_ID ) AS D
|
||||
ON (A.USER_ID = D.USER_ID AND A.SALE_STORE_ID = D.SALE_STORE_ID
|
||||
)
|
||||
WHEN MATCHED THEN
|
||||
UPDATE SET
|
||||
DEL_FLG = #{delFlg}
|
||||
, DISP_ORDER = #{dispOrder}
|
||||
, LAST_EDIT_DATETIME = #{lastEditDatetime}
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT (
|
||||
USER_ID
|
||||
, SALE_STORE_ID
|
||||
, DISP_ORDER
|
||||
, DEL_FLG
|
||||
, REGIST_DATETIME
|
||||
, LAST_EDIT_DATETIME
|
||||
) VALUES (
|
||||
#{userId}
|
||||
, #{saleStoreId}
|
||||
, #{dispOrder}
|
||||
, #{delFlg}
|
||||
, #{registDatetime}
|
||||
, #{lastEditDatetime}
|
||||
);
|
||||
</insert>
|
||||
</mapper>
|
||||
@ -6,20 +6,55 @@
|
||||
|
||||
<insert id="setStoreSapCdSave" parameterType="com.interplug.qcast.biz.user.dto.StoreRequest" >
|
||||
/* sqlid : com.interplug.qcast.user.setStoreSapCdSave */
|
||||
MERGE M_SALES_STORE_ID_FOR_SAP AS A
|
||||
USING
|
||||
( SELECT #{saleStoreId} AS SALE_STORE_ID ) AS D
|
||||
ON (A.SALE_STORE_ID = D.SALE_STORE_ID)
|
||||
WITH SALES_STORE_CTE AS (
|
||||
SELECT
|
||||
SALE_STORE_ID
|
||||
, SALE_STORE_NAME
|
||||
, SALE_STORE_LEVEL
|
||||
, FIRST_AGENT_ID
|
||||
, PARENT_SALE_AGENT_ID
|
||||
, DEL_FLG
|
||||
FROM M_SALES_STORE WITH(NOLOCK)
|
||||
WHERE SALE_STORE_ID = #{saleStoreId}
|
||||
AND APPROVE_FLG = '2'
|
||||
UNION ALL
|
||||
SELECT
|
||||
A.SALE_STORE_ID
|
||||
, A.SALE_STORE_NAME
|
||||
, A.SALE_STORE_LEVEL
|
||||
, A.FIRST_AGENT_ID
|
||||
, A.PARENT_SALE_AGENT_ID
|
||||
, A.DEL_FLG
|
||||
FROM M_SALES_STORE A WITH(NOLOCK)
|
||||
INNER JOIN SALES_STORE_CTE B
|
||||
ON A.PARENT_SALE_AGENT_ID = B.SALE_STORE_ID
|
||||
WHERE A.APPROVE_FLG = '2'
|
||||
)
|
||||
MERGE INTO M_SALES_STORE_ID_FOR_SAP AS A
|
||||
USING (
|
||||
SELECT
|
||||
CASE WHEN SALE_STORE_LEVEL = '1' THEN 'Y' ELSE 'N' END AS FIRST_AGENT_YN
|
||||
, SALE_STORE_ID
|
||||
, SALE_STORE_NAME
|
||||
, SALE_STORE_LEVEL
|
||||
, FIRST_AGENT_ID
|
||||
, PARENT_SALE_AGENT_ID
|
||||
, DEL_FLG
|
||||
FROM SALES_STORE_CTE
|
||||
) AS D
|
||||
ON A.SALE_STORE_ID = D.SALE_STORE_ID
|
||||
WHEN MATCHED AND D.DEL_FLG = '1' THEN
|
||||
DELETE
|
||||
WHEN MATCHED THEN
|
||||
UPDATE SET
|
||||
SAP_SALES_STORE_CD = #{sapSalesStoreCd}
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT (
|
||||
SALE_STORE_ID
|
||||
, SAP_SALES_STORE_CD
|
||||
SALE_STORE_ID
|
||||
, SAP_SALES_STORE_CD
|
||||
) VALUES (
|
||||
#{saleStoreId}
|
||||
, #{sapSalesStoreCd}
|
||||
#{saleStoreId}
|
||||
, #{sapSalesStoreCd}
|
||||
);
|
||||
</insert>
|
||||
|
||||
@ -138,8 +173,11 @@
|
||||
/* sqlid : com.interplug.qcast.user.setUserSave */
|
||||
MERGE M_USER AS A
|
||||
USING
|
||||
( SELECT #{userId} AS USER_ID ) AS D
|
||||
( SELECT #{userId} AS USER_ID
|
||||
, #{delFlg} AS DEL_FLG ) AS D
|
||||
ON (A.USER_ID = D.USER_ID)
|
||||
WHEN MATCHED AND D.DEL_FLG = '1' THEN
|
||||
DELETE
|
||||
WHEN MATCHED THEN
|
||||
UPDATE SET
|
||||
SALE_STORE_ID = #{saleStoreId}
|
||||
@ -192,9 +230,4 @@
|
||||
);
|
||||
</insert>
|
||||
|
||||
<delete id="deleteUser" parameterType="com.interplug.qcast.biz.user.dto.UserRequest" >
|
||||
/* sqlid : com.interplug.qcast.user.deleteUser */
|
||||
DELETE FROM M_USER
|
||||
WHERE USER_ID = #{userId}
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user