修改了各个角色的信息查询接口返回值,主要增加用户名密码和权限信息
This commit is contained in:
parent
6af74df222
commit
4e93cfb624
@ -2,11 +2,11 @@ package com.zoo.controller;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.zoo.common.R;
|
import com.zoo.common.R;
|
||||||
import com.zoo.entity.Admin;
|
import com.zoo.dto.AdminDto;
|
||||||
import com.zoo.entity.Animal;
|
import com.zoo.entity.*;
|
||||||
import com.zoo.entity.Keeper;
|
import com.zoo.service.IAccountService;
|
||||||
import com.zoo.entity.Veterinary;
|
|
||||||
import com.zoo.service.IAdminService;
|
import com.zoo.service.IAdminService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -14,7 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -29,17 +32,40 @@ import java.util.List;
|
|||||||
public class AdminController {
|
public class AdminController {
|
||||||
@Autowired
|
@Autowired
|
||||||
IAdminService iAdminService;
|
IAdminService iAdminService;
|
||||||
|
@Autowired
|
||||||
|
IAccountService iAccountService;
|
||||||
@GetMapping("/info")
|
@GetMapping("/info")
|
||||||
public R info(Integer id){
|
public R info(Integer id){
|
||||||
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
|
||||||
|
QueryWrapper<Account> queryWrapper1 = new QueryWrapper<>();
|
||||||
if (id!=null){
|
if (id!=null){
|
||||||
queryWrapper.eq("roleid",id);
|
queryWrapper.eq("roleid",id);
|
||||||
Admin admin = iAdminService.getOne(queryWrapper);
|
Admin admin = iAdminService.getOne(queryWrapper);
|
||||||
return R.success(admin);
|
queryWrapper1.eq("roleid",id);
|
||||||
|
queryWrapper1.eq("permissions",0);
|
||||||
|
Account one = iAccountService.getOne(queryWrapper1);
|
||||||
|
AdminDto adminDto = new AdminDto();
|
||||||
|
BeanUtils.copyProperties(admin,adminDto);
|
||||||
|
adminDto.setPassword(one.getPassword());
|
||||||
|
adminDto.setUsername(one.getUsername());
|
||||||
|
adminDto.setPermissions(0);
|
||||||
|
return R.success(adminDto);
|
||||||
}
|
}
|
||||||
List<Admin> list = iAdminService.list();
|
List<Admin> list = iAdminService.list();
|
||||||
return R.success(list);
|
List<AdminDto> adminDtoList = list.stream().map((item)->{
|
||||||
|
AdminDto adminDto = new AdminDto();
|
||||||
|
BeanUtils.copyProperties(item,adminDto);
|
||||||
|
QueryWrapper<Account> queryWrapper2 = new QueryWrapper<>();
|
||||||
|
queryWrapper2.eq("roleid",item.getRoleid());
|
||||||
|
queryWrapper2.eq("permissions",0);
|
||||||
|
Account one = iAccountService.getOne(queryWrapper2);
|
||||||
|
adminDto.setPassword(one.getPassword());
|
||||||
|
adminDto.setUsername(one.getUsername());
|
||||||
|
adminDto.setPermissions(0);
|
||||||
|
return adminDto;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return R.success(adminDtoList);
|
||||||
}
|
}
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public R add(Admin admin){
|
public R add(Admin admin){
|
||||||
|
@ -2,12 +2,13 @@ package com.zoo.controller;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.zoo.common.R;
|
import com.zoo.common.R;
|
||||||
import com.zoo.entity.Animal;
|
import com.zoo.dto.AdminDto;
|
||||||
import com.zoo.entity.Breedingplan;
|
import com.zoo.dto.KeeperDto;
|
||||||
import com.zoo.entity.Keeper;
|
import com.zoo.entity.*;
|
||||||
import com.zoo.entity.Veterinary;
|
import com.zoo.service.IAccountService;
|
||||||
import com.zoo.service.IKeeperService;
|
import com.zoo.service.IKeeperService;
|
||||||
import com.zoo.service.IVeterinaryService;
|
import com.zoo.service.IVeterinaryService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -16,6 +17,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -30,16 +32,39 @@ import java.util.List;
|
|||||||
public class KeeperController {
|
public class KeeperController {
|
||||||
@Autowired
|
@Autowired
|
||||||
IKeeperService iKeeperService;
|
IKeeperService iKeeperService;
|
||||||
|
@Autowired
|
||||||
|
IAccountService iAccountService;
|
||||||
@GetMapping("info")
|
@GetMapping("info")
|
||||||
public R info(Integer roleid){
|
public R info(Integer roleid){
|
||||||
|
QueryWrapper<Keeper> queryWrapper = new QueryWrapper<>();
|
||||||
|
QueryWrapper<Account> queryWrapper1 = new QueryWrapper<>();
|
||||||
if (roleid!=null){
|
if (roleid!=null){
|
||||||
QueryWrapper<Keeper> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("roleid",roleid);
|
queryWrapper.eq("roleid",roleid);
|
||||||
Keeper keeper = iKeeperService.getOne(queryWrapper);
|
Keeper keeper = iKeeperService.getOne(queryWrapper);
|
||||||
return R.success(keeper);
|
queryWrapper1.eq("roleid",roleid);
|
||||||
|
queryWrapper1.eq("permissions",1);
|
||||||
|
Account one = iAccountService.getOne(queryWrapper1);
|
||||||
|
KeeperDto keeperDto = new KeeperDto();
|
||||||
|
BeanUtils.copyProperties(keeper,keeperDto);
|
||||||
|
keeperDto.setPassword(one.getPassword());
|
||||||
|
keeperDto.setUsername(one.getUsername());
|
||||||
|
keeperDto.setPermissions(1);
|
||||||
|
return R.success(keeperDto);
|
||||||
}
|
}
|
||||||
List<Keeper> list = iKeeperService.list();
|
List<Keeper> list = iKeeperService.list();
|
||||||
return R.success(list);
|
List<KeeperDto> keeperDtoList = list.stream().map((item)->{
|
||||||
|
KeeperDto keeperDto = new KeeperDto();
|
||||||
|
BeanUtils.copyProperties(item,keeperDto);
|
||||||
|
QueryWrapper<Account> queryWrapper2 = new QueryWrapper<>();
|
||||||
|
queryWrapper2.eq("roleid",item.getRoleid());
|
||||||
|
queryWrapper2.eq("permissions",1);
|
||||||
|
Account one = iAccountService.getOne(queryWrapper2);
|
||||||
|
keeperDto.setPassword(one.getPassword());
|
||||||
|
keeperDto.setUsername(one.getUsername());
|
||||||
|
keeperDto.setPermissions(1);
|
||||||
|
return keeperDto;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return R.success(keeperDtoList);
|
||||||
}
|
}
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public R add(Keeper keeper){
|
public R add(Keeper keeper){
|
||||||
|
@ -2,9 +2,14 @@ package com.zoo.controller;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.zoo.common.R;
|
import com.zoo.common.R;
|
||||||
|
import com.zoo.dto.KeeperDto;
|
||||||
|
import com.zoo.dto.VeterinaryDto;
|
||||||
|
import com.zoo.entity.Account;
|
||||||
import com.zoo.entity.Keeper;
|
import com.zoo.entity.Keeper;
|
||||||
import com.zoo.entity.Veterinary;
|
import com.zoo.entity.Veterinary;
|
||||||
|
import com.zoo.service.IAccountService;
|
||||||
import com.zoo.service.IVeterinaryService;
|
import com.zoo.service.IVeterinaryService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -13,6 +18,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -27,16 +33,39 @@ import java.util.List;
|
|||||||
public class VeterinaryController {
|
public class VeterinaryController {
|
||||||
@Autowired
|
@Autowired
|
||||||
IVeterinaryService iVeterinaryService;
|
IVeterinaryService iVeterinaryService;
|
||||||
|
@Autowired
|
||||||
|
IAccountService iAccountService;
|
||||||
@GetMapping("info")
|
@GetMapping("info")
|
||||||
public R info(Integer roleid){
|
public R info(Integer roleid){
|
||||||
|
QueryWrapper<Veterinary> queryWrapper = new QueryWrapper<>();
|
||||||
|
QueryWrapper<Account> queryWrapper1 = new QueryWrapper<>();
|
||||||
if (roleid!=null){
|
if (roleid!=null){
|
||||||
QueryWrapper<Veterinary> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("roleid",roleid);
|
queryWrapper.eq("roleid",roleid);
|
||||||
Veterinary veterinary = iVeterinaryService.getOne(queryWrapper);
|
Veterinary keeper = iVeterinaryService.getOne(queryWrapper);
|
||||||
return R.success(veterinary);
|
queryWrapper1.eq("roleid",roleid);
|
||||||
|
queryWrapper1.eq("permissions",2);
|
||||||
|
Account one = iAccountService.getOne(queryWrapper1);
|
||||||
|
VeterinaryDto veterinaryDto = new VeterinaryDto();
|
||||||
|
BeanUtils.copyProperties(keeper,veterinaryDto);
|
||||||
|
veterinaryDto.setPassword(one.getPassword());
|
||||||
|
veterinaryDto.setUsername(one.getUsername());
|
||||||
|
veterinaryDto.setPermissions(2);
|
||||||
|
return R.success(veterinaryDto);
|
||||||
}
|
}
|
||||||
List<Veterinary> list = iVeterinaryService.list();
|
List<Veterinary> list = iVeterinaryService.list();
|
||||||
return R.success(list);
|
List<Veterinary> veterinaryList = list.stream().map((item)->{
|
||||||
|
VeterinaryDto veterinaryDto = new VeterinaryDto();
|
||||||
|
BeanUtils.copyProperties(item,veterinaryDto);
|
||||||
|
QueryWrapper<Account> queryWrapper2 = new QueryWrapper<>();
|
||||||
|
queryWrapper2.eq("roleid",item.getRoleid());
|
||||||
|
queryWrapper2.eq("permissions",2);
|
||||||
|
Account one = iAccountService.getOne(queryWrapper2);
|
||||||
|
veterinaryDto.setPassword(one.getPassword());
|
||||||
|
veterinaryDto.setUsername(one.getUsername());
|
||||||
|
veterinaryDto.setPermissions(2);
|
||||||
|
return veterinaryDto;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return R.success(veterinaryList);
|
||||||
}
|
}
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public R add(Veterinary veterinary){
|
public R add(Veterinary veterinary){
|
||||||
|
@ -5,6 +5,31 @@ import com.zoo.entity.Admin;
|
|||||||
|
|
||||||
public class AdminDto extends Admin {
|
public class AdminDto extends Admin {
|
||||||
private Integer permissions;
|
private Integer permissions;
|
||||||
|
/**
|
||||||
|
* 角色账号
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getPermissions() {
|
public Integer getPermissions() {
|
||||||
return permissions;
|
return permissions;
|
||||||
|
@ -4,6 +4,31 @@ import com.zoo.entity.Keeper;
|
|||||||
|
|
||||||
public class KeeperDto extends Keeper {
|
public class KeeperDto extends Keeper {
|
||||||
private Integer permissions;
|
private Integer permissions;
|
||||||
|
/**
|
||||||
|
* 角色账号
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getPermissions() {
|
public Integer getPermissions() {
|
||||||
return permissions;
|
return permissions;
|
||||||
|
@ -4,6 +4,31 @@ import com.zoo.entity.Veterinary;
|
|||||||
|
|
||||||
public class VeterinaryDto extends Veterinary {
|
public class VeterinaryDto extends Veterinary {
|
||||||
private Integer permissions;
|
private Integer permissions;
|
||||||
|
/**
|
||||||
|
* 角色账号
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getPermissions() {
|
public Integer getPermissions() {
|
||||||
return permissions;
|
return permissions;
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user