修改了各个角色的信息查询接口返回值,主要增加用户名密码和权限信息
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.zoo.common.R;
|
||||
import com.zoo.entity.Admin;
|
||||
import com.zoo.entity.Animal;
|
||||
import com.zoo.entity.Keeper;
|
||||
import com.zoo.entity.Veterinary;
|
||||
import com.zoo.dto.AdminDto;
|
||||
import com.zoo.entity.*;
|
||||
import com.zoo.service.IAccountService;
|
||||
import com.zoo.service.IAdminService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -29,17 +32,40 @@ import java.util.List;
|
||||
public class AdminController {
|
||||
@Autowired
|
||||
IAdminService iAdminService;
|
||||
@Autowired
|
||||
IAccountService iAccountService;
|
||||
@GetMapping("/info")
|
||||
public R info(Integer id){
|
||||
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
QueryWrapper<Account> queryWrapper1 = new QueryWrapper<>();
|
||||
if (id!=null){
|
||||
queryWrapper.eq("roleid",id);
|
||||
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();
|
||||
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")
|
||||
public R add(Admin admin){
|
||||
|
@ -2,12 +2,13 @@ package com.zoo.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zoo.common.R;
|
||||
import com.zoo.entity.Animal;
|
||||
import com.zoo.entity.Breedingplan;
|
||||
import com.zoo.entity.Keeper;
|
||||
import com.zoo.entity.Veterinary;
|
||||
import com.zoo.dto.AdminDto;
|
||||
import com.zoo.dto.KeeperDto;
|
||||
import com.zoo.entity.*;
|
||||
import com.zoo.service.IAccountService;
|
||||
import com.zoo.service.IKeeperService;
|
||||
import com.zoo.service.IVeterinaryService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -16,6 +17,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -30,16 +32,39 @@ import java.util.List;
|
||||
public class KeeperController {
|
||||
@Autowired
|
||||
IKeeperService iKeeperService;
|
||||
@Autowired
|
||||
IAccountService iAccountService;
|
||||
@GetMapping("info")
|
||||
public R info(Integer roleid){
|
||||
if (roleid!=null){
|
||||
QueryWrapper<Keeper> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<Account> queryWrapper1 = new QueryWrapper<>();
|
||||
if (roleid!=null){
|
||||
queryWrapper.eq("roleid",roleid);
|
||||
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();
|
||||
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")
|
||||
public R add(Keeper keeper){
|
||||
|
@ -2,9 +2,14 @@ package com.zoo.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.Veterinary;
|
||||
import com.zoo.service.IAccountService;
|
||||
import com.zoo.service.IVeterinaryService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -13,6 +18,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -27,16 +33,39 @@ import java.util.List;
|
||||
public class VeterinaryController {
|
||||
@Autowired
|
||||
IVeterinaryService iVeterinaryService;
|
||||
@Autowired
|
||||
IAccountService iAccountService;
|
||||
@GetMapping("info")
|
||||
public R info(Integer roleid){
|
||||
if (roleid!=null){
|
||||
QueryWrapper<Veterinary> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<Account> queryWrapper1 = new QueryWrapper<>();
|
||||
if (roleid!=null){
|
||||
queryWrapper.eq("roleid",roleid);
|
||||
Veterinary veterinary = iVeterinaryService.getOne(queryWrapper);
|
||||
return R.success(veterinary);
|
||||
Veterinary keeper = iVeterinaryService.getOne(queryWrapper);
|
||||
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();
|
||||
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")
|
||||
public R add(Veterinary veterinary){
|
||||
|
@ -5,6 +5,31 @@ import com.zoo.entity.Admin;
|
||||
|
||||
public class AdminDto extends Admin {
|
||||
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() {
|
||||
return permissions;
|
||||
|
@ -4,6 +4,31 @@ import com.zoo.entity.Keeper;
|
||||
|
||||
public class KeeperDto extends Keeper {
|
||||
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() {
|
||||
return permissions;
|
||||
|
@ -4,6 +4,31 @@ import com.zoo.entity.Veterinary;
|
||||
|
||||
public class VeterinaryDto extends Veterinary {
|
||||
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() {
|
||||
return permissions;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user