This commit is contained in:
khj0414 2025-02-20 11:16:48 +09:00
parent 96c5a349c7
commit 68b8a26322
14 changed files with 113 additions and 25 deletions

View File

@ -2,6 +2,7 @@ package io.company.localhost.controller.api;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -76,5 +77,19 @@ public class VoteBoardController {
return ApiResponse.ok(localvoteservice.insertCheckedNums(map));
}
/**
* 투표 종료
* @param endVoteId 투표번호
* @return
*/
@Member
@PatchMapping("updateEndData")
public ApiResponse<Long> updateEndData(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
Long userId = AuthUtil.getUser().getId();
map.put("userId", userId);
return ApiResponse.ok(localvoteservice.updateEndData(map));
}
}

View File

@ -14,8 +14,10 @@
*************************************************************/
package io.company.localhost.controller.api;
//import java.util.Arrays;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
@ -96,6 +98,9 @@ public class worddictController {
@PostMapping("insertCategory")
public ApiResponse<Long> insertCategory(@ReqMap MapDto map) {
Long result = commoncodservice.insertCategory(map);
if(result == -1) {
return ApiResponse.okMessage("이미 존재하는 카테고리명입니다.");
}
return ApiResponse.ok(result);
}
/**
@ -135,4 +140,16 @@ public class worddictController {
return ApiResponse.ok(result);
}
/**
* 용어 삭제
* @param idList 게시판 아이디 리스트
* @return
*/
@Member
@PatchMapping("deleteword")
public ApiResponse<Long> updateword(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
return ApiResponse.ok(worddictyservice.updateword(map));
}
}

View File

@ -50,7 +50,7 @@ public class ImageUploadController {
*/
@ParameterCheck
@PostMapping("/upload")
public ApiResponse<String> uploadImage(@RequestParam("file") MultipartFile file) throws IOException {
public ApiResponse<String> uploadImage(@ReqMap MultipartFile file) throws IOException {
if (file.isEmpty()) {
return ApiResponse.error(HttpStatus.BAD_REQUEST, "File is empty");

View File

@ -40,4 +40,6 @@ public interface commoncodMapper {
List<MapDto> selectYearCategories();
List<MapDto> selectCategories();
Long selectcheckCategoryExists(MapDto map);
}

View File

@ -15,5 +15,7 @@ public interface localvoteMapper {
List<MapDto> getVoteList(MapDto map);
Long updateEndData(MapDto map);
}

View File

@ -33,6 +33,8 @@ public interface worddictyMapper {
int getTotal(MapDto map);
Long updateword(MapDto map);

View File

@ -19,6 +19,7 @@ import java.util.List;
import org.springframework.stereotype.Service;
import io.company.localhost.common.dto.MapDto;
import io.company.localhost.common.exception.NotFoundHandler;
import io.company.localhost.mapper.commoncodMapper;
import lombok.RequiredArgsConstructor;
@ -33,6 +34,10 @@ public class commoncodService {
}
public Long insertCategory(MapDto map) {
Long count = commoncodmapper.selectcheckCategoryExists(map);
if(count > 0) {
return -1L;
}
return commoncodmapper.insertCategory(map);
}

View File

@ -31,7 +31,10 @@ public class localvoteService {
Long result = 0L;
int voteIdInt = (int) map.get("voteId");
int voteIdInt = 0 ;
if(map.get("voteId") != null) {
voteIdInt = (int) map.get("voteId");
}
if(voteIdInt != 0) {
result = votdetailmapper.insertdetail(map);
}else {
@ -87,5 +90,9 @@ public class localvoteService {
return result;
}
public Long updateEndData(MapDto map) {
return localvotemapper.updateEndData(map);
}
}

View File

@ -58,8 +58,6 @@ public class worddictyService {
return processedList;
}
public Long insertWord(MapDto map) {
return worddictymapper.insertWord(map);
}
@ -77,6 +75,11 @@ public class worddictyService {
}
public Long updateword(MapDto map) {
return worddictymapper.updateword(map);
}

View File

@ -12,11 +12,30 @@
</foreach>
</insert>
<select id="getVoteMember" parameterType="int" >
select
*
from
votdetail
SELECT
a.*,
n.*,
c.CMNCODNAM AS usercolor,
CASE
WHEN v.LOCVOTSEQ IS NOT NULL THEN 1
ELSE 0
END AS voted
FROM
votmember a
LEFT JOIN
netmember n
ON a.MEMBERSEQ = n.MEMBERSEQ
LEFT JOIN
commoncod c
ON
n.MEMBERCOL = c.CMNCODVAL
LEFT JOIN
votrecord v
ON
a.LOCVOTSEQ = v.LOCVOTSEQ
AND
a.MEMBERSEQ = v.VOTRECMEM
where
LOCVOTSEQ = #{LOCVOTSEQ}
a.locvotseq = #{LOCVOTSEQ}
</select>
</mapper>

View File

@ -23,20 +23,5 @@
,#{userId}
,now()
)
</insert>
<!-- <insert id="insertCheckedNums" parameterType="map">
INSERT INTO votrecord
(
LOCVOTSEQ
,VOTRECMEM
,VOTRECRDT
)
VALUES
<foreach collection="checkedList" item="item" separator=",">
(#{item.LOCVOTSEQ}, #{userId} ,now())
</foreach>
</insert>-->
</mapper>

View File

@ -112,5 +112,12 @@
AND
CMNCODODR != 0
</select>
<select id="selectcheckCategoryExists" parameterType="Map" resultType="Long">
select
count(*) checkCategory
from
commoncod
where
CMNCODNAM = #{CMNCODNAM}
</select>
</mapper>

View File

@ -28,11 +28,25 @@
,DATE_FORMAT(a.LOCVOTRDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTRDT
,DATE_FORMAT(a.LOCVOTEDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTEDT
,b.*
,c.CMNCODNAM usercolor
from
localvote a
LEFT JOIN
netmember b
on
a.LOCVOTREG = b.MEMBERSEQ
left join
commoncod c
on
b.MEMBERCOL = c.CMNCODVAL
order by
a.LOCVOTRDT desc
</select>
<update id="updateEndData" parameterType="map">
UPDATE
localvote
SET
LOCVOTDDT = now()
WHERE LOCVOTSEQ = #{endVoteId}
</update>
</mapper>

View File

@ -236,4 +236,14 @@
where
WRDDICSEQ = #{WRDDICSEQ}
</select>
<update id="updateword" parameterType="map">
UPDATE
worddicty
SET
WRDDICEDT = now()
WHERE WRDDICSEQ IN
<foreach item="id" collection="idList" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>