| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.moral.common.util.*;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
|
| | | import com.github.pagehelper.PageHelper;
|
| | | import com.moral.common.bean.Constants;
|
| | | import com.moral.common.bean.PageBean;
|
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.Crypto;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.OperateUser;
|
| | | import com.moral.mapper.OperateUserMapper;
|
| | | import com.moral.service.OperateUserService;
|
| | |
|
| | | import java.util.List;
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | | import tk.mybatis.mapper.entity.Example.Criteria;
|
| | |
|
| | | @Service
|
| | | public class OperateUserServiceImpl implements OperateUserService {
|
| | |
|
| | | private static Class ENTITY_CLASS = OperateUser.class;
|
| | | @Resource
|
| | | private OperateUserMapper operateUserMapper;
|
| | |
|
| | | @Override
|
| | | public boolean isUniqueProperty(String propertyName, Object value){
|
| | | Example example = new Example(ENTITY_CLASS);
|
| | | example.or().andEqualTo(propertyName,value);
|
| | | return operateUserMapper.selectCountByExample(example)==0;
|
| | | }
|
| | | @Override
|
| | | public OperateUser getOperateUserByMobile(String mobile) {
|
| | | OperateUser operateUser = new OperateUser();
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<OperateUser> findOperateUserList() {
|
| | | return operateUserMapper.findOperateUserList();
|
| | | public PageBean<OperateUser> getOperateUserList(Map<String, Object> parameters) {
|
| | | Example example = new Example(OperateUser.class);
|
| | | Criteria criteria = example.createCriteria();
|
| | | if (parameters.containsKey("u_name")) {
|
| | | criteria.andLike("name", "%" + (String) parameters.get("u_name") + "%");
|
| | | }
|
| | | if (parameters.containsKey("u_mobile")) {
|
| | | criteria.andLike("mobile", "%" + (String) parameters.get("u_mobile") + "%");
|
| | | }
|
| | | if (parameters.containsKey("sorter")) {
|
| | | example.setOrderByClause((String) parameters.get("sorter"));
|
| | | }
|
| | | Object isDelete = parameters.get("isDelete");
|
| | | criteria.andEqualTo("isDelete",isDelete!=null?isDelete:0);
|
| | | // criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
|
| | | PageHelper.startPage(Integer.valueOf((String) parameters.get("pi")), Integer.valueOf((String) parameters.get("ps")));
|
| | | List<OperateUser> operateUsers = operateUserMapper.selectByExample(example);
|
| | | return new PageBean<OperateUser>(operateUsers);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Long findOperateUserCount() {
|
| | | return operateUserMapper.findOperateUserCount();
|
| | | @Transactional
|
| | | public Integer saveOrUpdateOperateUser(OperateUser operateUser) {
|
| | | if (ObjectUtils.isEmpty(operateUser.getId())) {
|
| | | operateUser.setIsDelete(Constants.IS_DELETE_FALSE);
|
| | | operateUser.setCreateTime(new Date());
|
| | | operateUser.setPassword(Crypto.md5(ResourceUtil.getValue("password")));
|
| | | return operateUserMapper.insertSelective(operateUser);
|
| | | }else {
|
| | | if(!StringUtils.isNullOrEmpty(operateUser.getPassword())){
|
| | | // 明码加密
|
| | | operateUser.setPassword(Crypto.md5(operateUser.getPassword()));
|
| | | }
|
| | | return operateUserMapper.updateByPrimaryKeySelective(operateUser);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public Integer deleteOperateUserByLogic(OperateUser operateUser) {
|
| | | operateUser.setIsDelete(Constants.IS_DELETE_TRUE);
|
| | | return operateUserMapper.updateByPrimaryKey(operateUser);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public OperateUser findOperateUser(int id) {
|
| | | return operateUserMapper.selectByPrimaryKey(id);
|
| | | @Transactional
|
| | | public Integer deleteOperateUsersByLogic(List<Integer> ids) {
|
| | | OperateUser operateUser = new OperateUser();
|
| | | operateUser.setIsDelete(Constants.IS_DELETE_TRUE);
|
| | | Example example = new Example(OperateUser.class);
|
| | | example.or().andIn("id", ids);
|
| | | return operateUserMapper.updateByExampleSelective(operateUser, example);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertOperateUser(OperateUser user) {
|
| | | return operateUserMapper.insert(user);
|
| | | public PageBean queryByPageBean(PageBean pageBean) {
|
| | | return MyBatisBaseMapUtil.queryPage(operateUserMapper,pageBean,ENTITY_CLASS);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateOperateUser(OperateUser user) {
|
| | | return operateUserMapper.updateByPrimaryKey(user);
|
| | | public Integer updateOperateUser(OperateUser operateUser) {
|
| | | return operateUserMapper.updateByPrimaryKeySelective(operateUser);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int deleteOperateUser(int id) {
|
| | | return operateUserMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | }
|