zhubaomin
2025-04-08 d9437e8c8b95377fde98f5ed9f66e54d9d59e4c6
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeSv.java
New file
@@ -0,0 +1,115 @@
package com.dy.pipIrrBase.clientType;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrBase.user.QueryVo;
import com.dy.pipIrrGlobal.daoBa.BaClientMapper;
import com.dy.pipIrrGlobal.daoBa.BaClientTypeMapper;
import com.dy.pipIrrGlobal.pojoBa.BaClientType;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class ClientTypeSv {
    private BaClientTypeMapper dao;
    private BaClientMapper cdao;
    @Autowired
    private void setDao(BaClientTypeMapper dao){
        this.dao = dao;
    }
    @Autowired
    private void setDao(BaClientMapper dao){
        this.cdao = dao;
    }
    /**
     * 查询某类型农户总数
     * @param typeId 农户类型ID
     * @return 总数
     */
    public Long selectClientByType(Long typeId){
        return this.cdao.selectCountByType(typeId) ;
    }
    /**
     * 得到所有农户类型
     * @return 所有农户类型集合
     */
    public QueryResultVo<List<BaClientType>> selectAll(){
        QueryResultVo<List<BaClientType>> rsVo = new QueryResultVo<>() ;
        rsVo.obj = this.dao.selectAll() ;
        return rsVo ;
    }
    /**
     * 得到一个农户类型
     * @param id 农户类型ID
     * @return 农户类型实体
     */
    public BaClientType selectById(Long id){
        return this.dao.selectById(id) ;
    }
    /**
     * 得到一个用户
     * @param vo 查询条件值对象
     * @return 用户实体
     */
    @SuppressWarnings("unchecked")
    public QueryResultVo<List<BaClientType>> selectSome(QueryVo vo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ;
        Long itemTotal = this.dao.selectTotal(params) ;
        QueryResultVo<List<BaClientType>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = vo.pageSize ;
        rsVo.pageCurr = vo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = this.dao.selectSome(params) ;
        return rsVo ;
    }
    /**
     * 保存实体
     * @param po 实体
     * @return 影响记录数量
     */
    @Transactional
    public int save(BaClientType po){
        return this.dao.insertSelective(po) ;
    }
    /**
     * 保存修改实体
     * @param po 实体
     * @return 影响记录数量
     */
    @Transactional
    public int update(BaClientType po){
        return this.dao.updateByPrimaryKeySelective(po) ;
    }
    /**
     * 保存修改实体
     * @param id 实体ID
     * @return 影响记录数量
     */
    @Transactional
    public int delete(Long id){
        return this.dao.deleteById(id) ;
    }
}