package com.goafanti.customer.service.impl;

import com.goafanti.common.dao.UserSuperEvaluateMapper;
import com.goafanti.common.model.UserSuperEvaluate;
import com.goafanti.core.mybatis.BaseMybatisDao;
import com.goafanti.core.mybatis.page.Pagination;
import com.goafanti.core.shiro.token.TokenManager;
import com.goafanti.customer.bo.OutUserSuperEvaluate;
import com.goafanti.customer.service.UserSuperEvaluateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 客户上级评价(UserSuperEvaluate)表服务实现类
 *
 * @author makejava
 * @since 2024-07-17 08:51:36
 */
@Service("userSuperEvaluateService")
public class UserSuperEvaluateServiceImpl extends BaseMybatisDao< UserSuperEvaluateMapper> implements UserSuperEvaluateService {
    @Resource
    private UserSuperEvaluateMapper userSuperEvaluateMapper;
    
    
    
    @Override
    public Pagination<OutUserSuperEvaluate> list(UserSuperEvaluate userSuperEvaluate, Integer pageNo, Integer pageSize) {
		Map<String, Object> params = new HashMap<>();
        params.put("uid",userSuperEvaluate.getUid());
        params.put("aid",userSuperEvaluate.getAid());
        params.put("type",userSuperEvaluate.getType());
		return (Pagination<OutUserSuperEvaluate>) findPage("findUserSuperEvaluateList",
				"findUserSuperEvaluateCount", params, pageNo, pageSize);
	}

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserSuperEvaluate queryById(Integer id) {
        return this.userSuperEvaluateMapper.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param userSuperEvaluate 实例对象
     * @return 实例对象
     */
    @Override
    public UserSuperEvaluate insert(UserSuperEvaluate userSuperEvaluate) {
        userSuperEvaluate.setAid(TokenManager.getAdminId());
        this.userSuperEvaluateMapper.insert(userSuperEvaluate);
        return userSuperEvaluate;
    }

    /**
     * 修改数据
     *
     * @param userSuperEvaluate 实例对象
     * @return 实例对象
     */
    @Override
    public UserSuperEvaluate update(UserSuperEvaluate userSuperEvaluate) {
        this.userSuperEvaluateMapper.update(userSuperEvaluate);
        return this.queryById(userSuperEvaluate.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.userSuperEvaluateMapper.deleteById(id) > 0;
    }
}
