[新增]按id数组查询用户信息的接口
All checks were successful
CI / Docker-Build (push) Successful in 2m14s

This commit is contained in:
thesai 2024-09-24 16:43:07 +08:00
parent ac87b0dbe9
commit 235f4dce5b
3 changed files with 178 additions and 145 deletions

View File

@ -4,15 +4,25 @@ import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.UserQueryVO; import club.joylink.rtss.vo.UserQueryVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.user.*; import club.joylink.rtss.vo.client.user.MobileInfoVO;
import club.joylink.rtss.vo.client.user.RetrievePwdVO;
import club.joylink.rtss.vo.client.user.UpdateEmailVO;
import club.joylink.rtss.vo.client.user.UpdateMobileVO;
import club.joylink.rtss.vo.client.user.UpdatePasswordVO;
import club.joylink.rtss.vo.user.AccountCreateVO; import club.joylink.rtss.vo.user.AccountCreateVO;
import club.joylink.rtss.vo.user.AccountRegisterVO; import club.joylink.rtss.vo.user.AccountRegisterVO;
import club.joylink.rtss.vo.user.UserRegisterCheck; import club.joylink.rtss.vo.user.UserRegisterCheck;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 系统账户接口 * 系统账户接口
@ -21,165 +31,178 @@ import java.util.List;
@RequestMapping("/api/userinfo") @RequestMapping("/api/userinfo")
public class SysAccountController { public class SysAccountController {
@Autowired @Autowired
private ISysUserService iSysUserService; private ISysUserService iSysUserService;
@PostMapping("/register") @PostMapping("/register")
public void register(@RequestBody @Validated(value = UserRegisterCheck.class) AccountCreateVO accountCreateVO) { public void register(
this.iSysUserService.register(accountCreateVO); @RequestBody @Validated(value = UserRegisterCheck.class) AccountCreateVO accountCreateVO) {
} this.iSysUserService.register(accountCreateVO);
}
/** /**
* 新注册接口 * 新注册接口
*/ */
@PostMapping("/register2") @PostMapping("/register2")
public void register2(@RequestBody @Validated AccountRegisterVO registerVO) { public void register2(@RequestBody @Validated AccountRegisterVO registerVO) {
this.iSysUserService.register2(registerVO); this.iSysUserService.register2(registerVO);
} }
/** /**
*根据姓名或电话号查询用户 * 根据姓名或电话号查询用户
*/ */
@GetMapping(path="/nameOrMobile") @GetMapping(path = "/nameOrMobile")
public List<AccountVO> queryUserByNameOrMobile(String query) { public List<AccountVO> queryUserByNameOrMobile(String query) {
List<AccountVO> list = this.iSysUserService.queryUserByNameOrMobile(query); List<AccountVO> list = this.iSysUserService.queryUserByNameOrMobile(query);
return list; return list;
} }
/** /**
* 手机号是否已经注册 * 手机号是否已经注册
*/ */
@GetMapping("/isExist/mobile") @GetMapping("/isExist/mobile")
public boolean isMobileExist(String mobile) { public boolean isMobileExist(String mobile) {
return iSysUserService.isSameMobileExist(mobile); return iSysUserService.isSameMobileExist(mobile);
} }
/** /**
* 邮箱是否已经注册 * 邮箱是否已经注册
*/ */
@GetMapping("/isExist/email") @GetMapping("/isExist/email")
public boolean isEmailExist(String email) { public boolean isEmailExist(String email) {
return iSysUserService.isSameEmailExist(email); return iSysUserService.isSameEmailExist(email);
} }
/** /**
*根据用户id获取用户信息 * 根据用户id获取用户信息
*/ */
@GetMapping(path = "/{id}") @GetMapping(path = "/{id}")
public AccountVO getUserBaseInfoById(@PathVariable Long id) { public AccountVO getUserBaseInfoById(@PathVariable Long id) {
return this.iSysUserService.getUserBaseInfoById(id); return this.iSysUserService.getUserBaseInfoById(id);
} }
/** /**
*修改用户信息 * 修改用户信息
*/ */
@PutMapping(path = "/{id}") @PutMapping(path = "/{id}")
public void modify(@PathVariable Long id, @RequestBody AccountVO userInfo, String vdcode) { public void modify(@PathVariable Long id, @RequestBody AccountVO userInfo, String vdcode) {
this.iSysUserService.modify(id, userInfo, vdcode); this.iSysUserService.modify(id, userInfo, vdcode);
} }
/** /**
*微信关注事件 * 微信关注事件
*/ */
@GetMapping(path = "/wxsubscribe") @GetMapping(path = "/wxsubscribe")
public void wxSubscribe(@RequestParam String wxId) { public void wxSubscribe(@RequestParam String wxId) {
iSysUserService.wxSubscribeEventHandle(wxId); iSysUserService.wxSubscribeEventHandle(wxId);
} }
/** /**
*批量修改用户的openId为unionId * 批量修改用户的openId为unionId
*/ */
@PutMapping(path = "/batchchange/unionid") @PutMapping(path = "/batchchange/unionid")
public void batchChangeOpenId2UnionId() { public void batchChangeOpenId2UnionId() {
this.iSysUserService.batchChangeOpenId2UnionId(); this.iSysUserService.batchChangeOpenId2UnionId();
} }
/** /**
*更新用户真实姓名 * 更新用户真实姓名
*/ */
@PutMapping(path = "/{id}/name") @PutMapping(path = "/{id}/name")
public void updateName(@PathVariable Long id, String name) { public void updateName(@PathVariable Long id, String name) {
this.iSysUserService.updateUserName(id, name); this.iSysUserService.updateUserName(id, name);
} }
/** /**
*更新用户昵称 * 更新用户昵称
*/ */
@PutMapping(path = "/{id}/nickname") @PutMapping(path = "/{id}/nickname")
public void updateNickname(@PathVariable Long id, String nickname) { public void updateNickname(@PathVariable Long id, String nickname) {
this.iSysUserService.updateNickname(id, nickname); this.iSysUserService.updateNickname(id, nickname);
} }
/** /**
*用户上传头像 * 用户上传头像
*/ */
@PostMapping(path = "/{id}/avatar") @PostMapping(path = "/{id}/avatar")
public void uploadAvatar(@PathVariable Long id, @RequestBody AccountVO accountVO) { public void uploadAvatar(@PathVariable Long id, @RequestBody AccountVO accountVO) {
this.iSysUserService.updateAvatar(id, accountVO.getAvatarPath()); this.iSysUserService.updateAvatar(id, accountVO.getAvatarPath());
} }
/** /**
*发送手机验证码 * 发送手机验证码
*/ */
@PostMapping(path = "/mobile/code") @PostMapping(path = "/mobile/code")
public String sendMobileValidCode(@RequestBody MobileInfoVO mobileInfoVO) { public String sendMobileValidCode(@RequestBody MobileInfoVO mobileInfoVO) {
return this.iSysUserService.sendMobileValidCode(mobileInfoVO); return this.iSysUserService.sendMobileValidCode(mobileInfoVO);
} }
/** /**
*发送邮箱验证码 * 发送邮箱验证码
*/ */
@PostMapping(path = "/email/code") @PostMapping(path = "/email/code")
public String sendEmailValidCode(String email) { public String sendEmailValidCode(String email) {
return this.iSysUserService.sendEmailValidCode(email); return this.iSysUserService.sendEmailValidCode(email);
} }
/** /**
*更新用户手机号 * 更新用户手机号
*/ */
@PutMapping(path = "/{id}/mobile") @PutMapping(path = "/{id}/mobile")
public void updateMobile(@PathVariable Long id, @RequestBody @Validated UpdateMobileVO updateMobileVO) { public void updateMobile(@PathVariable Long id,
this.iSysUserService.updateMobile(id, updateMobileVO); @RequestBody @Validated UpdateMobileVO updateMobileVO) {
} this.iSysUserService.updateMobile(id, updateMobileVO);
}
/** /**
*更新用户邮箱 * 更新用户邮箱
*/ */
@PutMapping(path = "/{id}/email") @PutMapping(path = "/{id}/email")
public void updateEmail(@PathVariable Long id, @RequestBody @Validated UpdateEmailVO updateEmailVO) { public void updateEmail(@PathVariable Long id,
this.iSysUserService.updateEmail(id, updateEmailVO); @RequestBody @Validated UpdateEmailVO updateEmailVO) {
} this.iSysUserService.updateEmail(id, updateEmailVO);
}
/** /**
*更新用户登陆密码 * 更新用户登陆密码
*/ */
@PutMapping(path = "/{id}/password") @PutMapping(path = "/{id}/password")
public void updatePassword(@PathVariable Long id, @RequestBody @Validated UpdatePasswordVO updatePasswordVO) { public void updatePassword(@PathVariable Long id,
this.iSysUserService.updatePassword(id, updatePasswordVO); @RequestBody @Validated UpdatePasswordVO updatePasswordVO) {
} this.iSysUserService.updatePassword(id, updatePasswordVO);
}
/** /**
* 按条件分页查询指定来源的账号 * 按条件分页查询指定来源的账号
*/ */
@GetMapping("/page/criteria/{source}") @GetMapping("/page/criteria/{source}")
public PageVO<AccountVO> queryPagedAccountOfTheSource(UserQueryVO queryVO, @PathVariable String source) { public PageVO<AccountVO> queryPagedAccountOfTheSource(UserQueryVO queryVO,
queryVO.setSource(source); @PathVariable String source) {
return this.iSysUserService.queryPagedUser(queryVO); queryVO.setSource(source);
} return this.iSysUserService.queryPagedUser(queryVO);
}
/** /**
* 超管重置用户密码 * 超管重置用户密码
*/ */
@PutMapping("/{id}/reset/pwd") @PutMapping("/{id}/reset/pwd")
public void resetPwd(@PathVariable long id) { public void resetPwd(@PathVariable long id) {
iSysUserService.resetPwd(id); iSysUserService.resetPwd(id);
} }
/** /**
* 找回密码 * 找回密码
*/ */
@PutMapping("/retrieve/pwd") @PutMapping("/retrieve/pwd")
public void retrievePwd(@RequestBody @Validated RetrievePwdVO vo) { public void retrievePwd(@RequestBody @Validated RetrievePwdVO vo) {
iSysUserService.retrievePwd(vo); iSysUserService.retrievePwd(vo);
} }
/**
* 根据用户id列表获取用户信息
*/
@PostMapping("/list/ids")
public List<AccountVO> listByIds(@RequestBody List<Long> ids) {
return iSysUserService.listByIds(ids);
}
} }

View File

@ -363,4 +363,6 @@ public interface ISysUserService {
boolean isSameMobileExist(String mobile); boolean isSameMobileExist(String mobile);
boolean isSameEmailExist(String email); boolean isSameEmailExist(String email);
List<AccountVO> listByIds(List<Long> ids);
} }

View File

@ -1112,6 +1112,14 @@ public class SysUserService implements ISysUserService {
return sysAccountDAO.countByExample(example) > 0; return sysAccountDAO.countByExample(example) > 0;
} }
@Override
public List<AccountVO> listByIds(List<Long> ids) {
SysAccountExample example = new SysAccountExample();
example.createCriteria().andIdIn(ids);
List<SysAccount> sysAccounts = sysAccountDAO.selectByExample(example);
return AccountVO.convertFromDB(sysAccounts);
}
/** /**
* 查询包含组织信息的用户信息 * 查询包含组织信息的用户信息
*/ */