package com.goafanti.demand.service.impl; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.goafanti.common.bo.PublishPageBo; import com.goafanti.common.dao.DemandPublishMapper; import com.goafanti.common.model.DemandPublish; import com.goafanti.core.mybatis.BaseMybatisDao; import com.goafanti.core.mybatis.page.Pagination; import com.goafanti.core.shiro.token.TokenManager; import com.goafanti.demand.bo.DemandPublishBo; import com.goafanti.demand.service.DemandPublishPageService; import com.goafanti.demand.service.DemandPublishService; @Service public class DemandPublishServiceImpl extends BaseMybatisDao implements DemandPublishService { @Autowired private DemandPublishMapper demandPublishMapper; @Override public int insertDemandPublish(DemandPublish d) { String [] did=d.getDemandId().split(","); for (String s : did) { d.setDemandId(s); if (demandPublishMapper.checkExisting(d)>0) { continue; } d.setId(UUID.randomUUID().toString()); if (null!=TokenManager.getAdminId()) { d.setPublisher(TokenManager.getAdminId()); } if (null==d.getShowNumber()) { d.setShowNumber(9999999); } if (null==d.getTopNumber()) { d.setTopNumber(9999999); } d.setPublishTime(new Date()); demandPublishMapper.insertSelective(d); } return 1; } @Override public int deletePublish(String id) { return demandPublishMapper.deleteByPrimaryKey(id); } @Override public int updatePublish(DemandPublish d) { DemandPublish d1=demandPublishMapper.selectByPrimaryKey(d.getId()); if (d1.getIfTop()!=d.getIfTop()&&d.getIfTop()==1) { d.setTopNumber(9999999); } return demandPublishMapper.updateByPrimaryKeySelective(d); } @SuppressWarnings("unchecked") @Override public Pagination listPublish(String name, String publishPlatform, Integer publishClient, String publishPage, Integer ifTop, Integer pageNo, Integer pageSize,String employerName) { Map params=new HashMap(); if (null!=name) { params.put("name", name); } if (null!=publishPlatform) { params.put("publishPlatform", publishPlatform); } if (null!=publishClient) { params.put("publishClient", publishClient); } if (null!=publishPage) { params.put("publishPage", publishPage); } if (null!=ifTop) { params.put("ifTop", ifTop); } if (null!=employerName) { params.put("employerName", employerName); } Pagination p=(Pagination) findPage("findDemandPublishByPage", "findDemandPublishCount", params,pageNo, pageSize); List dp=(List) p.getList(); List pp=DemandPublishPageService.getBranchInformation(); for (DemandPublishBo d : dp) { for (PublishPageBo b : pp) { if (d.getPublishPage().equals(b.getId())) { d.setPublishPageName(b.getName()); } } } return p; } }