DemandPublishServiceImpl.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package com.goafanti.demand.service.impl;
  2. import java.util.Date;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import java.util.UUID;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import com.goafanti.common.bo.PublishPageBo;
  10. import com.goafanti.common.dao.DemandPublishMapper;
  11. import com.goafanti.common.model.DemandPublish;
  12. import com.goafanti.core.mybatis.BaseMybatisDao;
  13. import com.goafanti.core.mybatis.page.Pagination;
  14. import com.goafanti.core.shiro.token.TokenManager;
  15. import com.goafanti.demand.bo.DemandPublishBo;
  16. import com.goafanti.demand.service.DemandPublishPageService;
  17. import com.goafanti.demand.service.DemandPublishService;
  18. @Service
  19. public class DemandPublishServiceImpl extends BaseMybatisDao<DemandPublishMapper> implements DemandPublishService {
  20. @Autowired
  21. private DemandPublishMapper demandPublishMapper;
  22. @Override
  23. public int insertDemandPublish(DemandPublish d) {
  24. String [] did=d.getDemandId().split(",");
  25. for (String s : did) {
  26. d.setDemandId(s);
  27. if (demandPublishMapper.checkExisting(d)>0) {
  28. continue;
  29. }
  30. d.setId(UUID.randomUUID().toString());
  31. if (null!=TokenManager.getAdminId()) {
  32. d.setPublisher(TokenManager.getAdminId());
  33. }
  34. if (null==d.getShowNumber()) {
  35. d.setShowNumber(9999999);
  36. }
  37. if (null==d.getTopNumber()) {
  38. d.setTopNumber(9999999);
  39. }
  40. d.setPublishTime(new Date());
  41. demandPublishMapper.insertSelective(d);
  42. }
  43. return 1;
  44. }
  45. @Override
  46. public int deletePublish(String id) {
  47. return demandPublishMapper.deleteByPrimaryKey(id);
  48. }
  49. @Override
  50. public int updatePublish(DemandPublish d) {
  51. DemandPublish d1=demandPublishMapper.selectByPrimaryKey(d.getId());
  52. if (d1.getIfTop()!=d.getIfTop()&&d.getIfTop()==1) {
  53. d.setTopNumber(9999999);
  54. }
  55. return demandPublishMapper.updateByPrimaryKeySelective(d);
  56. }
  57. @SuppressWarnings("unchecked")
  58. @Override
  59. public Pagination<DemandPublishBo> listPublish(String name, String publishPlatform, Integer publishClient,
  60. String publishPage, Integer ifTop, Integer pageNo, Integer pageSize,String employerName) {
  61. Map<String, Object> params=new HashMap<String, Object>();
  62. if (null!=name) {
  63. params.put("name", name);
  64. }
  65. if (null!=publishPlatform) {
  66. params.put("publishPlatform", publishPlatform);
  67. }
  68. if (null!=publishClient) {
  69. params.put("publishClient", publishClient);
  70. }
  71. if (null!=publishPage) {
  72. params.put("publishPage", publishPage);
  73. }
  74. if (null!=ifTop) {
  75. params.put("ifTop", ifTop);
  76. }
  77. if (null!=employerName) {
  78. params.put("employerName", employerName);
  79. }
  80. Pagination<DemandPublishBo> p=(Pagination<DemandPublishBo>) findPage("findDemandPublishByPage", "findDemandPublishCount",
  81. params,pageNo, pageSize);
  82. List<DemandPublishBo> dp=(List<DemandPublishBo>) p.getList();
  83. List <PublishPageBo> pp=DemandPublishPageService.getBranchInformation();
  84. for (DemandPublishBo d : dp) {
  85. for (PublishPageBo b : pp) {
  86. if (d.getPublishPage().equals(b.getId())) {
  87. d.setPublishPageName(b.getName());
  88. }
  89. }
  90. }
  91. return p;
  92. }
  93. }