package com.shlanbao.tzsc.pms.sys.user.service.impl; import java.util.Date; import java.util.List; import com.shlanbao.tzsc.base.model.SessionInfo; import com.shlanbao.tzsc.utils.tools.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.shlanbao.tzsc.base.dao.SysUserDaoI; import com.shlanbao.tzsc.base.mapping.SysModelPermis; import com.shlanbao.tzsc.base.mapping.SysUser; import com.shlanbao.tzsc.base.model.DataGrid; import com.shlanbao.tzsc.base.model.PageParams; import com.shlanbao.tzsc.base.service.BaseService; import com.shlanbao.tzsc.pms.sys.user.beans.UserBean; import com.shlanbao.tzsc.pms.sys.user.service.UserServiceI; import javax.servlet.http.HttpServletRequest; /** * 用户管理业务实现类 * @author Leejean * @create 2014年9月16日上午10:43:37 */ @Service public class UserServiceImpl extends BaseService implements UserServiceI{ @Autowired private SysUserDaoI sysUserDao; @Autowired private HttpServletRequest request; public UserBean getSysUserById(String id) throws Exception { return BeanConvertor.copyProperties(sysUserDao.findById(SysUser.class, id), UserBean.class); } @Override public UserBean login(UserBean user) throws Exception{ if(user!=null){ Object obj=sysUserDao.unique( "from SysUser u where u.del=0 and u.enable=1 and ((u.loginName=? and u.pwd=?) or (u.eno=? and u.pwd=?))", user.getLoginName(), MD5Util.SHA256(user.getPwd()), user.getLoginName(), MD5Util.SHA256(user.getPwd())); return obj==null?null:BeanConvertor.copyProperties(obj, UserBean.class); } return null; } @Override public DataGrid querySysUser(UserBean userBean, PageParams pageParams) throws Exception{ String hql="from SysUser o where o.del=0";//1 deleted data is not visible String params=""; if(StringUtil.notNull(userBean.getName())){ params+=" and (o.name like '%"+userBean.getName()+"%' or o.loginName like '%"+userBean.getName()+"%' or o.eno like '%"+userBean.getName()+"%')"; } if(StringUtil.notNull(userBean.getGender())){ params+=" and o.gender ='"+userBean.getGender()+"'"; } List rows=sysUserDao.queryByPage(hql.concat(params), pageParams); hql="select count(*) from SysUser o where o.del=0"; try { List beans = BeanConvertor.copyList(rows, UserBean.class); for(int i=0;i users) throws Exception { try { sysUserDao.batchInsert(users,SysUser.class); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }