package com.goafanti.weChat.service.impl;

import com.goafanti.common.dao.PublicAssistAdviceMapper;
import com.goafanti.common.model.Admin;
import com.goafanti.common.model.PublicAssistAdvice;
import com.goafanti.core.mybatis.BaseMybatisDao;
import com.goafanti.core.shiro.token.TokenManager;
import com.goafanti.weChat.service.PublicAssistAdviceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公出协单意见表(PublicAssistAdvice)表服务实现类
 *
 * @author makejava
 * @since 2024-07-12 09:21:26
 */
@Service("publicAssistAdviceService")
public class PublicAssistAdviceServiceImpl extends BaseMybatisDao< PublicAssistAdviceMapper> implements PublicAssistAdviceService {
    @Resource
    private PublicAssistAdviceMapper publicAssistAdviceMapper;
    
    
    
    @Override
    public List<PublicAssistAdvice> list(Integer id, Integer type) {
		return publicAssistAdviceMapper.selectList(id,type);
	}

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



    /**
     * 新增数据
     *
     * @param publicAssistAdvice 实例对象
     * @return 实例对象
     */
    @Override
    public PublicAssistAdvice insert(PublicAssistAdvice publicAssistAdvice) {
        Admin adminToken = TokenManager.getAdminToken();
        publicAssistAdvice.setAid(adminToken.getId());
        publicAssistAdvice.setAname(adminToken.getName());
        this.publicAssistAdviceMapper.insert(publicAssistAdvice);
        return publicAssistAdvice;
    }

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

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