수정
This commit is contained in:
parent
ab66477be2
commit
972c18d1cb
@ -36,12 +36,12 @@ public class VoteBoardController {
|
||||
@Member
|
||||
@ParameterCheck
|
||||
@GetMapping("getVoteList")
|
||||
public ApiResponse<PageInfo<MapDto>> getVoteList(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
||||
public ApiResponse<PageInfo<MapDto>> selectVoteList(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
||||
|
||||
//userId
|
||||
Long userId = AuthUtil.getUser().getId();
|
||||
map.put("userId", userId);
|
||||
PageInfo<MapDto> VoteList = localvoteservice.getVoteList(map);
|
||||
PageInfo<MapDto> VoteList = localvoteservice.selectVoteList(map);
|
||||
|
||||
|
||||
return ApiResponse.ok(VoteList);
|
||||
@ -90,6 +90,16 @@ public class VoteBoardController {
|
||||
map.put("userId", userId);
|
||||
return ApiResponse.ok(localvoteservice.updateEndData(map));
|
||||
}
|
||||
/**
|
||||
* 투표 랜덤뽑기
|
||||
* @param randomList 랜덤리스트 ,voteid 투표 번호
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Member
|
||||
@PostMapping("randomList")
|
||||
public ApiResponse<Long> randomList(@ReqMap MapDto map) {
|
||||
return ApiResponse.ok(localvoteservice.updateRandomResult(map));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -88,29 +88,13 @@ public class worddictController {
|
||||
return ApiResponse.ok( worddictyservice.getWordDetail(map));
|
||||
}
|
||||
/**
|
||||
* 용어집 카테고리 등록
|
||||
* @param CMNCODNAM 용어집 등록 카테고리 이름
|
||||
* @return
|
||||
*/
|
||||
@Member
|
||||
@ParameterCheck
|
||||
@PostMapping("insertCategory")
|
||||
public ApiResponse<Long> insertCategory(@ReqMap MapDto map) {
|
||||
Long result = commoncodservice.insertCategory(map);
|
||||
if(result == -1) {
|
||||
return ApiResponse.okMessage("이미 존재하는 카테고리명입니다.");
|
||||
}
|
||||
return ApiResponse.ok(result);
|
||||
}
|
||||
/**
|
||||
* 용어 등록
|
||||
* @param WRDDICCAT 카테고리 코드값 ,WRDDICTTL 용어,WRDDICCON 내용 ,WRDDICRIK 링크
|
||||
* 용어 등록 - 카테고리 등록
|
||||
* @param WRDDICCAT 카테고리 코드값 ,WRDDICTTL 용어,WRDDICCON 내용 ,WRDDICRIK 링크 ,CMNCODNAM 추가 등록 카테고리 이름
|
||||
* @return
|
||||
*/
|
||||
@Member
|
||||
@PostMapping("insertWord")
|
||||
public ApiResponse<Long> insertWord(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
||||
|
||||
//userId
|
||||
//Long userId = AuthUtil.getUser().getId();
|
||||
//임시
|
||||
|
||||
@ -11,6 +11,6 @@ public interface VotDetailMapper {
|
||||
|
||||
Long insertdetail(MapDto map);
|
||||
|
||||
List<MapDto> getVoteDetails(int locvotSeq);
|
||||
List<MapDto> selectVoteDetails(int locvotSeq);
|
||||
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ public interface VotMemberMapper {
|
||||
|
||||
void insertmem(MapDto map);
|
||||
|
||||
List<MapDto> getVoteMember(Integer locvotSeq);
|
||||
List<MapDto> selectVoteMember(Integer locvotSeq);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import io.company.localhost.common.dto.MapDto;
|
||||
@Mapper
|
||||
public interface VotRecordMapper {
|
||||
|
||||
int yesVotetotal(MapDto map);
|
||||
int selectYesVotetotal(MapDto map);
|
||||
|
||||
Long insertCheckedNums(MapDto map);
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package io.company.localhost.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import io.company.localhost.common.dto.MapDto;
|
||||
@ -9,4 +11,6 @@ public interface VotchoiceMapper {
|
||||
|
||||
void insertChoice(MapDto map);
|
||||
|
||||
List<MapDto> selectVoteResult(Integer locvotSeq);
|
||||
|
||||
}
|
||||
|
||||
@ -13,9 +13,11 @@ public interface localvoteMapper {
|
||||
|
||||
Long insertVote(MapDto map);
|
||||
|
||||
List<MapDto> getVoteList(MapDto map);
|
||||
List<MapDto> selectVoteList(MapDto map);
|
||||
|
||||
Long updateEndData(MapDto map);
|
||||
|
||||
Long updateRandomResult(MapDto selectedItem);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -33,14 +33,6 @@ public class commoncodService {
|
||||
return commoncodmapper.selectWordCategory();
|
||||
}
|
||||
|
||||
public Long insertCategory(MapDto map) {
|
||||
Long count = commoncodmapper.selectcheckCategoryExists(map);
|
||||
if(count > 0) {
|
||||
return -1L;
|
||||
}
|
||||
return commoncodmapper.insertCategory(map);
|
||||
}
|
||||
|
||||
public List<MapDto> selectColorList(String type) {
|
||||
return commoncodmapper.selectColorList(type);
|
||||
}
|
||||
|
||||
@ -2,12 +2,16 @@ package io.company.localhost.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import io.company.localhost.common.dto.ApiResponse;
|
||||
import io.company.localhost.common.dto.MapDto;
|
||||
import io.company.localhost.mapper.VotDetailMapper;
|
||||
import io.company.localhost.mapper.VotMemberMapper;
|
||||
@ -30,7 +34,6 @@ public class localvoteService {
|
||||
public Long insertVote(MapDto map) {
|
||||
|
||||
Long result = 0L;
|
||||
|
||||
int voteIdInt = 0 ;
|
||||
if(map.get("voteId") != null) {
|
||||
voteIdInt = (int) map.get("voteId");
|
||||
@ -48,12 +51,11 @@ public class localvoteService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public PageInfo<MapDto> getVoteList(MapDto map) {
|
||||
public PageInfo<MapDto> selectVoteList(MapDto map) {
|
||||
//투표 목록조회
|
||||
int page = map.getString("page") != null ? Integer.parseInt(map.getString("page")) : 1;
|
||||
PageHelper.startPage(page, 10);
|
||||
PageInfo<MapDto> localvote = PageUtil.redefineNavigation(new PageInfo<>(localvotemapper.getVoteList(map),10));
|
||||
PageInfo<MapDto> localvote = PageUtil.redefineNavigation(new PageInfo<>(localvotemapper.selectVoteList(map),10));
|
||||
List<MapDto> resultList = new ArrayList<>();
|
||||
|
||||
List<MapDto> voteList = localvote.getList();
|
||||
@ -63,15 +65,19 @@ public class localvoteService {
|
||||
voteMap.put("localVote", vote);
|
||||
Integer locvotSeq = (Integer) vote.get("LOCVOTSEQ");
|
||||
//투표 항목조회
|
||||
List<MapDto> voteDetails = votdetailmapper.getVoteDetails(locvotSeq);
|
||||
List<MapDto> voteDetails = votdetailmapper.selectVoteDetails(locvotSeq);
|
||||
//투표 가능 멤버 조회
|
||||
List<MapDto> voteMembers = votmembermapper.getVoteMember(locvotSeq);
|
||||
List<MapDto> voteMembers = votmembermapper.selectVoteMember(locvotSeq);
|
||||
//투표 결과 조회
|
||||
List<MapDto> voteResult = votchoicemapper.selectVoteResult(locvotSeq);
|
||||
|
||||
voteMap.put("voteDetails", voteDetails);
|
||||
voteMap.put("voteMembers", voteMembers);
|
||||
voteMap.put("voteResult", voteResult);
|
||||
|
||||
map.put("id",locvotSeq);
|
||||
//투표 여부
|
||||
int yesVotetotal = votrecordmapper.yesVotetotal(map);
|
||||
int yesVotetotal = votrecordmapper.selectYesVotetotal(map);
|
||||
voteMap.put("yesVotetotal", yesVotetotal);
|
||||
|
||||
resultList.add(voteMap);
|
||||
@ -94,5 +100,23 @@ public class localvoteService {
|
||||
return localvotemapper.updateEndData(map);
|
||||
}
|
||||
|
||||
public Long updateRandomResult(MapDto map) {
|
||||
|
||||
Long result = 0L;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Object randomListObj = map.get("randomList");
|
||||
|
||||
if (randomListObj instanceof List<?>) {
|
||||
List<?> rawList = (List<?>) randomListObj;
|
||||
if (!rawList.isEmpty()) {
|
||||
//랜덤뽑기
|
||||
Object selectedObj = rawList.get(new Random().nextInt(rawList.size()));
|
||||
MapDto selectedItem = objectMapper.convertValue(selectedObj, MapDto.class);
|
||||
selectedItem.put("voteid", map.get("voteid"));
|
||||
//투표결과 저장
|
||||
result = localvotemapper.updateRandomResult(selectedItem);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import io.company.localhost.common.dto.MapDto;
|
||||
import io.company.localhost.mapper.commoncodMapper;
|
||||
import io.company.localhost.mapper.worddictyMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@ -29,6 +30,8 @@ import lombok.RequiredArgsConstructor;
|
||||
public class worddictyService {
|
||||
|
||||
private final worddictyMapper worddictymapper;
|
||||
private final commoncodMapper commoncodmapper;
|
||||
|
||||
|
||||
public List<MapDto> getWordList(MapDto map) {
|
||||
List<MapDto> wordList = worddictymapper.getWordList(map);
|
||||
@ -59,6 +62,10 @@ public class worddictyService {
|
||||
}
|
||||
|
||||
public Long insertWord(MapDto map) {
|
||||
|
||||
if (map.containsKey("CMNCODNAM") && map.get("CMNCODNAM") != null) {
|
||||
commoncodmapper.insertCategory(map);
|
||||
}
|
||||
return worddictymapper.insertWord(map);
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="getVoteDetails" parameterType="int" >
|
||||
<select id="selectVoteDetails" parameterType="int" >
|
||||
select
|
||||
*
|
||||
from
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
(#{voteId}, #{user.id})
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="getVoteMember" parameterType="int" >
|
||||
<select id="selectVoteMember" parameterType="int" >
|
||||
SELECT
|
||||
a.*,
|
||||
n.*,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?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="io.company.localhost.mapper.VotRecordMapper">
|
||||
<select id="yesVotetotal" parameterType="map">
|
||||
<select id="selectYesVotetotal" parameterType="map">
|
||||
select count(*) as yesvote
|
||||
from
|
||||
votrecord
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
<?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="io.company.localhost.mapper.VotchoiceMapper">
|
||||
|
||||
<insert id="insertChoice" parameterType="map">
|
||||
<insert id="insertChoice" parameterType="map">
|
||||
INSERT INTO votchoice
|
||||
(
|
||||
LOCVOTSEQ
|
||||
@ -16,5 +15,21 @@
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="selectVoteResult" parameterType="int">
|
||||
SELECT
|
||||
c.VOTDETSEQ,
|
||||
v.LOCVOTCON,
|
||||
COUNT(v.VOTDETSEQ) AS VOTE_COUNT
|
||||
FROM
|
||||
votchoice c
|
||||
LEFT JOIN
|
||||
votdetail v ON c.LOCVOTSEQ = v.LOCVOTSEQ AND c.VOTDETSEQ = v.VOTDETSEQ
|
||||
WHERE
|
||||
c.LOCVOTSEQ = #{LOCVOTSEQ}
|
||||
GROUP BY
|
||||
c.LOCVOTSEQ, c.VOTDETSEQ
|
||||
ORDER BY
|
||||
VOTE_COUNT DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
,#{votemMltiIs}
|
||||
)
|
||||
</insert>
|
||||
<select id="getVoteList" parameterType="map">
|
||||
<select id="selectVoteList" parameterType="map">
|
||||
select
|
||||
a.*
|
||||
,DATE_FORMAT(a.LOCVOTRDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTRDT
|
||||
@ -49,4 +49,11 @@
|
||||
LOCVOTDDT = now()
|
||||
WHERE LOCVOTSEQ = #{endVoteId}
|
||||
</update>
|
||||
<update id="updateRandomResult" parameterType="map">
|
||||
UPDATE
|
||||
localvote
|
||||
SET
|
||||
LOCVOTRES = #{LOCVOTCON}
|
||||
WHERE LOCVOTSEQ = #{voteid}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user