package com.ssj.service.weixin.library.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.weixin.libmy.domain.TbJxyReadIn;
import com.ssj.bean.weixin.user.domain.User;
import com.ssj.dao.weixin.library.dao.IOneBookDao;
import com.ssj.dao.weixin.library.dao.IOneBookQueryDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.weixin.library.service.IBookManagerService;
import com.ssj.service.weixin.library.service.IOneBookService;
import com.ssj.service.weixin.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;
import java.util.Map;


@Service(version="1.0")
public class OneBookServiceImpl extends BaseServiceImpl<TbJxyReadIn, String> implements IOneBookService {

	@Autowired
	private IOneBookDao dao;
	
	@Autowired
	private IOneBookQueryDao queryDao;
	@Autowired
	private IBookManagerService managerService;
	@Autowired
	private UserService userService;
	
	@Override
	public PagingAndSortingRepository<TbJxyReadIn, String> getDao() {
		return dao;
	}

	@Override
	public Map<String, Object> getTjInfo(String userId) {
		
		return queryDao.getTjInfo(userId);
	}

	@Override
	public List<Map<String, Object>> groomBookList() {
		
		return queryDao.groomBookList();
	}

	@Override
	public List<Map<String, Object>> readBookList(String userId) {
		
		return queryDao.readBookList(userId);
	}

	@Override
	public List<TbJxyReadIn> getTop3Recode(String isbn13) {
		
		return dao.getTop3Recode(isbn13);
	}

	@Override
	public int getCountByIsbn(String isbn13) {
		
		return dao.getCountByIsbn(isbn13);
	}

	@Override
	public Map<String, Object> findSignInfo(String isbn13, String userId) {
		
		return queryDao.findSignInfo(isbn13,userId);
	}

	@Override
	public Page<Map<String, Object>> findByPage(Map<String, Object> params, Pageable pageable) {
		
		return queryDao.findByPage(params,pageable);
	}

	@Override
	public TbJxyReadIn findInfoByUserIsbn(String id, String isbn13) {
		
		return dao.findInfoByUserIsbn(id,isbn13);
	}

	@Override
	public List<Map<String, Object>> findBorrowInfo(String vipId, String userId) {
		
		return queryDao.findBorrowInfo(vipId,userId);
	}

	@Override
	public Page<Map<String, Object>> myBorrowHis(Map<String, Object> params, Pageable pageable) {
		
		return queryDao.myBorrowHis(params,pageable);
	}

	@Override
	public Page<Map<String, Object>> myReadHis(Map<String, Object> params, Pageable pageable) {
		
		return queryDao.myReadHis(params,pageable);
	}

	@Override
	public int getCountSign(String isbn13, String userId) {
		
		return dao.getCountSign(isbn13,userId);
	}

	@Override
	public TbJxyReadIn findByisbn13AndUserId(String isbn13, String userId) {
		return dao.findByisbn13AndUserId(isbn13, userId);
	}

	@Override
	public List<String> findWordList(int type) {
		
		return dao.findWordList(type);
	}

	@Override
	public void updateMobilePhone(User user, String phoneNumber) {
		user.setMobile(phoneNumber);
		userService.save(user);
		managerService.updateManagerPhone(user.getId(),phoneNumber);
	}


}
