package com.goafanti.admin.service.impl; import java.util.HashMap; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.goafanti.core.mybatis.BaseMybatisDao; import com.goafanti.admin.service.CustomerService; import com.goafanti.common.dao.CustomerMapper; import com.goafanti.common.model.Customer; import com.goafanti.core.mybatis.page.Pagination; import com.goafanti.core.shiro.token.TokenManager; @Service public class CustomerServiceImpl extends BaseMybatisDao implements CustomerService { @Autowired private CustomerMapper customerMapper ; @Override public int addCustomer(Customer cus) { int res = customerMapper.insertCustomer(cus); return res; } @Override public int deleteCustomer(String id) { int res = customerMapper.deleteByPrimaryKey(id); return res; } @SuppressWarnings("unchecked") @Override public Pagination findCustomerByPage(String companyName ,Integer customerTyp ,String province ,String customerName ,String telNum , String customerStatue ,String CompanyIntention ,String fllowSituation ,Integer pageNo, Integer pageSize) { return (Pagination) findPage("findSearchCustomerListByPage", "findSearchCustomerCount", buildListParams(companyName, customerTyp, province, customerName, telNum, customerStatue, CompanyIntention, fllowSituation, TokenManager.getUserId()), pageNo, pageSize); } private Map buildListParams(String companyName, Integer customerTyp,String province,String customerName,String telNum, String customerStatue,String CompanyIntention,String fllowSituation,String aid) { Map params = new HashMap<>(); if (null != companyName) { params.put("companyName", companyName); } if (null!=customerTyp) { params.put("customerTyp", customerTyp); } if (StringUtils.isNotBlank(province)) { params.put("province", province); } if (StringUtils.isNotBlank(customerName)) { params.put("customerName", customerName); } if (null!=customerStatue ) { params.put("customerStatue", customerStatue); } if (StringUtils.isNotBlank(CompanyIntention)) { params.put("CompanyIntention", CompanyIntention); } if (StringUtils.isNotBlank(fllowSituation)) { params.put("fllowSituation", fllowSituation); } if (StringUtils.isNotBlank(aid)) { params.put("aid", aid); } return params; } }