LectureUserServiceImpl.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package com.goafanti.LectureUser.service.impl;
  2. import java.util.Calendar;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import com.goafanti.LectureUser.bo.LectureUserListBo;
  9. import com.goafanti.LectureUser.service.LectureUserService;
  10. import com.goafanti.common.dao.LectureUserMapper;
  11. import com.goafanti.common.model.LectureUser;
  12. import com.goafanti.common.model.LectureUserKey;
  13. import com.goafanti.common.utils.StringUtils;
  14. import com.goafanti.core.mybatis.BaseMybatisDao;
  15. import com.goafanti.core.mybatis.page.Pagination;
  16. import com.goafanti.core.shiro.token.TokenManager;
  17. @Service
  18. public class LectureUserServiceImpl extends BaseMybatisDao<LectureUserMapper> implements LectureUserService {
  19. @Autowired
  20. private LectureUserMapper lectureUserMapper;
  21. @Override
  22. public void save(Long lid) {
  23. LectureUser lu = new LectureUser();
  24. lu.setLid(lid);
  25. lu.setUid(TokenManager.getUserId());
  26. Calendar now = Calendar.getInstance();
  27. now.set(Calendar.MILLISECOND, 0);
  28. lu.setCreateTime(now.getTime());
  29. lu.setLastUpdateTime(lu.getCreateTime());
  30. lectureUserMapper.insert(lu);
  31. }
  32. @Override
  33. public int update(LectureUser lu) {
  34. Calendar now = Calendar.getInstance();
  35. now.set(Calendar.MILLISECOND, 0);
  36. lu.setLastUpdateTime(now.getTime());
  37. return lectureUserMapper.updateByPrimaryKeySelective(lu);
  38. }
  39. @Override
  40. public int batchDeleteByPrimaryKey(List<String> id) {
  41. return lectureUserMapper.batchDeleteByPrimaryKey(id);
  42. }
  43. @Override
  44. public LectureUser selectByPrimaryKey(LectureUserKey key) {
  45. return lectureUserMapper.selectByPrimaryKey(key);
  46. }
  47. @SuppressWarnings("unchecked")
  48. @Override
  49. public Pagination<LectureUserListBo> listLectureUser(String lectureName, String mobile, String username,
  50. Integer number, Integer pSize, Integer pNo) {
  51. if (pNo == null || pNo < 0) {
  52. pNo = 1;
  53. }
  54. if (pSize == null || pSize < 0 || pSize > 10) {
  55. pSize = 10;
  56. }
  57. return (Pagination<LectureUserListBo>) findPage("findLectureUserListByPage", "findLectureUserCount",
  58. disposeLectureList(lectureName, mobile, number, username, null), pNo, pSize);
  59. }
  60. @SuppressWarnings("unchecked")
  61. @Override
  62. public Pagination<LectureUserListBo> listLectureOrg(String lectureName, String mobile, String unitName,
  63. Integer number, Integer pSize, Integer pNo) {
  64. if (pNo == null || pNo < 0) {
  65. pNo = 1;
  66. }
  67. if (pSize == null || pSize < 0 || pSize > 10) {
  68. pSize = 10;
  69. }
  70. return (Pagination<LectureUserListBo>) findPage("findLectureOrgListByPage", "findLectureOrgCount",
  71. disposeLectureList(lectureName, mobile, number, null, unitName), pNo, pSize);
  72. }
  73. private Map<String, Object> disposeLectureList(String lectureName, String mobile, Integer number, String username,
  74. String unitName) {
  75. Map<String, Object> params = new HashMap<>();
  76. if (StringUtils.isNotBlank(mobile)) {
  77. params.put("mobile", mobile);
  78. }
  79. if (null != number) {
  80. params.put("number", number);
  81. }
  82. if (StringUtils.isNotBlank(lectureName)) {
  83. params.put("lectureName", lectureName);
  84. }
  85. if (StringUtils.isNotBlank(username)) {
  86. params.put("username", username);
  87. }
  88. if (StringUtils.isNotBlank(unitName)) {
  89. params.put("unitName", unitName);
  90. }
  91. return params;
  92. }
  93. }