| | |
| | | package com.qxueyou.scc.user.service.impl; |
| | | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import com.qxueyou.scc.base.dao.CommonDAO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import com.qxueyou.scc.user.model.User; |
| | | import com.qxueyou.scc.user.model.UserReRoleUser; |
| | | import com.qxueyou.scc.user.service.IUserService; |
| | | import org.springframework.util.DigestUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | IOrganizationService organizationService; |
| | | |
| | | @Autowired |
| | | private CommonDAO commonDAO; |
| | | |
| | | /** |
| | | * 初始化用户wrapper |
| | |
| | | System.out.println(user.getOrganizationId()); |
| | | System.out.println(user.getUserId()); |
| | | |
| | | // String hql = "from UserReRoleUser u where deleteFlag is false and userId = ? "; |
| | | // |
| | | // find(hql, CollectionUtils.newList(param.getUserId()), UserReRoleUser.class); |
| | | |
| | | ClsClass objClsClass = this.findUnique("select c from StuStudent t," |
| | | + " ClsClass c where c.classId = t.classId " |
| | | + "ClsClass c where c.classId = t.classId " |
| | | + " and c.orgId = ? and t.userId = ? and t.status = ? order by t.createTime desc", CollectionUtils.newList(user.getOrganizationId(), user.getUserId(), StuStudent.STATUS_ACTIVE), ClsClass.class); |
| | | wrapper.setUser(user); |
| | | wrapper.setOrg(org); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public User insertUser(String name, String account, String mobilePhone, String password, Boolean sex, String orgId) { |
| | | return newUser(name, account, mobilePhone, password, sex, orgId); |
| | | public User insertUser( String photo,String name, String account, String mobilePhone, String password, Boolean sex, String orgId) { |
| | | return newUser( photo,name, account, mobilePhone, password, sex, orgId); |
| | | } |
| | | |
| | | private User newUser(String name, String account, String mobilePhone, String password, Boolean sex, String orgId) { |
| | | |
| | | private User newUser(String photo,String name, String account, String mobilePhone, String password, Boolean sex, String orgId) { |
| | | //随机字符串 |
| | | String salt= UUID.randomUUID().toString(); |
| | | User user = new User(); |
| | | TraceUtils.setCreateTrace(user); |
| | | user.setAccount(account); |
| | | user.setName(name); |
| | | //盐值 |
| | | user.setSalt(salt); |
| | | //对密码进行加密处理 |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); |
| | | user.setPassword(newPassword); |
| | | user.setMobilePhone(mobilePhone); |
| | | user.setPassword(password); |
| | | user.setImgPath(photo); |
| | | user.setSex(sex); |
| | | user.setOrganizationId(orgId); |
| | | save(user); |
| | |
| | | |
| | | @Override |
| | | public Result updatePassword(String userId, String usedPass, String pass) { |
| | | String hql = null; |
| | | |
| | | List<Object> params = null; |
| | | |
| | | User user = read(User.class, userId); |
| | | //随机字符串 |
| | | String salt= UUID.randomUUID().toString(); |
| | | |
| | | String salts = user.getSalt(); |
| | | //盐值 |
| | | user.setSalt(salt); |
| | | //对密码进行加密处理 |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+pass).getBytes()); |
| | | String newPasswords= DigestUtils.md5DigestAsHex((salts+usedPass).getBytes()); |
| | | if (StringUtils.isNotBlank(usedPass) && StringUtils.isNotBlank(pass)) { |
| | | if (!user.getPassword().equals(usedPass)) { |
| | | if (!user.getPassword().equals(newPasswords)) { |
| | | return new Result(false, "输入的旧密码错误"); |
| | | } |
| | | user.setPassword(pass); |
| | | user.setPassword(newPassword); |
| | | } |
| | | TraceUtils.setUpdateTrace(user); |
| | | save(user); |
| | |
| | | user.setImgPath(headPath); |
| | | TraceUtils.setUpdateTrace(user); |
| | | save(user); |
| | | this.bulkUpdate("update StuStudent set photo = ? , " + |
| | | " updateTime = sysdate(), updateId = ? , updator = ? where userId = ? " , |
| | | new Object[]{ headPath,userId, ClientUtils.getUserName(), userId } ); |
| | | |
| | | return new Result(true); |
| | | } |
| | |
| | | /** |
| | | * 用户设置手机号 |
| | | * |
| | | * @param headPath |
| | | * @param |
| | | * @return |
| | | */ |
| | | public Result updateUserInfo(String userId, String mobilePhone) { |
| | |
| | | public Result updatePassword(String userId, String password) { |
| | | User user = read(User.class, userId); |
| | | |
| | | //随机字符串 |
| | | String salt= UUID.randomUUID().toString(); |
| | | //盐值 |
| | | user.setSalt(salt); |
| | | //对密码进行加密处理 |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); |
| | | TraceUtils.setUpdateTrace(user); |
| | | user.setPassword(password); |
| | | user.setPassword(newPassword); |
| | | |
| | | save(user); |
| | | |
| | |
| | | @Override |
| | | public Result updateUser(String userId, String name, String account, String mobilePhone, String password, |
| | | Boolean sex) { |
| | | |
| | | User dbUser = read(User.class, userId); |
| | | |
| | | String salt = dbUser.getSalt(); |
| | | if(salt == null){ |
| | | salt= UUID.randomUUID().toString(); |
| | | dbUser.setSalt(salt); |
| | | salt = dbUser.getSalt(); |
| | | } |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); |
| | | if (dbUser.getAccount().equals(account)) { |
| | | dbUser.setName(name); |
| | | dbUser.setMobilePhone(mobilePhone); |
| | | dbUser.setPassword(password); |
| | | dbUser.setPassword(newPassword); |
| | | TraceUtils.setCreateTrace(dbUser); |
| | | save(dbUser); |
| | | return new Result(true, "success"); |
| | |
| | | dbUser.setAccount(account); |
| | | dbUser.setName(name); |
| | | dbUser.setMobilePhone(mobilePhone); |
| | | dbUser.setPassword(password); |
| | | dbUser.setPassword(newPassword); |
| | | TraceUtils.setCreateTrace(dbUser); |
| | | save(dbUser); |
| | | return new Result(true, "success"); |
| | |
| | | return findCount("from User where account = ?", CollectionUtils.newList(account)) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Result countUser() { |
| | | String hql = "from count User where sex=? and deleteFlag is false"; |
| | | return new Result(true,findCount(hql,CollectionUtils.newList(1))); |
| | | } |
| | | @Override |
| | | public Result countUsersex() { |
| | | String hql = "from count User where sex=? and deleteFlag is false"; |
| | | return new Result(true,findCount(hql,CollectionUtils.newList(0))); |
| | | } |
| | | } |