权限管理接口开发
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
package com.micro.fast.upms.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UpmsUserOrganizationMapper {
|
||||
|
||||
/**
|
||||
* 批量插入一个用户和多个组织的关系
|
||||
* @param userId
|
||||
* @param orgIds
|
||||
* @return
|
||||
*/
|
||||
int batchInsertOneUserWithManyOrg(@Param("userId") Integer userId, @Param("orgIds") List<Integer> orgIds);
|
||||
|
||||
/**
|
||||
* 批量删除一个用户和多个组织的关系
|
||||
* @param userId
|
||||
* @param orgs
|
||||
* @return
|
||||
*/
|
||||
int batchDeleteByUserIdOrganizationId(@Param("userId") Integer userId, @Param("orgIds") List<Integer> orgs);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.micro.fast.upms.service;
|
||||
|
||||
import com.micro.fast.common.service.SsmService;
|
||||
|
||||
/**
|
||||
* 系统管理接口
|
||||
* @author lsy
|
||||
*/
|
||||
public interface UpmsSystemService<T,ID> extends SsmService<T,ID>{
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.micro.fast.upms.service;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
public interface UpmsUserRoleService{
|
||||
|
||||
/**
|
||||
* 批量建立用户和角色的关系
|
||||
* @param userId 用户id
|
||||
* @param roleIds 角色id的集合
|
||||
* @return
|
||||
*/
|
||||
ServerResponse batchInsert(Integer userId, List<Integer> roleIds);
|
||||
|
||||
/**
|
||||
* 批量解除用户和角色的关系
|
||||
* @param userId 用户id
|
||||
* @param roleIds 角色id的集合
|
||||
* @return
|
||||
*/
|
||||
ServerResponse batchDelete(Integer userId, List<Integer> roleIds);
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.micro.fast.upms.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.common.service.impl.SsmServiceImpl;
|
||||
import com.micro.fast.upms.dao.UpmsPermissionMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsPermission;
|
||||
import com.micro.fast.upms.service.UpmsPermissionService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
@Service
|
||||
public class UpmsPermissionServiceImpl extends SsmServiceImpl<UpmsPermission,Integer,UpmsPermissionMapper>
|
||||
implements UpmsPermissionService<UpmsPermission,Integer>,InitializingBean {
|
||||
|
||||
@Autowired
|
||||
private UpmsPermissionMapper mapper;
|
||||
|
||||
/**
|
||||
* 在这个bean初始化完成后覆盖父类的mapper
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.setMapper(this.mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getPermissionsByUserIdandPTypeandType(Integer userId, Integer type, Integer pType) {
|
||||
List<UpmsPermission> upmsPermissions = mapper.selectByUserIdAndType(userId, pType, type);
|
||||
return ServerResponse.successMsgData("查询权限成功",upmsPermissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getPermissionByRoleAndType(Integer type, Integer roleId) {
|
||||
List<UpmsPermission> upmsPermissions = mapper.selectByRoleIdAndType(roleId, type);
|
||||
return ServerResponse.successData(upmsPermissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getUnHavePermissionByRoleIdAndTypeOrSystemIdOrPermissionName(Integer roleId, Integer type, Integer systemId, String name, Integer pageNum, Integer pageSize) {
|
||||
// 最近近创建的在前
|
||||
PageHelper.startPage(pageNum,pageSize,"ctime_desc");
|
||||
List<UpmsPermission> upmsPermissions = mapper.selectPageRoleUnHavePermissionByCondition(roleId, type, systemId, name);
|
||||
PageInfo pageInfo = new PageInfo(upmsPermissions);
|
||||
return ServerResponse.successData(pageInfo);
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.micro.fast.upms.service.impl;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.dao.UpmsRolePermissionMapper;
|
||||
import com.micro.fast.upms.service.UpmsRolePermissionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
@Service
|
||||
public class UpmsRolePermissionServiceImpl implements UpmsRolePermissionService {
|
||||
|
||||
@Autowired
|
||||
private UpmsRolePermissionMapper mapper;
|
||||
|
||||
@Override
|
||||
public ServerResponse batchAddRolePermission(Integer roleId, List<Integer> permissionIds) {
|
||||
int i = mapper.batchInsert(roleId, permissionIds);
|
||||
if (i == permissionIds.size()) {
|
||||
return ServerResponse.successMsg("批量增加成功");
|
||||
}
|
||||
return ServerResponse.errorMsg("批量增加权限成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse batchDeleteRolePermission(Integer roleId, List<Integer> permissionIds) {
|
||||
int i = mapper.batchDelete(roleId, permissionIds);
|
||||
if (i == permissionIds.size()){
|
||||
return ServerResponse.successMsg("批量删除权限成功");
|
||||
}
|
||||
return ServerResponse.errorMsg("批量删除权限失败");
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.micro.fast.upms.service.impl;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.dao.UpmsUserOrganizationMapper;
|
||||
import com.micro.fast.upms.service.UpmsUserOrganizationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
@Service
|
||||
public class UpmsUserOrganizationServiceImpl implements UpmsUserOrganizationService {
|
||||
|
||||
@Autowired
|
||||
private UpmsUserOrganizationMapper mapper;
|
||||
|
||||
@Override
|
||||
public ServerResponse batchInsert(Integer userId, List orgIds) {
|
||||
int i = mapper.batchInsertOneUserWithManyOrg(userId, orgIds);
|
||||
if (i>0) {
|
||||
return ServerResponse.successMsg("加入组织成功");
|
||||
} else {
|
||||
return ServerResponse.errorMsg("加入组织失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse batchDelete(Integer userId, List orgIds) {
|
||||
int i = mapper.batchDeleteByUserIdOrganizationId(userId, orgIds);
|
||||
if (i>0) {
|
||||
return ServerResponse.successMsg("退出组织成功");
|
||||
} else {
|
||||
return ServerResponse.errorMsg("退出组织失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.micro.fast.upms.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.micro.fast.boot.starter.common.exception.SystemException;
|
||||
import com.micro.fast.boot.starter.common.exception.UserException;
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst;
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst.SystemResponse;
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst.UserResponse;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.common.service.impl.SsmServiceImpl;
|
||||
import com.micro.fast.upms.dao.UpmsUserMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsUser;
|
||||
import com.micro.fast.upms.service.UpmsUserService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
@Service
|
||||
public class UpmsUserServiceImpl extends SsmServiceImpl<UpmsUser,Integer,UpmsUserMapper>
|
||||
implements UpmsUserService<UpmsUser,Integer> ,InitializingBean {
|
||||
|
||||
|
||||
@Autowired
|
||||
private UpmsUserMapper upmsUserMapper;
|
||||
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@Override
|
||||
public ServerResponse<UpmsUser> register(UpmsUser upmsUser, String repeatPassword){
|
||||
ServerResponse checkUsername = checkUsername(upmsUser.getUsername());
|
||||
ServerResponse checkEmail = checkEmail(upmsUser.getEmail());
|
||||
//校验两次输入密码是否一致
|
||||
if (!upmsUser.getPassword().equals(repeatPassword)){
|
||||
throw new UserException(UserResponse.TWO_PASSWORD_NOT_SAME);
|
||||
}
|
||||
//校验用户名,邮箱是否存在
|
||||
boolean success = checkUsername.isSuccess();
|
||||
boolean success1 = checkEmail.isSuccess();
|
||||
if (!success){
|
||||
throw new UserException(UserResponse.USERNAME_IS_HAVE );
|
||||
}
|
||||
if (!success1){
|
||||
throw new UserException(UserResponse.EMAIL_IS_HAVE);
|
||||
}
|
||||
upmsUser.setCtime(System.currentTimeMillis());
|
||||
String encode = passwordEncoder.encode(upmsUser.getPassword());
|
||||
upmsUser.setPassword(encode);
|
||||
byte loacked = 0;
|
||||
upmsUser.setLocked(loacked);
|
||||
int i = upmsUserMapper.insertSelective(upmsUser);
|
||||
//是否插入成功
|
||||
if (i<1){
|
||||
throw new SystemException(SystemResponse.DATABASE_INSERT_FAILURE);
|
||||
}
|
||||
return ServerResponse.successData(upmsUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse checkUsername(String username) {
|
||||
int i = upmsUserMapper.countUsername(username);
|
||||
if (i>0){
|
||||
//用户名被占用
|
||||
return ServerResponse.error();
|
||||
}else{
|
||||
//用户名没被占用
|
||||
return ServerResponse.success();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse checkEmail(String email) {
|
||||
int i = upmsUserMapper.countEmail(email);
|
||||
if (i>0){
|
||||
//邮箱已被占用
|
||||
return ServerResponse.error();
|
||||
}else{
|
||||
//邮箱没被占用
|
||||
return ServerResponse.success();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getUsersByOrgId(UpmsUser upmsUser, Integer orgId, int pageNum, int pageSize, String order_by) {
|
||||
String[] split = order_by.split(BaseConst.ORDER_SPLIT);
|
||||
PageHelper.startPage(pageNum,pageSize,split[0]+BaseConst.ORDER_CONTACT+split[1]);
|
||||
List<UpmsUser> upmsUsers = upmsUserMapper.selectJoinWithOrgId(upmsUser, orgId);
|
||||
PageInfo pageInfo = new PageInfo(upmsUsers);
|
||||
return ServerResponse.successMsgData("根据组织查询用户成功",pageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.setMapper(this.upmsUserMapper);
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.micro.fast.upms.controller;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.pojo.UpmsLog;
|
||||
import com.micro.fast.upms.service.UpmsLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lsy
|
||||
*/
|
||||
@Api("upmsLog")
|
||||
@RestController
|
||||
@RequestMapping("/upmsLog")
|
||||
public class UpmsLogController {
|
||||
|
||||
@Autowired
|
||||
private UpmsLogService<UpmsLog,Integer> upmsLogService;
|
||||
|
||||
@ApiOperation("添加信息")
|
||||
@PostMapping
|
||||
public ServerResponse addUpmsLog(@Valid UpmsLog upmsLog) throws BindException {
|
||||
return upmsLogService.add(upmsLog);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询详细信息")
|
||||
@GetMapping("/{id}")
|
||||
public ServerResponse getUpmsLogById(
|
||||
@PathVariable(value = "id") @NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
return upmsLogService.getById(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据条件分页查询")
|
||||
@GetMapping
|
||||
public ServerResponse getUpmsLogByCondition(UpmsLog upmsLog,
|
||||
@RequestParam(defaultValue = "1",required = false) int pageNum,
|
||||
@RequestParam(defaultValue = "10",required = false)int pageSize,
|
||||
@RequestParam(required = false) String orderBy){
|
||||
return upmsLogService.getByCondition(upmsLog,pageNum,pageSize,orderBy);
|
||||
}
|
||||
|
||||
@ApiOperation("修改信息")
|
||||
@PutMapping("/{id}")
|
||||
public ServerResponse updateUpmsLog(UpmsLog upmsLog,
|
||||
@NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
upmsLog.setId(Integer.valueOf(id));
|
||||
return upmsLogService.update(upmsLog);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id删除,传入数组")
|
||||
@DeleteMapping
|
||||
public ServerResponse deleteUpmsLog(@NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入ids")
|
||||
@RequestParam("ids") ArrayList<Integer> ids){
|
||||
return upmsLogService.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package com.micro.fast.upms.controller;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.pojo.UpmsPermission;
|
||||
import com.micro.fast.upms.service.UpmsPermissionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lsy
|
||||
*/
|
||||
@Api(description = "权限管理")
|
||||
@RestController
|
||||
@RequestMapping("/upmsPermission")
|
||||
public class UpmsPermissionController {
|
||||
|
||||
@Autowired
|
||||
private UpmsPermissionService<UpmsPermission,Integer> upmsPermissionService;
|
||||
|
||||
@ApiOperation("添加信息")
|
||||
@PostMapping
|
||||
public ServerResponse addUpmsPermission(@Valid UpmsPermission upmsPermission) throws BindException {
|
||||
upmsPermission.setCtime(System.currentTimeMillis());
|
||||
return upmsPermissionService.add(upmsPermission);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询详细信息")
|
||||
@GetMapping
|
||||
public ServerResponse getUpmsPermissionById(
|
||||
@PathVariable(value = "id") @NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
return upmsPermissionService.getById(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据条件分页查询")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name",value = "权限名称",dataType = "string"),
|
||||
@ApiImplicitParam(name = "systemId",value = "系统id",dataType = "integer"),
|
||||
@ApiImplicitParam(name = "status",value = "权限状态",dataType = "string")
|
||||
})
|
||||
@GetMapping("/getPageByCondition")
|
||||
public ServerResponse getUpmsPermissionByCondition(UpmsPermission upmsPermission,
|
||||
@RequestParam(defaultValue = "1",required = false) int pageNum,
|
||||
@RequestParam(defaultValue = "10",required = false)int pageSize,
|
||||
@RequestParam(required = false) String orderBy){
|
||||
return upmsPermissionService.getByCondition(upmsPermission,pageNum,pageSize,orderBy);
|
||||
}
|
||||
|
||||
@ApiOperation("修改信息")
|
||||
@PutMapping
|
||||
public ServerResponse updateUpmsPermission(UpmsPermission upmsPermission,
|
||||
@RequestParam("id") @NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
upmsPermission.setId(Integer.valueOf(id));
|
||||
return upmsPermissionService.update(upmsPermission);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id删除,传入数组")
|
||||
@DeleteMapping
|
||||
public ServerResponse deleteUpmsPermission(@NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入ids") @RequestParam("ids") ArrayList<Integer> ids){
|
||||
return upmsPermissionService.deleteByIds(ids);
|
||||
}
|
||||
|
||||
@ApiOperation("根据用户id,权限类型,增减权限查询权限")
|
||||
@GetMapping("/permission")
|
||||
public ServerResponse getPermissions(@RequestParam("userId") Integer userId,@RequestParam("type") Integer type,@RequestParam("pType") Integer pType) {
|
||||
return upmsPermissionService.getPermissionsByUserIdandPTypeandType(userId, type, pType);
|
||||
}
|
||||
|
||||
@ApiOperation("按类型查询角色所拥有的权限")
|
||||
@GetMapping("/role/permission")
|
||||
public ServerResponse getRolePermission(@RequestParam("type") @NotNull(message = BaseConst.BASEMSG_PREFIX + "请输入权限类型") Integer type,
|
||||
@RequestParam("roleId") @NotNull(message = BaseConst.BASEMSG_PREFIX+"请选择角色") Integer roleId){
|
||||
return upmsPermissionService.getPermissionByRoleAndType(type,roleId);
|
||||
}
|
||||
|
||||
@ApiOperation("按类型查询角色未拥有的权限")
|
||||
@GetMapping("/role/unhave/permission")
|
||||
public ServerResponse getRoleUnHavePermission(@RequestParam("type") @NotNull(message = BaseConst.BASEMSG_PREFIX + "请输入权限类型") Integer type,
|
||||
@RequestParam("roleId") @NotNull(message = BaseConst.BASEMSG_PREFIX+"请选择角色") Integer roleId,
|
||||
@RequestParam(value = "systemId",required = false) Integer systemId,
|
||||
@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam(defaultValue = "1",required = false) Integer pageSize,
|
||||
@RequestParam(defaultValue = "10",required = false) Integer pageNum){
|
||||
return upmsPermissionService.getUnHavePermissionByRoleIdAndTypeOrSystemIdOrPermissionName(roleId,type,systemId,name,pageNum,pageSize);
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.micro.fast.upms.controller;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.pojo.UpmsSystem;
|
||||
import com.micro.fast.upms.service.UpmsSystemService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 系统管理
|
||||
* @author lsy
|
||||
*/
|
||||
@Api(description = "系统管理")
|
||||
@RestController
|
||||
@RequestMapping("/upmsSystem")
|
||||
public class UpmsSystemController {
|
||||
|
||||
@Autowired
|
||||
private UpmsSystemService<UpmsSystem,Integer> upmsSystemService;
|
||||
|
||||
@ApiOperation("添加信息")
|
||||
@PostMapping
|
||||
public ServerResponse addSystem(@Valid UpmsSystem upmsSystem) throws BindException {
|
||||
upmsSystem.setCtime(System.currentTimeMillis());
|
||||
if (upmsSystem.getStatus() == null){
|
||||
upmsSystem.setStatus((byte)1);
|
||||
}
|
||||
return upmsSystemService.add(upmsSystem);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询详细信息")
|
||||
@GetMapping
|
||||
public ServerResponse getSystemById(
|
||||
@RequestParam(value = "id") @NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
return upmsSystemService.getById(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据条件分页查询")
|
||||
@GetMapping("/getPageByCondition")
|
||||
public ServerResponse getSystemByCondition(UpmsSystem upmsSystem,
|
||||
@RequestParam(defaultValue = "1",required = false) int pageNum,
|
||||
@RequestParam(defaultValue = "10",required = false)int pageSize,
|
||||
@RequestParam(required = false) String orderBy){
|
||||
return upmsSystemService.getByCondition(upmsSystem,pageNum,pageSize,orderBy);
|
||||
}
|
||||
|
||||
@ApiOperation("修改信息")
|
||||
@PutMapping
|
||||
public ServerResponse updateSystem( UpmsSystem upmsSystem,
|
||||
@RequestParam("id") @NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
upmsSystem.setId(Integer.valueOf(id));
|
||||
return upmsSystemService.update(upmsSystem);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id删除,传入数组")
|
||||
@DeleteMapping
|
||||
public ServerResponse deleteSystem(
|
||||
@NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入id") @RequestParam("ids") ArrayList<Integer> ids){
|
||||
return upmsSystemService.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.micro.fast.upms.controller;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.service.UpmsUserOrganizationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lsy
|
||||
*/
|
||||
@Api(description = "用户组织关系维护")
|
||||
@RestController
|
||||
@RequestMapping("/upmsUserOrganization")
|
||||
public class UpmsUserOrganizationController {
|
||||
|
||||
@Autowired
|
||||
private UpmsUserOrganizationService upmsUserOrganizationService;
|
||||
|
||||
@ApiOperation("批量添加用户和组织的关系")
|
||||
@PostMapping("/batch")
|
||||
public ServerResponse batchAdd(@RequestParam("userId") Integer userId,
|
||||
@RequestParam("organizationIds") ArrayList<Integer> organizationIds){
|
||||
return upmsUserOrganizationService.batchInsert(userId,organizationIds);
|
||||
}
|
||||
@ApiOperation("批量删除用户和组织的关系")
|
||||
@DeleteMapping("/batch")
|
||||
public ServerResponse batchDelete(@RequestParam("userId") Integer userId,
|
||||
@RequestParam("organizationIds") ArrayList<Integer> organizationIds){
|
||||
return upmsUserOrganizationService.batchDelete(userId,organizationIds);
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.micro.fast.upms.controller;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.service.UpmsUserRoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lsy
|
||||
*/
|
||||
@Api("用户和角色关系维护")
|
||||
@RestController
|
||||
@RequestMapping("/upmsUserRole")
|
||||
public class UpmsUserRoleController {
|
||||
|
||||
@Autowired
|
||||
private UpmsUserRoleService upmsUserRoleService;
|
||||
|
||||
|
||||
@ApiOperation("用户添加角色")
|
||||
@PostMapping("/userAddRoles")
|
||||
public ServerResponse userAddRoles(@RequestParam("userId") @NotNull(message = BaseConst.BASEMSG_PREFIX+"请传入用户的id") Integer userId,
|
||||
@RequestParam("roleIds")
|
||||
@NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入的角色的id") ArrayList<Integer> roleIds){
|
||||
return upmsUserRoleService.batchInsert(userId,roleIds);
|
||||
}
|
||||
|
||||
@ApiOperation("用户删除角色")
|
||||
@DeleteMapping("/userDeleteRoles")
|
||||
public ServerResponse userDeleteRoles(@RequestParam("userId") @NotNull(message = BaseConst.BASEMSG_PREFIX+"请传入用户的id") Integer userId,
|
||||
@RequestParam("roleIds")
|
||||
@NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入的角色的id") ArrayList<Integer> roleIds){
|
||||
return upmsUserRoleService.batchDelete(userId,roleIds);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.micro.fast.upms.controller.handler;
|
||||
|
||||
import com.micro.fast.boot.starter.common.exception.handler.BaseExceptionHandlerController;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* upms异常处理基类
|
||||
* @author lsy
|
||||
*/
|
||||
@RestControllerAdvice(basePackages = {"com.micro.fast.upms.controller"})
|
||||
public class UpmsExceptionHandlerController extends BaseExceptionHandlerController{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* micro-fast upms controller
|
||||
* @author lishouyu 18332763730@163.com 2017/09/05
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
package com.micro.fast.upms.controller;
|
||||
Reference in New Issue
Block a user