package com.xxfc.platform.vehicle.rest;

import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.VehicleUserScoreBiz;
import com.xxfc.platform.vehicle.entity.VehicleUserScore;
import com.xxfc.platform.vehicle.pojo.dto.VehicleUserScoreDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehicleUserScoreVo;
import org.springframework.web.bind.annotation.*;

/**
 * @author libin
 * @version 1.0
 * @description 评分
 * @data 2019/6/18 15:32
 */
@RestController
@RequestMapping("vehicleUserScore")
public class VehicleUserScoreController extends BaseController<VehicleUserScoreBiz, VehicleUserScore> {

    /**
     * 保存评分
     * @param vehicleUserScoreDTO
     * @return
     */
    @PostMapping("/score")
     public ObjectRestResponse<Void> saveVehicleUserScore(VehicleUserScoreDTO vehicleUserScoreDTO){
         int effectRows = getBaseBiz().saveVehicleUserScore(vehicleUserScoreDTO);
         if (effectRows>0){
            return ObjectRestResponse.succ();
         }
         return ObjectRestResponse.createDefaultFail();
     }
    /**
     * 根据车型查询评分列表
     *
     * @param modelId
     * @return
     */
    @GetMapping("/scores")
    public ObjectRestResponse<PageDataVO<VehicleUserScoreVo>> findVehicleUserScorePageByModelId(@RequestParam("modelId") Integer modelId) {
        PageDataVO<VehicleUserScoreVo> pageDataVO = getBaseBiz().findVehicleUserScorePageByModelId(modelId);
        return ObjectRestResponse.succ(pageDataVO);
    }
}