담당: 진성
카투사에서 커피를 먹기 위해서는 카페도 등록이 되어야 한다.

프론트반과의 의견충돌이 있었지만 일이 많아지기에 유저와 비슷하게 하는걸로 ㅇㅇ


딱 봐도 뭐 많아 보이죠 ㅎㅎ
<aside> 💡
대형패치: 시간관계상 관리자페이지를 없애기로함. 그래서 카페등록, 정보수정, 카테고리 추가, 주문현황수정, 메뉴추가, 수정 등 카페자체적으로 해야하는것은 구현하지 않기로 했다. 그렇지만 어떻게 백엔드에서 할지는 정리하는것이 좋다고 생각. 카투사에서 제일 빡센 파트였긴 했다.
</aside>
우선 XML파일을 먼저 보자
XML
<mapper namespace="com.green.ca2sa.cafe.CafeMapper">
<update id="updCafe">
UPDATE cafe
<set>
<if test="cafeName != null and cafeName != ''">
cafeName = #{cafeName}
</if>
<if test="location != null and location != ''">
,location = #{location}
</if>
<if test="tel != null and tel != ''">
,tel = #{tel}
</if>
<if test="cafePic != null and cafePic != ''">
,cafePic = #{cafePic}
</if>
<if test="closeTime != null and closeTime != ''">
,closeTime = #{closeTime}
</if>
<if test="openTime != null and openTime != ''">
,openTime = #{openTime}
</if>
<if test="longitude != null">
,longitude = #{longitude}
</if>
<if test="latitude != null">
,latitude = #{latitude}
</if>
</set>
WHERE cafeId = #{cafeId}
</update>
<insert id="insCafe" useGeneratedKeys="true" keyProperty="cafeId">
INSERT INTO cafe
SET
cafeName = #{cafeName}, location = #{location}, tel = #{tel}, cafePic = #{cafePic},
closeTime = #{closeTime}, openTime = #{openTime}, businessNumber = #{businessNumber},
latitude = #{latitude}, longitude = #{longitude} , userId = #{userId}
</insert>
<select id="selCafe">
SELECT
cafeId, cafeName, location, tel, cafePic, openTime, closeTime, latitude, longitude
FROM cafe
where cafeId = #{cafeId}
</select>
<select id="selAllCafe">
select
cafeId, cafeName, location, tel, cafePic AS pic, latitude, longitude,
ROUND(6371000 * ACOS(COS(RADIANS(#{userLatitude})) * COS(RADIANS(latitude)) * COS(RADIANS(longitude) - RADIANS(#{userLongitude})) + SIN(RADIANS(#{userLatitude})) * SIN(RADIANS(latitude)))) AS distance,
openTime, closeTime
from cafe
HAVING distance <![CDATA[ <= ]]> 1000
</select>
<select id="searchCafe">
select
a.cafeId,
cafeName, location, tel, cafePic AS pic, latitude, longitude,
ROUND(6371000 * ACOS(COS(RADIANS(#{userLatitude})) * COS(RADIANS(latitude)) * COS(RADIANS(longitude) - RADIANS(#{userLongitude})) + SIN(RADIANS(#{userLatitude})) * SIN(RADIANS(latitude)))) AS distance,
openTime, closeTime
from cafe a
left join menu b
on a.cafeId = b.cafeId
<if test="searchMenuName != null and searchMenuName != ''">
WHERE
menuName LIKE '%${searchMenuName}%'
</if>
<if test="searchCafeName != null and searchCafeName != ''">
WHERE
cafeName Like '%${searchCafeName}%'
</if>
GROUP BY a.cafeId
HAVING distance <![CDATA[<=]]> #{maxDistance}
</select>
</mapper>

카투사에 가입한 회원이라면 카페를 등록 할 수 있다. 그중에 지도로 카페를 찾아 주문할수 있게 위도, 경도값도 설정했다. → 흥미로운 부분
카페사진은 별도로 처리할 것이라서 @JsonIgnore
Mapper
int insCafe(CafeSignUpReq p);
Service