mirror of
https://gitee.com/gz-yami/mall4j.git
synced 2026-03-22 09:17:16 +08:00
评论信息接口修改
This commit is contained in:
@@ -43,7 +43,7 @@ public class ProdCommController {
|
||||
@GetMapping("/prodCommData")
|
||||
@ApiOperation(value = "返回商品评论数据(好评率 好评数量 中评数 差评数)", notes = "根据商品id获取")
|
||||
public ResponseEntity<ProdCommDataDto> getProdCommData(Long prodId) {
|
||||
return ResponseEntity.ok(prodCommService.getProdCommDataByProdId(prodId, SecurityUtils.getUser().getUserId()));
|
||||
return ResponseEntity.ok(prodCommService.getProdCommDataByProdId(prodId));
|
||||
}
|
||||
|
||||
@GetMapping("/prodCommPageByUser")
|
||||
@@ -59,7 +59,7 @@ public class ProdCommController {
|
||||
@ApiImplicitParam(name = "evaluate", value = "-1或null 全部,0好评 1中评 2差评 3有图", required = true, dataType = "Long"),
|
||||
})
|
||||
public ResponseEntity<IPage<ProdCommDto>> getProdCommPageByProdId(PageParam page, Long prodId, Integer evaluate) {
|
||||
return ResponseEntity.ok(prodCommService.getProdCommDtoPageByProdId(page, prodId, evaluate, SecurityUtils.getUser().getUserId()));
|
||||
return ResponseEntity.ok(prodCommService.getProdCommDtoPageByProdId(page, prodId, evaluate));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.yami.shop.common.util.PrincipalUtil;
|
||||
import com.yami.shop.dao.UserMapper;
|
||||
import com.yami.shop.security.dao.AppConnectMapper;
|
||||
import com.yami.shop.security.enums.App;
|
||||
import com.yami.shop.security.exception.UsernameNotFoundException;
|
||||
import com.yami.shop.security.exception.UsernameNotFoundExceptionBase;
|
||||
import com.yami.shop.security.model.AppConnect;
|
||||
import com.yami.shop.security.service.YamiUser;
|
||||
@@ -135,7 +136,7 @@ public class YamiUserServiceImpl implements YamiUserDetailsService {
|
||||
public YamiUser loadUserByUserMail(String userMail, String loginPassword) {
|
||||
User user = userMapper.getUserByUserMail(userMail);
|
||||
if (user == null) {
|
||||
throw new YamiShopBindException("用户不存在");
|
||||
throw new UsernameNotFoundException("用户不存在");
|
||||
}
|
||||
String paramPassword = passwordEncoder.encode(loginPassword);
|
||||
if (!passwordEncoder.matches(loginPassword, user.getLoginPassword())) {
|
||||
|
||||
@@ -20,11 +20,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ProdCommMapper extends BaseMapper<ProdComm> {
|
||||
ProdCommDataDto getProdCommDataByProdId(@Param("prodId") Long prodId, @Param("userId") String userId);
|
||||
ProdCommDataDto getProdCommDataByProdId(@Param("prodId") Long prodId);
|
||||
|
||||
IPage<ProdCommDto> getProdCommDtoPageByProdId(@Param("page") Page page, @Param("prodId") Long prodId, @Param("evaluate") Integer evaluate, @Param("userId") String userId);
|
||||
IPage<ProdCommDto> getProdCommDtoPageByProdId(@Param("page") Page page, @Param("prodId") Long prodId, @Param("evaluate") Integer evaluate);
|
||||
|
||||
IPage<ProdCommDto> getProdCommDtoPageByUserId(Page page, @Param("userId") String userId);
|
||||
|
||||
IPage<ProdComm> getProdCommPage(Page page, @Param("prodComm") ProdComm prodComm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import java.util.List;
|
||||
* @date 2019-04-19 10:43:57
|
||||
*/
|
||||
public interface ProdCommService extends IService<ProdComm> {
|
||||
ProdCommDataDto getProdCommDataByProdId(Long prodId, String userId);
|
||||
ProdCommDataDto getProdCommDataByProdId(Long prodId);
|
||||
|
||||
IPage<ProdCommDto> getProdCommDtoPageByUserId(Page page,String userId);
|
||||
|
||||
IPage<ProdCommDto> getProdCommDtoPageByProdId(Page page, Long prodId, Integer evaluate, String userId);
|
||||
IPage<ProdCommDto> getProdCommDtoPageByProdId(Page page, Long prodId, Integer evaluate);
|
||||
|
||||
IPage<ProdComm> getProdCommPage(Page page,ProdComm prodComm);
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ public class ProdCommServiceImpl extends ServiceImpl<ProdCommMapper, ProdComm> i
|
||||
private ProdCommMapper prodCommMapper;
|
||||
|
||||
@Override
|
||||
public ProdCommDataDto getProdCommDataByProdId(Long prodId, String userId) {
|
||||
ProdCommDataDto prodCommDataDto=prodCommMapper.getProdCommDataByProdId(prodId, userId);
|
||||
public ProdCommDataDto getProdCommDataByProdId(Long prodId) {
|
||||
ProdCommDataDto prodCommDataDto=prodCommMapper.getProdCommDataByProdId(prodId);
|
||||
//计算出好评率
|
||||
if(prodCommDataDto.getPraiseNumber() == 0||prodCommDataDto.getNumber() == 0){
|
||||
prodCommDataDto.setPositiveRating(0.0);
|
||||
@@ -53,9 +53,9 @@ public class ProdCommServiceImpl extends ServiceImpl<ProdCommMapper, ProdComm> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ProdCommDto> getProdCommDtoPageByProdId(Page page, Long prodId, Integer evaluate, String userId) {
|
||||
public IPage<ProdCommDto> getProdCommDtoPageByProdId(Page page, Long prodId, Integer evaluate) {
|
||||
|
||||
IPage<ProdCommDto> prodCommDtos = prodCommMapper.getProdCommDtoPageByProdId(page, prodId, evaluate, userId);
|
||||
IPage<ProdCommDto> prodCommDtos = prodCommMapper.getProdCommDtoPageByProdId(page, prodId, evaluate);
|
||||
prodCommDtos.getRecords().forEach(prodCommDto -> {
|
||||
// 匿名评价
|
||||
if (prodCommDto.getIsAnonymous() == 1) {
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
count(CASE WHEN evaluate = 2 THEN 1 ELSE null END) AS negative_number,
|
||||
count(CASE WHEN pics is not null THEN 1 ELSE null END) AS pic_number
|
||||
FROM tz_prod_comm
|
||||
WHERE prod_id = #{prodId}
|
||||
and (status = 1 or user_id = #{userId})
|
||||
WHERE prod_id = #{prodId} and status = 1
|
||||
</select>
|
||||
|
||||
|
||||
@@ -78,13 +77,14 @@
|
||||
from
|
||||
tz_prod_comm pc
|
||||
left join tz_user u on u.user_id=pc.user_id
|
||||
where pc.prod_id = #{prodId} and (pc.status = 1 or pc.user_id = #{userId} )
|
||||
where pc.prod_id = #{prodId} and pc.status = 1
|
||||
<if test="evaluate != -1 and evaluate != 3">
|
||||
and pc.evaluate = #{evaluate}
|
||||
</if>
|
||||
<if test="evaluate == 3">
|
||||
and pc.pics is not null
|
||||
</if>
|
||||
order by pc.rec_time desc
|
||||
</select>
|
||||
|
||||
<select id="getProdCommDtoPageByUserId" resultMap="ProdCommDto">
|
||||
@@ -147,4 +147,4 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user