| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- package com.goafanti.LectureUser.service.impl;
- import java.util.Calendar;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.goafanti.LectureUser.bo.LectureUserListBo;
- import com.goafanti.LectureUser.service.LectureUserService;
- import com.goafanti.common.dao.LectureUserMapper;
- import com.goafanti.common.model.LectureUser;
- import com.goafanti.common.model.LectureUserKey;
- import com.goafanti.common.utils.StringUtils;
- import com.goafanti.core.mybatis.BaseMybatisDao;
- import com.goafanti.core.mybatis.page.Pagination;
- import com.goafanti.core.shiro.token.TokenManager;
- @Service
- public class LectureUserServiceImpl extends BaseMybatisDao<LectureUserMapper> implements LectureUserService {
- @Autowired
- private LectureUserMapper lectureUserMapper;
- @Override
- public void save(Long lid) {
- LectureUser lu = new LectureUser();
- lu.setLid(lid);
- lu.setUid(TokenManager.getUserId());
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- lu.setCreateTime(now.getTime());
- lu.setLastUpdateTime(lu.getCreateTime());
- lectureUserMapper.insert(lu);
- }
- @Override
- public int update(LectureUser lu) {
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- lu.setLastUpdateTime(now.getTime());
- return lectureUserMapper.updateByPrimaryKeySelective(lu);
- }
- @Override
- public int batchDeleteByPrimaryKey(List<String> id) {
- return lectureUserMapper.batchDeleteByPrimaryKey(id);
- }
- @Override
- public LectureUser selectByPrimaryKey(LectureUserKey key) {
- return lectureUserMapper.selectByPrimaryKey(key);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<LectureUserListBo> listLectureUser(String lectureName, String mobile, String username,
- Integer number, Integer pSize, Integer pNo) {
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- return (Pagination<LectureUserListBo>) findPage("findLectureUserListByPage", "findLectureUserCount",
- disposeLectureList(lectureName, mobile, number, username, null), pNo, pSize);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<LectureUserListBo> listLectureOrg(String lectureName, String mobile, String unitName,
- Integer number, Integer pSize, Integer pNo) {
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- return (Pagination<LectureUserListBo>) findPage("findLectureOrgListByPage", "findLectureOrgCount",
- disposeLectureList(lectureName, mobile, number, null, unitName), pNo, pSize);
- }
- private Map<String, Object> disposeLectureList(String lectureName, String mobile, Integer number, String username,
- String unitName) {
- Map<String, Object> params = new HashMap<>();
- if (StringUtils.isNotBlank(mobile)) {
- params.put("mobile", mobile);
- }
- if (null != number) {
- params.put("number", number);
- }
- if (StringUtils.isNotBlank(lectureName)) {
- params.put("lectureName", lectureName);
- }
- if (StringUtils.isNotBlank(username)) {
- params.put("username", username);
- }
- if (StringUtils.isNotBlank(unitName)) {
- params.put("unitName", unitName);
- }
- return params;
- }
- }
|