투표수정
This commit is contained in:
parent
6198078447
commit
f119c4724a
@ -37,15 +37,12 @@ public class VoteBoardController {
|
|||||||
@ParameterCheck
|
@ParameterCheck
|
||||||
@GetMapping("getVoteList")
|
@GetMapping("getVoteList")
|
||||||
public ApiResponse<PageInfo<MapDto>> selectVoteList(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
public ApiResponse<PageInfo<MapDto>> selectVoteList(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
||||||
|
|
||||||
//userId
|
|
||||||
Long userId = AuthUtil.getUser().getId();
|
Long userId = AuthUtil.getUser().getId();
|
||||||
map.put("userId", userId);
|
map.put("userId", userId);
|
||||||
PageInfo<MapDto> VoteList = localvoteservice.selectVoteList(map);
|
PageInfo<MapDto> VoteList = localvoteservice.selectVoteList(map);
|
||||||
|
|
||||||
|
|
||||||
return ApiResponse.ok(VoteList);
|
return ApiResponse.ok(VoteList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 투표 등록
|
* 투표 등록
|
||||||
@ -55,14 +52,11 @@ public class VoteBoardController {
|
|||||||
@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
|
|
||||||
Long userId = AuthUtil.getUser().getId();
|
Long userId = AuthUtil.getUser().getId();
|
||||||
map.put("userId", userId);
|
map.put("userId", userId);
|
||||||
Long result = localvoteservice.insertVote(map);
|
Long result = localvoteservice.insertVote(map);
|
||||||
return ApiResponse.ok(result);
|
return ApiResponse.ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 투표 선택
|
* 투표 선택
|
||||||
* @param title 제목 ,endDate 종료날짜 ,itemList 항목리스트(항목,링크) ,addvoteIs 항목추가여부, votemMltiIs 다중투표 허용여부
|
* @param title 제목 ,endDate 종료날짜 ,itemList 항목리스트(항목,링크) ,addvoteIs 항목추가여부, votemMltiIs 다중투표 허용여부
|
||||||
@ -71,12 +65,10 @@ public class VoteBoardController {
|
|||||||
@Member
|
@Member
|
||||||
@PostMapping("insertCheckedNums")
|
@PostMapping("insertCheckedNums")
|
||||||
public ApiResponse<Long> insertCheckedNums(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
public ApiResponse<Long> insertCheckedNums(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
||||||
|
|
||||||
Long userId = AuthUtil.getUser().getId();
|
Long userId = AuthUtil.getUser().getId();
|
||||||
map.put("userId", userId);
|
map.put("userId", userId);
|
||||||
return ApiResponse.ok(localvoteservice.insertCheckedNums(map));
|
return ApiResponse.ok(localvoteservice.insertCheckedNums(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 투표 종료
|
* 투표 종료
|
||||||
* @param endVoteId 투표번호
|
* @param endVoteId 투표번호
|
||||||
@ -85,21 +77,26 @@ public class VoteBoardController {
|
|||||||
@Member
|
@Member
|
||||||
@PatchMapping("updateEndData")
|
@PatchMapping("updateEndData")
|
||||||
public ApiResponse<Long> updateEndData(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
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));
|
return ApiResponse.ok(localvoteservice.updateEndData(map));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 투표 삭제
|
||||||
|
* @param endVoteId 투표번호
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Member
|
||||||
|
@PatchMapping("updateDeleteData")
|
||||||
|
public ApiResponse<Long> updateDeleteData(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) {
|
||||||
|
return ApiResponse.ok(localvoteservice.updateDeleteData(map));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 투표 랜덤뽑기
|
* 투표 랜덤뽑기
|
||||||
* @param randomList 랜덤리스트 ,voteid 투표 번호
|
* @param randomList 랜덤리스트 ,voteid 투표 번호
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Member
|
@Member
|
||||||
@PostMapping("randomList")
|
@PostMapping("randomList")
|
||||||
public ApiResponse<Long> randomList(@ReqMap MapDto map) {
|
public ApiResponse<Long> randomList(@ReqMap MapDto map) {
|
||||||
return ApiResponse.ok(localvoteservice.updateRandomResult(map));
|
return ApiResponse.ok(localvoteservice.updateRandomResult(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,5 +19,7 @@ public interface localvoteMapper {
|
|||||||
|
|
||||||
Long updateRandomResult(MapDto selectedItem);
|
Long updateRandomResult(MapDto selectedItem);
|
||||||
|
|
||||||
|
Long updateDeleteData(MapDto map);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
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.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;
|
||||||
@ -51,6 +49,7 @@ public class localvoteService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageInfo<MapDto> selectVoteList(MapDto map) {
|
public PageInfo<MapDto> selectVoteList(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;
|
||||||
@ -66,6 +65,7 @@ public class localvoteService {
|
|||||||
Integer locvotSeq = (Integer) vote.get("LOCVOTSEQ");
|
Integer locvotSeq = (Integer) vote.get("LOCVOTSEQ");
|
||||||
//투표 항목조회
|
//투표 항목조회
|
||||||
List<MapDto> voteDetails = votdetailmapper.selectVoteDetails(locvotSeq);
|
List<MapDto> voteDetails = votdetailmapper.selectVoteDetails(locvotSeq);
|
||||||
|
|
||||||
//투표 가능 멤버 조회
|
//투표 가능 멤버 조회
|
||||||
List<MapDto> voteMembers = votmembermapper.selectVoteMember(locvotSeq);
|
List<MapDto> voteMembers = votmembermapper.selectVoteMember(locvotSeq);
|
||||||
//투표 결과 조회
|
//투표 결과 조회
|
||||||
@ -119,4 +119,8 @@ public class localvoteService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long updateDeleteData(MapDto map) {
|
||||||
|
return localvotemapper.updateDeleteData(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,19 @@
|
|||||||
<?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.localvoteMapper">
|
<mapper namespace="io.company.localhost.mapper.localvoteMapper">
|
||||||
|
<sql id="searchConditions">
|
||||||
|
<if test="voteset != null and voteset != ''">
|
||||||
|
<choose>
|
||||||
|
<when test='voteset == "1"'>
|
||||||
|
AND a.LOCVOTDDT IS NOT NULL
|
||||||
|
</when>
|
||||||
|
<when test='voteset == "2"'>
|
||||||
|
AND a.LOCVOTDDT IS NULL
|
||||||
|
AND a.LOCVOTDEL IS NULL
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
<insert id="insertVote" parameterType="map" useGeneratedKeys="true" keyProperty="voteId">
|
<insert id="insertVote" parameterType="map" useGeneratedKeys="true" keyProperty="voteId">
|
||||||
insert into localvote
|
insert into localvote
|
||||||
(
|
(
|
||||||
@ -23,24 +35,40 @@
|
|||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<select id="selectVoteList" parameterType="map">
|
<select id="selectVoteList" parameterType="map">
|
||||||
select
|
SELECT * FROM (
|
||||||
a.*
|
SELECT
|
||||||
,DATE_FORMAT(a.LOCVOTRDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTRDT
|
a.*,
|
||||||
,DATE_FORMAT(a.LOCVOTEDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTEDT
|
DATE_FORMAT(a.LOCVOTRDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTRDT,
|
||||||
,b.*
|
DATE_FORMAT(a.LOCVOTEDT, '%Y-%m-%d %H:%i') AS formatted_LOCVOTEDT,
|
||||||
,c.CMNCODNAM usercolor
|
b.*,
|
||||||
from
|
c.CMNCODNAM AS usercolor,
|
||||||
localvote a
|
CASE
|
||||||
LEFT JOIN
|
WHEN EXISTS (
|
||||||
netmember b
|
SELECT 1
|
||||||
on
|
FROM votrecord v
|
||||||
a.LOCVOTREG = b.MEMBERSEQ
|
WHERE v.LOCVOTSEQ = a.LOCVOTSEQ
|
||||||
left join
|
AND v.VOTRECMEM = #{userId}
|
||||||
commoncod c
|
) THEN 'Y'
|
||||||
on
|
ELSE 'N'
|
||||||
b.MEMBERCOL = c.CMNCODVAL
|
END AS myvoted
|
||||||
order by
|
FROM
|
||||||
a.LOCVOTRDT desc
|
localvote a
|
||||||
|
LEFT JOIN
|
||||||
|
netmember b ON a.LOCVOTREG = b.MEMBERSEQ
|
||||||
|
LEFT JOIN
|
||||||
|
commoncod c ON b.MEMBERCOL = c.CMNCODVAL
|
||||||
|
WHERE 1=1
|
||||||
|
<include refid="searchConditions"/>
|
||||||
|
) AS subquery
|
||||||
|
WHERE 1=1
|
||||||
|
<if test="myVote != null and myVote != ''">
|
||||||
|
<choose>
|
||||||
|
<when test='myVote == "1"'>
|
||||||
|
AND myvoted = 'Y'
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
ORDER BY formatted_LOCVOTRDT DESC
|
||||||
</select>
|
</select>
|
||||||
<update id="updateEndData" parameterType="map">
|
<update id="updateEndData" parameterType="map">
|
||||||
UPDATE
|
UPDATE
|
||||||
@ -49,6 +77,13 @@
|
|||||||
LOCVOTDDT = now()
|
LOCVOTDDT = now()
|
||||||
WHERE LOCVOTSEQ = #{endVoteId}
|
WHERE LOCVOTSEQ = #{endVoteId}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateDeleteData" parameterType="map">
|
||||||
|
UPDATE
|
||||||
|
localvote
|
||||||
|
SET
|
||||||
|
LOCVOTDEL = now()
|
||||||
|
WHERE LOCVOTSEQ = #{deleteVoteId}
|
||||||
|
</update>
|
||||||
<update id="updateRandomResult" parameterType="map">
|
<update id="updateRandomResult" parameterType="map">
|
||||||
UPDATE
|
UPDATE
|
||||||
localvote
|
localvote
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user