关于评价功能,每评价一条就会for循环很多条相同的数据
相关代码:
<van-action-sheet v-model:show="state.dialogVisible" :title="book.bookName"> <van-form ref="evaluationForm"> <van-cell-group inset> <van-rate v-model="form.score" color="#ffd21e" void-icon="star" style="padding: 16px" ></van-rate> <van-field v-model="form.content" name="content" placeholder="这里输入评论内容" autocomplete = "off" :rules="[{ required: true, message: '请输入评论内容' }]" /> </van-cell-group> <div style="margin: 16px;margin-bottom: 50px"> <van-button round block type="primary" @click="onSubmit('evaluationForm')"> 提交短评 </van-button> </div> </van-form> </van-action-sheet>
相关代码:
@PostMapping("/evaluate") public ResponseUtils evaluate(Long memberId,Long bookId,Integer score,String content){ ResponseUtils resp = null; try { Evaluation evaluation = evaluationService.evaluate(memberId, bookId, score, content); resp = new ResponseUtils().put("evaluation",evaluation); }catch (Exception e){ e.printStackTrace(); resp = new ResponseUtils(e.getClass().getSimpleName(),e.getMessage()); } return resp; }
相关代码:
实现类 @Override public Evaluation evaluate(Long memberId, Long bookId, Integer score, String content) { Evaluation evaluation = new Evaluation(); evaluation.setMemberId(memberId); evaluation.setBookId(bookId); evaluation.setScore(score); evaluation.setContent(content); evaluation.setCreateTime(new Date()); evaluation.setState("enable"); evaluation.setEnjoy(0); evaluationMapper.insert(evaluation); return evaluation; }
25
收起
正在回答
1回答
同学你好,1、测试同学代码是没有问题的,建议同学查看数据库中短评信息,查看是否是数据库中的问题。
2、也有可能是同学查询的问题,同学也可以将代码反馈到问答区。如下所示:将对应的代码反馈到对应的代码格式中。
祝学习愉快!
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星