| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import com.github.pagehelper.PageHelper;
|
| | | import com.moral.common.bean.Constants;
|
| | | import com.moral.common.bean.PageBean;
|
| | | import com.moral.common.util.Crypto;
|
| | | import com.moral.common.util.ResourceUtil;
|
| | | import com.moral.entity.AlarmUser;
|
| | | import com.moral.entity.Organization;
|
| | | import com.moral.mapper.AlarmUserMapper;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import com.moral.service.AlarmUserService;
|
| | |
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | |
| | | @Resource
|
| | | private AlarmUserMapper alarmUserMapper;
|
| | |
|
| | | @Resource
|
| | | private OrganizationMapper organizationMapper;
|
| | |
|
| | | @Override
|
| | | public PageBean<AlarmUser> getalarmUserList(Map<String, Object> parameters) {
|
| | | Example example = new Example(AlarmUser.class);
|
| | | Criteria criteria = example.createCriteria();
|
| | | if (parameters.containsKey("alarmUserName")) {
|
| | | criteria.andLike("alarmUserName", "%" + (String) parameters.get("alarmUserName") + "%");
|
| | | if (parameters.containsKey("name")) {
|
| | | criteria.andLike("name", "%" + (String) parameters.get("name") + "%");
|
| | | }
|
| | | if (parameters.containsKey("mobile")) {
|
| | | criteria.andLike("mobile", "%" + (String) parameters.get("mobile") + "%");
|
| | |
| | | }
|
| | | PageHelper.startPage(Integer.valueOf((String) parameters.get("pageIndex")), Integer.valueOf((String) parameters.get("pageSize")));
|
| | | List<AlarmUser> alarmUsers = alarmUserMapper.selectByExample(example);
|
| | | Set<Integer> organizationIds = new HashSet<Integer>();
|
| | | for (AlarmUser alarmUser : alarmUsers) {
|
| | | if (!ObjectUtils.isEmpty(alarmUser.getOrganizationId())) {
|
| | | organizationIds.add(alarmUser.getOrganizationId());
|
| | | }
|
| | | }
|
| | | if (!ObjectUtils.isEmpty(organizationIds)) {
|
| | | example = new Example(Organization.class);
|
| | | example.or().andIn("id", organizationIds);
|
| | | List<Organization> organizations = organizationMapper.selectByExample(example);
|
| | | for (AlarmUser alarmUser : alarmUsers) {
|
| | | for (Organization organization : organizations) {
|
| | | if (alarmUser.getOrganizationId() == organization.getId()) {
|
| | | alarmUser.setOrganization(organization);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return new PageBean<AlarmUser>(alarmUsers);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Integer saveOrUpdatealarmUser(AlarmUser alarmUser) {
|
| | | if (ObjectUtils.isEmpty(alarmUser.getId())) {
|
| | | alarmUser.setIsDelete(Constants.IS_DELETE_FALSE);
|
| | | alarmUser.setCreateTime(new Date());
|
| | | alarmUser.setPassword(Crypto.md5(ResourceUtil.getValue("password")));
|
| | | return alarmUserMapper.insertSelective(alarmUser);
|
| | | } else {
|
| | | return alarmUserMapper.updateByPrimaryKeySelective(alarmUser);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Integer deletealarmUserByLogic(AlarmUser alarmUser) {
|
| | | alarmUser.setIsDelete(Constants.IS_DELETE_TRUE);
|
| | | return alarmUserMapper.updateByPrimaryKeySelective(alarmUser);
|
| | | }
|
| | |
|
| | | @Override
|