Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: the page status was not changed after the vote #29

Closed
zhanyeye opened this issue Dec 3, 2021 · 1 comment · Fixed by #30
Closed

bug: the page status was not changed after the vote #29

zhanyeye opened this issue Dec 3, 2021 · 1 comment · Fixed by #30
Assignees
Labels
bug Something isn't working

Comments

@zhanyeye
Copy link
Member

zhanyeye commented Dec 3, 2021

缺陷描述:

进入投票页面后,第一次投票,页面没有变化;第二次投票出现异常,但前端异常信息为null, (这里其实是后端 Duplicate entry 'v_id-u_id' for key, 重复投票的异常)

问题分析:

投票后确实发送到后端了,但是前端没有正确切换到投票状态页面,后端异常信息也没提示 ”用户已投票“

  • 前端异常log:
POST http://47.104.103.33:8089/api/vote/52 500 ()
{timestamp: "2021-12-03", status: 500, error: "Internal Server Error", message: "", path: "/api/vote/52"}
  • 后端异常log:
Duplicate entry '52-27' for key 'vote_detail.UK61vpx1woxr2v6exm8a2hxwtgb'
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [vote_detail.UK61vpx1woxr2v6exm8a2hxwtgb]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement] with root cause
java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '52-27' for key 'vote_detail.UK61vpx1woxr2v6exm8a2hxwtgb'
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:117)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1092)
........
@zhanyeye zhanyeye added the bug Something isn't working label Dec 3, 2021
@zhanyeye
Copy link
Member Author

zhanyeye commented Dec 3, 2021

@lilingj

  • hasVoted 忘记考虑投票后更新的情况

    hasVoted() {
    return this.vote_detail.myvote !== 'unvote'
    }

    <div v-if="!hasVoted">
    <div>
    <div class="choice">
    <el-radio v-model="pollform.result" class="radio" border label="true">ACCEPT [接受]</el-radio>
    </div>
    <div class="choice">
    <el-radio v-model="pollform.result" class="radio" border label="false">REJECT [拒绝]</el-radio>
    </div>
    </div>
    <div style="padding:10px">
    <el-button style="width:100%" size="medium" type="primary" @click="voting">确认提交</el-button>
    </div>
    </div>
    <div v-else>
    <div style="padding:10px">
    <el-button style="width:100%" size="medium" type="success" plain >您的投票结果: {{ vote_detail.myvote }}, 请耐心等待</el-button>
    </div>
    </div>
    </div>
    </div>

  • 原先投票之后,会取这里的值更新页面状态

    createVote(this.voteform)
    .then(res => {
    console.log(res.data)
    this.vote = res.data
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants