admin
2024-10-17 b30fb8afd3cd6228bda9b182dc412bb3c8daf69c
src/main/java/com/yeshi/buwan/service/imp/UserService.java
@@ -12,6 +12,7 @@
import com.yeshi.buwan.exception.user.LoginUserException;
import com.yeshi.buwan.exception.user.RegisterUserException;
import com.yeshi.buwan.service.inter.LoginUserService;
import com.yeshi.buwan.service.inter.system.SystemConfigService;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.cache.annotation.Cacheable;
@@ -47,11 +48,22 @@
    @Resource
    private LoginUserService loginUserService;
    @Resource
    private SystemConfigService systemConfigService;
    // 用户操作
    public List<UserInfo> getUserList(int system, int page) {
        return userDao.list("from UserInfo u where u.system.id=? order by u.createtime desc",
                (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{system + ""});
    }
    //设置昵称
    public void setNickName(Long uid, String nickName) {
        LoginUser update = new LoginUser();
        update.setId(uid + "");
        update.setName(nickName);
        loginUserDao.updateSelective(update);
    }
    // 获取用户数量
@@ -85,7 +97,7 @@
    }
    public void updateLoginUserInfo(LoginUser lu) {
        loginUserDao.update(lu);
        loginUserDao.updateSelective(lu);
    }
    public String getUid(String device, String system, String imei, String mac, String lat, String lng) {
@@ -243,10 +255,11 @@
        if (loginUser != null) {
            loginUser.setLoginType(dto.getLoginType());
            loginUserDao.update(loginUser);
            loginUserDao.updateSelective(loginUser);
        }
        if (loginUserExtra != null) {
            loginUserExtra.setUtdId(dto.getUtdId());
            loginUserExtraDao.updateSelective(loginUserExtra);
        }
@@ -343,7 +356,7 @@
                loginUser = new LoginUser();
                loginUser.setLoginType(LoginUser.LOGIN_TYPE_PHONE);
                loginUser.setName(null);
                loginUser.setName(dto.getNickName());
                loginUser.setPhone(dto.getPhone());
                loginUserExtra = new LoginUserExtra();
@@ -365,8 +378,10 @@
        loginUser.setId(uid + "");
        if (StringUtil.isNullOrEmpty(loginUser.getName())) {
            //TODO 昵称前缀
//            systemConfigService.getConfigValueByKeyCache("");
            //设置默认用户昵称
            String nickName = "无名氏";
            String nickName = "ID_" + uid;
            LoginUser update = new LoginUser();
            update.setId(uid + "");
            update.setName(nickName);
@@ -391,6 +406,15 @@
        return null;
    }
    public LoginUser getValidLoginUserByEmail(String email, String systemId) {
        List<LoginUser> userList = loginUserDao.list("from LoginUser lu where lu.systemId=? and lu.email=? and lu.state=?", systemId, email, LoginUser.STATE_NORMAL);
        if(userList!=null&&userList.size()>0){
             return userList.get(0);
        }
        return null;
    }
    /**
     * 用户注销
     *
@@ -406,7 +430,7 @@
            throw new Exception("账户已被注销");
        }
        user.setState(LoginUser.STATE_UNREGISTER);
        loginUserDao.update(user);
        loginUserDao.updateSelective(user);
    }
    // 邮箱注册