ExpertPublishServiceImpl.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package com.goafanti.user.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.ExpertPublishMapper;
  11. import com.goafanti.common.model.ExpertPublish;
  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.user.bo.ExpertPublishBo;
  16. import com.goafanti.user.service.ExpertPublishPageService;
  17. import com.goafanti.user.service.ExpertPublishService;
  18. @Service
  19. public class ExpertPublishServiceImpl extends BaseMybatisDao<ExpertPublishMapper> implements ExpertPublishService {
  20. @Autowired
  21. private ExpertPublishMapper expertPublishMapper;
  22. @Override
  23. public int insertExpertPublish(ExpertPublish e) {
  24. String [] aid=e.getExpertId().split(",");
  25. for (String s : aid) {
  26. e.setExpertId(s);
  27. if (expertPublishMapper.checkExisting(e)>0) {
  28. continue;
  29. }
  30. e.setId(UUID.randomUUID().toString());
  31. if (null!=TokenManager.getAdminId()) {
  32. e.setPublisher(TokenManager.getAdminId());
  33. }
  34. if (null==e.getShowNumber()) {
  35. e.setShowNumber(9999999);
  36. }
  37. if (null==e.getTopNumber()) {
  38. e.setTopNumber(9999999);
  39. }
  40. e.setPublishTime(new Date());
  41. expertPublishMapper.insertSelective(e);
  42. }
  43. return 1;
  44. }
  45. @Override
  46. public int deletePublish(String id) {
  47. return expertPublishMapper.deleteByPrimaryKey(id);
  48. }
  49. @Override
  50. public int updatePublish(ExpertPublish e) {
  51. ExpertPublish e1=expertPublishMapper.selectByPrimaryKey(e.getId());
  52. if (e1.getIfTop()!=e.getIfTop()&&e.getIfTop()==1) {
  53. e.setTopNumber(9999999);
  54. }
  55. return expertPublishMapper.updateByPrimaryKeySelective(e);
  56. }
  57. @SuppressWarnings("unchecked")
  58. @Override
  59. public Pagination<ExpertPublishBo> listPublish(String name, String publishPlatform, Integer publishClient,
  60. String publishPage, Integer ifTop, Integer pageNo, Integer pageSize) {
  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. Pagination<ExpertPublishBo> p=(Pagination<ExpertPublishBo>) findPage("findExpertPublishByPage", "findExpertPublishCount",
  78. params,pageNo, pageSize);
  79. List<ExpertPublishBo> ep=(List<ExpertPublishBo>) p.getList();
  80. List <PublishPageBo> pp=ExpertPublishPageService.getBranchInformation();
  81. for (ExpertPublishBo a : ep) {
  82. for (PublishPageBo b : pp) {
  83. if (a.getPublishPage().equals(b.getId())) {
  84. a.setPublishPageName(b.getName());
  85. }
  86. }
  87. }
  88. return p;
  89. }
  90. }