package com.demo.service.impl; import com.demo.dao.CustomerMapper; import com.demo.dao.ZiXunMapper; import com.demo.pojo.Customer; import com.demo.pojo.ZiXun; import com.demo.pojo.ZiXunExample; import com.demo.service.ZiXunService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class ZiXunServiceImpl implements ZiXunService { @Autowired private ZiXunMapper ziXunMapper; @Autowired private CustomerMapper customerMapper; @Override public List list() { ZiXunExample example = new ZiXunExample(); example.createCriteria().andStatusEqualTo(1); List ziXuns = ziXunMapper.selectByExample(example); for (ZiXun z:ziXuns){ Customer customer =customerMapper.selectByPrimaryKey(z.getCstid()); z.setCustomer(customer); } return ziXuns; } @Override public void save(ZiXun entity) { ziXunMapper.insert(entity); } @Override public void del(int id) { ziXunMapper.deleteByPrimaryKey(id); } @Override public ZiXun get(int id) { return ziXunMapper.selectByPrimaryKey(id); } @Override public void shenhe(int zid) { ziXunMapper.shenhe(zid); } @Override public List list1() { List ziXuns = ziXunMapper.selectByExample(null); for (ZiXun z:ziXuns){ Customer customer =customerMapper.selectByPrimaryKey(z.getCstid()); z.setCustomer(customer); } return ziXuns; } }