/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.doctor;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.yihu.wlyy.entity.statistics.DoctorStatisticsComment;

public interface DoctorStatisticsCommentDao extends PagingAndSortingRepository<DoctorStatisticsComment, Long>, JpaSpecificationExecutor<DoctorStatisticsComment> {

	@Query("select a from DoctorStatisticsComment a where a.doctor = ?1 and a.date = ?2")
	DoctorStatisticsComment findByDoctorDate(String doctor, int date);

	@Modifying
	@Query("update DoctorStatisticsComment a set a.oneStar = a.oneStar + 1 where a.doctor = ?1 and a.date = ?2")
	int increaseOneStar(String doctor, int date);

	@Modifying
	@Query("update DoctorStatisticsComment a set a.twoStar = a.twoStar + 1 where a.doctor = ?1 and a.date = ?2")
	int increaseTwoStar(String doctor, int date);

	@Modifying
	@Query("update DoctorStatisticsComment a set a.threeStar = a.threeStar + 1 where a.doctor = ?1 and a.date = ?2")
	int increaseThreeStar(String doctor, int date);

	@Modifying
	@Query("update DoctorStatisticsComment a set a.fourStar = a.fourStar + 1 where a.doctor = ?1 and a.date = ?2")
	int increaseFourStar(String doctor, int date);

	@Modifying
	@Query("update DoctorStatisticsComment a set a.fiveStar = a.fiveStar + 1 where a.doctor = ?1 and a.date = ?2")
	int increaseFiveStar(String doctor, int date);

}
