Merge branch 'main' of http://192.168.0.251:3000/localnet/localhost-back.git into main
This commit is contained in:
commit
6bf491dacd
@ -36,12 +36,12 @@ public class VoteBoardController {
|
|||||||
@Member
|
@Member
|
||||||
@ParameterCheck
|
@ParameterCheck
|
||||||
@GetMapping("getVoteList")
|
@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
|
//userId
|
||||||
Long userId = AuthUtil.getUser().getId();
|
Long userId = AuthUtil.getUser().getId();
|
||||||
map.put("userId", userId);
|
map.put("userId", userId);
|
||||||
PageInfo<MapDto> VoteList = localvoteservice.getVoteList(map);
|
PageInfo<MapDto> VoteList = localvoteservice.selectVoteList(map);
|
||||||
|
|
||||||
|
|
||||||
return ApiResponse.ok(VoteList);
|
return ApiResponse.ok(VoteList);
|
||||||
@ -90,6 +90,16 @@ public class VoteBoardController {
|
|||||||
map.put("userId", userId);
|
map.put("userId", userId);
|
||||||
return ApiResponse.ok(localvoteservice.updateEndData(map));
|
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));
|
return ApiResponse.ok( worddictyservice.getWordDetail(map));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 용어집 카테고리 등록
|
* 용어 등록 - 카테고리 등록
|
||||||
* @param CMNCODNAM 용어집 등록 카테고리 이름
|
* @param WRDDICCAT 카테고리 코드값 ,WRDDICTTL 용어,WRDDICCON 내용 ,WRDDICRIK 링크 ,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 링크
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Member
|
@Member
|
||||||
@PostMapping("insertWord")
|
@PostMapping("insertWord")
|
||||||
public ApiResponse<Long> insertWord(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
public ApiResponse<Long> insertWord(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
||||||
|
|
||||||
//userId
|
//userId
|
||||||
//Long userId = AuthUtil.getUser().getId();
|
//Long userId = AuthUtil.getUser().getId();
|
||||||
//임시
|
//임시
|
||||||
|
|||||||
@ -11,6 +11,6 @@ public interface VotDetailMapper {
|
|||||||
|
|
||||||
Long insertdetail(MapDto map);
|
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);
|
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
|
@Mapper
|
||||||
public interface VotRecordMapper {
|
public interface VotRecordMapper {
|
||||||
|
|
||||||
int yesVotetotal(MapDto map);
|
int selectYesVotetotal(MapDto map);
|
||||||
|
|
||||||
Long insertCheckedNums(MapDto map);
|
Long insertCheckedNums(MapDto map);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package io.company.localhost.mapper;
|
package io.company.localhost.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import io.company.localhost.common.dto.MapDto;
|
import io.company.localhost.common.dto.MapDto;
|
||||||
@ -9,4 +11,6 @@ public interface VotchoiceMapper {
|
|||||||
|
|
||||||
void insertChoice(MapDto map);
|
void insertChoice(MapDto map);
|
||||||
|
|
||||||
|
List<MapDto> selectVoteResult(Integer locvotSeq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,9 +13,11 @@ public interface localvoteMapper {
|
|||||||
|
|
||||||
Long insertVote(MapDto map);
|
Long insertVote(MapDto map);
|
||||||
|
|
||||||
List<MapDto> getVoteList(MapDto map);
|
List<MapDto> selectVoteList(MapDto map);
|
||||||
|
|
||||||
Long updateEndData(MapDto map);
|
Long updateEndData(MapDto map);
|
||||||
|
|
||||||
|
Long updateRandomResult(MapDto selectedItem);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,19 +29,11 @@ import lombok.RequiredArgsConstructor;
|
|||||||
public class commoncodService {
|
public class commoncodService {
|
||||||
|
|
||||||
private final commoncodMapper commoncodmapper;
|
private final commoncodMapper commoncodmapper;
|
||||||
|
|
||||||
public List<MapDto> selectWordCategory() {
|
public List<MapDto> selectWordCategory() {
|
||||||
return commoncodmapper.selectWordCategory();
|
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) {
|
public List<MapDto> selectColorList(String type) {
|
||||||
return commoncodmapper.selectColorList(type);
|
return commoncodmapper.selectColorList(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,12 +2,16 @@ package io.company.localhost.service;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import io.company.localhost.common.dto.ApiResponse;
|
||||||
import io.company.localhost.common.dto.MapDto;
|
import io.company.localhost.common.dto.MapDto;
|
||||||
import io.company.localhost.mapper.VotDetailMapper;
|
import io.company.localhost.mapper.VotDetailMapper;
|
||||||
import io.company.localhost.mapper.VotMemberMapper;
|
import io.company.localhost.mapper.VotMemberMapper;
|
||||||
@ -30,7 +34,6 @@ public class localvoteService {
|
|||||||
public Long insertVote(MapDto map) {
|
public Long insertVote(MapDto map) {
|
||||||
|
|
||||||
Long result = 0L;
|
Long result = 0L;
|
||||||
|
|
||||||
int voteIdInt = 0 ;
|
int voteIdInt = 0 ;
|
||||||
if(map.get("voteId") != null) {
|
if(map.get("voteId") != null) {
|
||||||
voteIdInt = (int) map.get("voteId");
|
voteIdInt = (int) map.get("voteId");
|
||||||
@ -48,12 +51,11 @@ public class localvoteService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public PageInfo<MapDto> selectVoteList(MapDto map) {
|
||||||
public PageInfo<MapDto> getVoteList(MapDto map) {
|
|
||||||
//투표 목록조회
|
//투표 목록조회
|
||||||
int page = map.getString("page") != null ? Integer.parseInt(map.getString("page")) : 1;
|
int page = map.getString("page") != null ? Integer.parseInt(map.getString("page")) : 1;
|
||||||
PageHelper.startPage(page, 10);
|
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> resultList = new ArrayList<>();
|
||||||
|
|
||||||
List<MapDto> voteList = localvote.getList();
|
List<MapDto> voteList = localvote.getList();
|
||||||
@ -63,15 +65,19 @@ public class localvoteService {
|
|||||||
voteMap.put("localVote", vote);
|
voteMap.put("localVote", vote);
|
||||||
Integer locvotSeq = (Integer) vote.get("LOCVOTSEQ");
|
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("voteDetails", voteDetails);
|
||||||
voteMap.put("voteMembers", voteMembers);
|
voteMap.put("voteMembers", voteMembers);
|
||||||
|
voteMap.put("voteResult", voteResult);
|
||||||
|
|
||||||
map.put("id",locvotSeq);
|
map.put("id",locvotSeq);
|
||||||
//투표 여부
|
//투표 여부
|
||||||
int yesVotetotal = votrecordmapper.yesVotetotal(map);
|
int yesVotetotal = votrecordmapper.selectYesVotetotal(map);
|
||||||
voteMap.put("yesVotetotal", yesVotetotal);
|
voteMap.put("yesVotetotal", yesVotetotal);
|
||||||
|
|
||||||
resultList.add(voteMap);
|
resultList.add(voteMap);
|
||||||
@ -94,5 +100,23 @@ public class localvoteService {
|
|||||||
return localvotemapper.updateEndData(map);
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import io.company.localhost.common.dto.MapDto;
|
import io.company.localhost.common.dto.MapDto;
|
||||||
|
import io.company.localhost.mapper.commoncodMapper;
|
||||||
import io.company.localhost.mapper.worddictyMapper;
|
import io.company.localhost.mapper.worddictyMapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@ -29,6 +30,8 @@ import lombok.RequiredArgsConstructor;
|
|||||||
public class worddictyService {
|
public class worddictyService {
|
||||||
|
|
||||||
private final worddictyMapper worddictymapper;
|
private final worddictyMapper worddictymapper;
|
||||||
|
private final commoncodMapper commoncodmapper;
|
||||||
|
|
||||||
|
|
||||||
public List<MapDto> getWordList(MapDto map) {
|
public List<MapDto> getWordList(MapDto map) {
|
||||||
List<MapDto> wordList = worddictymapper.getWordList(map);
|
List<MapDto> wordList = worddictymapper.getWordList(map);
|
||||||
@ -59,6 +62,10 @@ public class worddictyService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long insertWord(MapDto map) {
|
public Long insertWord(MapDto map) {
|
||||||
|
|
||||||
|
if (map.containsKey("CMNCODNAM") && map.get("CMNCODNAM") != null) {
|
||||||
|
commoncodmapper.insertCategory(map);
|
||||||
|
}
|
||||||
return worddictymapper.insertWord(map);
|
return worddictymapper.insertWord(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<select id="getVoteDetails" parameterType="int" >
|
<select id="selectVoteDetails" parameterType="int" >
|
||||||
select
|
select
|
||||||
*
|
*
|
||||||
from
|
from
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
(#{voteId}, #{user.id})
|
(#{voteId}, #{user.id})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<select id="getVoteMember" parameterType="int" >
|
<select id="selectVoteMember" parameterType="int" >
|
||||||
SELECT
|
SELECT
|
||||||
a.*,
|
a.*,
|
||||||
n.*,
|
n.*,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!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">
|
<mapper namespace="io.company.localhost.mapper.VotRecordMapper">
|
||||||
<select id="yesVotetotal" parameterType="map">
|
<select id="selectYesVotetotal" parameterType="map">
|
||||||
select count(*) as yesvote
|
select count(*) as yesvote
|
||||||
from
|
from
|
||||||
votrecord
|
votrecord
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!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">
|
<mapper namespace="io.company.localhost.mapper.VotchoiceMapper">
|
||||||
|
<insert id="insertChoice" parameterType="map">
|
||||||
<insert id="insertChoice" parameterType="map">
|
|
||||||
INSERT INTO votchoice
|
INSERT INTO votchoice
|
||||||
(
|
(
|
||||||
LOCVOTSEQ
|
LOCVOTSEQ
|
||||||
@ -16,5 +15,21 @@
|
|||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</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>
|
</mapper>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
,#{votemMltiIs}
|
,#{votemMltiIs}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<select id="getVoteList" parameterType="map">
|
<select id="selectVoteList" parameterType="map">
|
||||||
select
|
select
|
||||||
a.*
|
a.*
|
||||||
,DATE_FORMAT(a.LOCVOTRDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTRDT
|
,DATE_FORMAT(a.LOCVOTRDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTRDT
|
||||||
@ -49,4 +49,11 @@
|
|||||||
LOCVOTDDT = now()
|
LOCVOTDDT = now()
|
||||||
WHERE LOCVOTSEQ = #{endVoteId}
|
WHERE LOCVOTSEQ = #{endVoteId}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateRandomResult" parameterType="map">
|
||||||
|
UPDATE
|
||||||
|
localvote
|
||||||
|
SET
|
||||||
|
LOCVOTRES = #{LOCVOTCON}
|
||||||
|
WHERE LOCVOTSEQ = #{voteid}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user