完善了部分功能
|
After Width: | Height: | Size: 68 KiB |
@@ -21,6 +21,7 @@
|
||||
省略
|
||||
#### 安装mysql5.7+
|
||||
默认端口改为3317,数据库账号为root,数据库密码为studyj2e。
|
||||
导入[sql脚本](../sql)
|
||||
如果不想修改本地mysql配置,可以fork [config-server](https://gitee.com/kklt1996/config-server)到自己仓库,对config-server
|
||||
中的数据库连接配置修改。然后ms项目中需要修改config-server模块的配置仓库的指向为自己的仓库url
|
||||
#### 安装flume1.8.0
|
||||
|
||||
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 65 KiB |
@@ -5,6 +5,8 @@ management:
|
||||
health:
|
||||
diskspace:
|
||||
enabled: true
|
||||
security:
|
||||
enabled: false
|
||||
port: 10001
|
||||
# info 信息的获取
|
||||
info:
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.micro.fast.gateway.controller;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.gateway.filter.RecordInformationFilter;
|
||||
import com.micro.fast.gateway.pojo.ServiceRank;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 展示数据
|
||||
* @author lsy
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/bigShow")
|
||||
@Api(description = "服务调用数据展示")
|
||||
public class BigShowController {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
@GetMapping("/serviceRank")
|
||||
@ApiOperation("获取服务调用排行")
|
||||
public ServerResponse ServiceRank(){
|
||||
List<ServiceRank> serviceRanks = new ArrayList<>();
|
||||
Set<ZSetOperations.TypedTuple<String>> typedTuples = redisTemplate.opsForZSet().rangeWithScores(RecordInformationFilter.SERVICE_RANK_KEY, 0, 10);
|
||||
typedTuples.forEach(item -> {
|
||||
ServiceRank serviceRank = new ServiceRank(item.getValue(),item.getScore());
|
||||
serviceRanks.add(serviceRank);
|
||||
});
|
||||
serviceRanks.sort((a,b) -> a.getNumber().equals(b.getNumber()) ? 0 : (a.getNumber() > b.getNumber() ? -1 : 1));
|
||||
return ServerResponse.successMsgData("获取服务调用排行成功",serviceRanks);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ public class PreRequestFilter extends ZuulFilter {
|
||||
|
||||
@Override
|
||||
public Object run() {
|
||||
//校验登录状态和访问权限
|
||||
RequestContext requestContext = RequestContext.getCurrentContext();
|
||||
HttpServletRequest request = requestContext.getRequest();
|
||||
ServerResponse validate = ValidateJwtToken.validate(request, signingKey);
|
||||
@@ -55,7 +56,6 @@ public class PreRequestFilter extends ZuulFilter {
|
||||
requestContext.setResponseStatusCode(HttpStatus.UNAUTHORIZED.value());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.micro.fast.gateway.filter;
|
||||
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
/**
|
||||
* 对服务访问者的信息进行记录
|
||||
* @author lsy
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RecordInformationFilter extends ZuulFilter {
|
||||
|
||||
public static final String SERVICE_RANK_KEY = "gateway:ServiceCount";
|
||||
|
||||
public static final String SERVICE_COUNT_KEY = "gateway:ServiceCount";
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
/**
|
||||
* 过滤器类型
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String filterType() {
|
||||
return "pre";
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤器排序
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int filterOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否启用该过滤器
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldFilter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object run() {
|
||||
RequestContext currentContext = RequestContext.getCurrentContext();
|
||||
HttpServletRequest request = currentContext.getRequest();
|
||||
String requestURI = request.getRequestURI();
|
||||
String[] split = requestURI.split("/");
|
||||
// 统计网管访问服务数量
|
||||
redisTemplate.opsForZSet().incrementScore(SERVICE_RANK_KEY,split[1],1);
|
||||
// 统计服务调用总量
|
||||
redisTemplate.opsForValue().increment(SERVICE_COUNT_KEY,1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.micro.fast.gateway.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 服务调用排行
|
||||
* @author lsy
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ServiceRank {
|
||||
private String name;
|
||||
private Double number;
|
||||
}
|
||||
@@ -26,41 +26,6 @@ import java.util.List;
|
||||
public class UpmsRolePermissionController {
|
||||
|
||||
@Autowired
|
||||
private UpmsRolePermissionService<UpmsRolePermission,Integer> upmsRolePermissionService;
|
||||
private UpmsRolePermissionService upmsRolePermissionService;
|
||||
|
||||
@ApiOperation("添加信息")
|
||||
@PostMapping
|
||||
public ServerResponse addUpmsRolePermission(@Valid UpmsRolePermission upmsRolePermission) throws BindException {
|
||||
return upmsRolePermissionService.add(upmsRolePermission);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询详细信息")
|
||||
@GetMapping("/{id}")
|
||||
public ServerResponse getUpmsRolePermissionById(
|
||||
@PathVariable(value = "id") @NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
return upmsRolePermissionService.getById(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据条件分页查询")
|
||||
@GetMapping
|
||||
public ServerResponse getUpmsRolePermissionByCondition(UpmsRolePermission upmsRolePermission,
|
||||
@RequestParam(defaultValue = "1",required = false) int pageNum,
|
||||
@RequestParam(defaultValue = "10",required = false)int pageSize,
|
||||
@RequestParam(required = false) String orderBy){
|
||||
return upmsRolePermissionService.getByCondition(upmsRolePermission,pageNum,pageSize,orderBy);
|
||||
}
|
||||
|
||||
@ApiOperation("修改信息")
|
||||
@PutMapping("/{id}")
|
||||
public ServerResponse updateUpmsRolePermission(UpmsRolePermission upmsRolePermission,
|
||||
@NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
upmsRolePermission.setRolePermissionId(Integer.valueOf(id));
|
||||
return upmsRolePermissionService.update(upmsRolePermission);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id删除,传入数组")
|
||||
@DeleteMapping
|
||||
public ServerResponse deleteUpmsRolePermission(@NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入ids") @RequestParam("ids") ArrayList<Integer> ids){
|
||||
return upmsRolePermissionService.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.micro.fast.upms.pojo.UpmsUser;
|
||||
import com.micro.fast.upms.service.UpmsUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -17,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限管理系统用户管理
|
||||
@@ -95,4 +93,14 @@ public class UpmsUserController {
|
||||
@NotEmpty(message = BaseConst.BASEMSG_PREFIX + "请传入id") @RequestParam("ids") ArrayList<Integer> ids) {
|
||||
return upmsUserService.deleteByIds(ids);
|
||||
}
|
||||
|
||||
@ApiOperation("根据组织id还有用户信息查询用户")
|
||||
@GetMapping("/organization")
|
||||
public ServerResponse getUsersByOrgId(UpmsUser upmsUser,
|
||||
@RequestParam(defaultValue = "1", required = false) int pageNum,
|
||||
@RequestParam(defaultValue = "10", required = false) int pageSize,
|
||||
@RequestParam(required = false) String orderBy,
|
||||
@RequestParam(value = "organizationId",required = false) Integer orgId ) {
|
||||
return upmsUserService.getUsersByOrgId(upmsUser, orgId, pageNum, pageSize, orderBy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +1,36 @@
|
||||
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.UpmsUserOrganization;
|
||||
import com.micro.fast.upms.service.UpmsUserOrganizationService;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lsy
|
||||
*/
|
||||
@Api("upmsUserOrganization")
|
||||
@Api(description = "用户组织关系维护")
|
||||
@RestController
|
||||
@RequestMapping("/upmsUserOrganization")
|
||||
public class UpmsUserOrganizationController {
|
||||
|
||||
@Autowired
|
||||
private UpmsUserOrganizationService<UpmsUserOrganization,Integer> upmsUserOrganizationService;
|
||||
private UpmsUserOrganizationService upmsUserOrganizationService;
|
||||
|
||||
@ApiOperation("添加信息")
|
||||
@PostMapping
|
||||
public ServerResponse addUpmsUserOrganization(@Valid UpmsUserOrganization upmsUserOrganization) throws BindException {
|
||||
return upmsUserOrganizationService.add(upmsUserOrganization);
|
||||
@ApiOperation("批量添加用户和组织的关系")
|
||||
@PostMapping("/batch")
|
||||
public ServerResponse batchAdd(@RequestParam("userId") Integer userId,
|
||||
@RequestParam("organizationIds") ArrayList<Integer> organizationIds){
|
||||
return upmsUserOrganizationService.batchInsert(userId,organizationIds);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询详细信息")
|
||||
@GetMapping("/{id}")
|
||||
public ServerResponse getUpmsUserOrganizationById(
|
||||
@PathVariable(value = "id") @NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
return upmsUserOrganizationService.getById(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据条件分页查询")
|
||||
@GetMapping
|
||||
public ServerResponse getUpmsUserOrganizationByCondition(UpmsUserOrganization upmsUserOrganization,
|
||||
@RequestParam(defaultValue = "1",required = false) int pageNum,
|
||||
@RequestParam(defaultValue = "10",required = false)int pageSize,
|
||||
@RequestParam(required = false) String orderBy){
|
||||
return upmsUserOrganizationService.getByCondition(upmsUserOrganization,pageNum,pageSize,orderBy);
|
||||
}
|
||||
|
||||
@ApiOperation("修改信息")
|
||||
@PutMapping("/{id}")
|
||||
public ServerResponse updateUpmsUserOrganization(UpmsUserOrganization upmsUserOrganization,
|
||||
@NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
upmsUserOrganization.setUserOrganizationId(Integer.valueOf(id));
|
||||
return upmsUserOrganizationService.update(upmsUserOrganization);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id删除,传入数组")
|
||||
@DeleteMapping
|
||||
public ServerResponse deleteUpmsUserOrganization(@NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入ids") @RequestParam("ids") ArrayList<Integer> ids){
|
||||
return upmsUserOrganizationService.deleteByIds(ids);
|
||||
@ApiOperation("批量删除用户和组织的关系")
|
||||
@DeleteMapping("/batch")
|
||||
public ServerResponse batchDelete(@RequestParam("userId") Integer userId,
|
||||
@RequestParam("organizationIds") ArrayList<Integer> organizationIds){
|
||||
return upmsUserOrganizationService.batchDelete(userId,organizationIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
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.UpmsUserPermission;
|
||||
import com.micro.fast.upms.service.UpmsUserPermissionService;
|
||||
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 org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -26,41 +22,12 @@ import java.util.List;
|
||||
public class UpmsUserPermissionController {
|
||||
|
||||
@Autowired
|
||||
private UpmsUserPermissionService<UpmsUserPermission,Integer> upmsUserPermissionService;
|
||||
private UpmsUserPermissionService upmsUserPermissionService;
|
||||
|
||||
@ApiOperation("添加信息")
|
||||
@PostMapping
|
||||
public ServerResponse addUpmsUserPermission(@Valid UpmsUserPermission upmsUserPermission) throws BindException {
|
||||
return upmsUserPermissionService.add(upmsUserPermission);
|
||||
}
|
||||
@ApiOperation("批量添加用户和组织的关系,一个用户可以属于多个组织")
|
||||
@PostMapping("/batch/oneUserWithManyOrganization")
|
||||
public ServerResponse batchAddUpmsUserPermission(@RequestParam("userId") Integer userId,@RequestParam("orgIds") ArrayList<Integer> orgIds) {
|
||||
|
||||
@ApiOperation("根据id查询详细信息")
|
||||
@GetMapping("/{id}")
|
||||
public ServerResponse getUpmsUserPermissionById(
|
||||
@PathVariable(value = "id") @NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
return upmsUserPermissionService.getById(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据条件分页查询")
|
||||
@GetMapping
|
||||
public ServerResponse getUpmsUserPermissionByCondition(UpmsUserPermission upmsUserPermission,
|
||||
@RequestParam(defaultValue = "1",required = false) int pageNum,
|
||||
@RequestParam(defaultValue = "10",required = false)int pageSize,
|
||||
@RequestParam(required = false) String orderBy){
|
||||
return upmsUserPermissionService.getByCondition(upmsUserPermission,pageNum,pageSize,orderBy);
|
||||
}
|
||||
|
||||
@ApiOperation("修改信息")
|
||||
@PutMapping("/{id}")
|
||||
public ServerResponse updateUpmsUserPermission(UpmsUserPermission upmsUserPermission,
|
||||
@NotBlank(message = BaseConst.BASEMSG_PREFIX+"请传入id") String id){
|
||||
upmsUserPermission.setUserPermissionId(Integer.valueOf(id));
|
||||
return upmsUserPermissionService.update(upmsUserPermission);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id删除,传入数组")
|
||||
@DeleteMapping
|
||||
public ServerResponse deleteUpmsUserPermission(@NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入ids") @RequestParam("ids") ArrayList<Integer> ids){
|
||||
return upmsUserPermissionService.deleteByIds(ids);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.micro.fast.upms.dao;
|
||||
|
||||
import com.micro.fast.common.dao.SsmMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsOrganization;
|
||||
import feign.Param;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.micro.fast.upms.dao;
|
||||
|
||||
import com.micro.fast.common.dao.SsmMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsOrganization;
|
||||
import com.micro.fast.upms.pojo.UpmsUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -60,5 +59,5 @@ public interface UpmsUserMapper extends SsmMapper<UpmsUser,Integer>{
|
||||
* 根据组织id还有用户的其他信息查询
|
||||
* @return
|
||||
*/
|
||||
List<UpmsUser> selectJoinWithOrgId(UpmsUser record, @Param("orgid") Integer orgid);
|
||||
List<UpmsUser> selectJoinWithOrgId(@Param("user") UpmsUser record, @Param("orgid") Integer orgid);
|
||||
}
|
||||
@@ -1,24 +1,18 @@
|
||||
package com.micro.fast.upms.dao;
|
||||
|
||||
import com.micro.fast.common.dao.SsmMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsUserOrganization;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface UpmsUserOrganizationMapper extends SsmMapper<UpmsUserOrganization,Integer> {
|
||||
@Override
|
||||
int deleteByPrimaryKey(Integer userOrganizationId);
|
||||
import java.util.List;
|
||||
|
||||
@Override
|
||||
int insert(UpmsUserOrganization record);
|
||||
public interface UpmsUserOrganizationMapper {
|
||||
|
||||
@Override
|
||||
int insertSelective(UpmsUserOrganization record);
|
||||
/**
|
||||
* 批量插入一个用户和多个组织的关系
|
||||
* @param userId
|
||||
* @param orgIds
|
||||
* @return
|
||||
*/
|
||||
int batchInsertOneUserWithManyOrg(@Param("userId") Integer userId, @Param("orgIds") List<Integer> orgIds);
|
||||
|
||||
@Override
|
||||
UpmsUserOrganization selectByPrimaryKey(Integer userOrganizationId);
|
||||
|
||||
@Override
|
||||
int updateByPrimaryKeySelective(UpmsUserOrganization record);
|
||||
|
||||
@Override
|
||||
int updateByPrimaryKey(UpmsUserOrganization record);
|
||||
int batchDeleteByUserIdOrganizationId(@Param("userId")Integer userId,@Param("orgIds")List<Integer> orgs);
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.micro.fast.upms.dao;
|
||||
|
||||
import com.micro.fast.common.dao.SsmMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsUserPermission;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface UpmsUserPermissionMapper extends SsmMapper<UpmsUserPermission,Integer> {
|
||||
import java.util.List;
|
||||
|
||||
public interface UpmsUserPermissionMapper {
|
||||
int deleteByPrimaryKey(Integer userPermissionId);
|
||||
|
||||
int insert(UpmsUserPermission record);
|
||||
@@ -15,4 +17,5 @@ public interface UpmsUserPermissionMapper extends SsmMapper<UpmsUserPermission,I
|
||||
int updateByPrimaryKeySelective(UpmsUserPermission record);
|
||||
|
||||
int updateByPrimaryKey(UpmsUserPermission record);
|
||||
|
||||
}
|
||||
@@ -5,6 +5,6 @@ import com.micro.fast.common.service.SsmService;
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
public interface UpmsRolePermissionService<T,ID> extends SsmService<T,ID>{
|
||||
public interface UpmsRolePermissionService{
|
||||
|
||||
}
|
||||
@@ -1,10 +1,27 @@
|
||||
package com.micro.fast.upms.service;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.common.service.SsmService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
public interface UpmsUserOrganizationService<T,ID> extends SsmService<T,ID>{
|
||||
public interface UpmsUserOrganizationService{
|
||||
/**
|
||||
* 批量建立用户和组织的关系
|
||||
* @param userId
|
||||
* @param orgIds
|
||||
* @return
|
||||
*/
|
||||
ServerResponse batchInsert(Integer userId, List<Integer> orgIds);
|
||||
|
||||
/**
|
||||
* 批量删除用户和组织的关系
|
||||
* @param userId
|
||||
* @param orgIds
|
||||
* @return
|
||||
*/
|
||||
ServerResponse batchDelete(Integer userId,List<Integer> orgIds);
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.micro.fast.upms.service;
|
||||
|
||||
import com.micro.fast.common.service.SsmService;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
public interface UpmsUserPermissionService<T,ID> extends SsmService<T,ID>{
|
||||
public interface UpmsUserPermissionService{
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -33,4 +33,9 @@ public interface UpmsUserService<T,ID> extends SsmService<T,ID> {
|
||||
*/
|
||||
ServerResponse checkEmail(String email);
|
||||
|
||||
/**
|
||||
* 根据组织等信息查询用户
|
||||
*/
|
||||
ServerResponse getUsersByOrgId(UpmsUser upmsUser, Integer orgId, int pageNum, int pageSize, String order_by);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.micro.fast.upms.service.impl;
|
||||
|
||||
import com.micro.fast.common.service.impl.SsmServiceImpl;
|
||||
import com.micro.fast.upms.dao.UpmsRolePermissionMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsRolePermission;
|
||||
import com.micro.fast.upms.service.UpmsRolePermissionService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -12,17 +9,9 @@ import org.springframework.stereotype.Service;
|
||||
* @author lsy
|
||||
*/
|
||||
@Service
|
||||
public class UpmsRolePermissionServiceImpl extends SsmServiceImpl<UpmsRolePermission,Integer,UpmsRolePermissionMapper>
|
||||
implements UpmsRolePermissionService<UpmsRolePermission,Integer>,InitializingBean {
|
||||
public class UpmsRolePermissionServiceImpl implements UpmsRolePermissionService {
|
||||
|
||||
@Autowired
|
||||
private UpmsRolePermissionMapper mapper;
|
||||
|
||||
/**
|
||||
* 在这个bean初始化完成后覆盖父类的mapper
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.setMapper(this.mapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,39 @@
|
||||
package com.micro.fast.upms.service.impl;
|
||||
|
||||
import com.micro.fast.common.service.impl.SsmServiceImpl;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.dao.UpmsUserOrganizationMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsUserOrganization;
|
||||
import com.micro.fast.upms.service.UpmsUserOrganizationService;
|
||||
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 UpmsUserOrganizationServiceImpl extends SsmServiceImpl<UpmsUserOrganization,Integer,UpmsUserOrganizationMapper>
|
||||
implements UpmsUserOrganizationService<UpmsUserOrganization,Integer>,InitializingBean {
|
||||
public class UpmsUserOrganizationServiceImpl implements UpmsUserOrganizationService {
|
||||
|
||||
@Autowired
|
||||
private UpmsUserOrganizationMapper mapper;
|
||||
|
||||
/**
|
||||
* 在这个bean初始化完成后覆盖父类的mapper
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.setMapper(this.mapper);
|
||||
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("退出组织失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
package com.micro.fast.upms.service.impl;
|
||||
|
||||
import com.micro.fast.common.service.impl.SsmServiceImpl;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.dao.UpmsUserPermissionMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsUserPermission;
|
||||
import com.micro.fast.upms.service.UpmsUserPermissionService;
|
||||
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 UpmsUserPermissionServiceImpl extends SsmServiceImpl<UpmsUserPermission,Integer,UpmsUserPermissionMapper>
|
||||
implements UpmsUserPermissionService<UpmsUserPermission,Integer>,InitializingBean {
|
||||
public class UpmsUserPermissionServiceImpl implements UpmsUserPermissionService{
|
||||
|
||||
@Autowired
|
||||
private UpmsUserPermissionMapper mapper;
|
||||
|
||||
/**
|
||||
* 在这个bean初始化完成后覆盖父类的mapper
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.setMapper(this.mapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
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;
|
||||
@@ -14,6 +17,8 @@ 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
|
||||
*/
|
||||
@@ -82,6 +87,15 @@ public class UpmsUserServiceImpl extends SsmServiceImpl<UpmsUser,Integer,UpmsUs
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
</delete>
|
||||
<!--根据userId查询组织-->
|
||||
<select id="selectJionWithUserId" resultType="com.micro.fast.upms.pojo.UpmsOrganization">
|
||||
select <include refid="Base_Column_List"/> FROM upms_user_organization WHERE id IN
|
||||
(SELECT user_organization_id WHERE use_id = #{userId})
|
||||
select <include refid="Base_Column_List"/> FROM upms_organization WHERE id IN
|
||||
(SELECT organization_id from upms_user_organization WHERE user_id = #{userId})
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -181,16 +181,16 @@
|
||||
SELECT <include refid="Base_Column_List"/> FROM micro.upms_user
|
||||
<where>
|
||||
<if test="username != null">
|
||||
username like "%"#{username}"%"
|
||||
username like #{username}
|
||||
</if>
|
||||
<if test="realname != null">
|
||||
and realname like "%"#{realname}"%"
|
||||
and realname like #{realname}
|
||||
</if>
|
||||
<if test="phone != null">
|
||||
and phone like "%"#{phone}"%"
|
||||
and phone like #{phone}
|
||||
</if>
|
||||
<if test="email != null">
|
||||
and email like "%"#{email}"%"
|
||||
and email like #{email}
|
||||
</if>
|
||||
<if test="sex != null">
|
||||
and sex = #{sex}
|
||||
@@ -203,20 +203,20 @@
|
||||
<if test="orgid != null">
|
||||
and id IN (SELECT user_id FROM upms_user_organization WHERE organization_id = #{orgid})
|
||||
</if>
|
||||
<if test="username != null">
|
||||
and username like "%"#{username}"%"
|
||||
<if test="user.username != null">
|
||||
and username like #{user.username}
|
||||
</if>
|
||||
<if test="realname != null">
|
||||
and realname like "%"#{realname}"%"
|
||||
<if test="user.realname != null">
|
||||
and realname like #{user.realname}
|
||||
</if>
|
||||
<if test="phone != null">
|
||||
and phone like "%"#{phone}"%"
|
||||
<if test="user.phone != null">
|
||||
and phone like #{user.phone}
|
||||
</if>
|
||||
<if test="email != null">
|
||||
and email like "%"#{email}"%"
|
||||
<if test="user.email != null">
|
||||
and email like #{user.email}
|
||||
</if>
|
||||
<if test="sex != null">
|
||||
and sex = #{sex}
|
||||
<if test="user.sex != null">
|
||||
and sex = #{user.sex}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -11,63 +11,18 @@
|
||||
<sql id="Base_Column_List" >
|
||||
user_organization_id, user_id, organization_id
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from upms_user_organization
|
||||
where user_organization_id = #{userOrganizationId,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
|
||||
delete from upms_user_organization
|
||||
where user_organization_id = #{userOrganizationId,jdbcType=INTEGER}
|
||||
<!--非自动生成的语句-->
|
||||
<insert id="batchInsertOneUserWithManyOrg">
|
||||
insert into upms_user_organization ( user_id, organization_id)
|
||||
values
|
||||
<foreach collection="orgIds" open=" " separator="," close=" " item="item" >
|
||||
(#{userId},#{item})
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="batchDeleteByUserIdOrganizationId">
|
||||
DELETE FROM upms_user_organization WHERE user_id = #{userId} and organization_id in
|
||||
<foreach collection="orgIds" open="(" separator="," close=")" item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.micro.fast.upms.pojo.UpmsUserOrganization" >
|
||||
insert into upms_user_organization (user_organization_id, user_id, organization_id
|
||||
)
|
||||
values (#{userOrganizationId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{organizationId,jdbcType=INTEGER}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.micro.fast.upms.pojo.UpmsUserOrganization" >
|
||||
insert into upms_user_organization
|
||||
<trim prefix="(" suffix=")" suffixOverrides="," >
|
||||
<if test="userOrganizationId != null" >
|
||||
user_organization_id,
|
||||
</if>
|
||||
<if test="userId != null" >
|
||||
user_id,
|
||||
</if>
|
||||
<if test="organizationId != null" >
|
||||
organization_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
||||
<if test="userOrganizationId != null" >
|
||||
#{userOrganizationId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="userId != null" >
|
||||
#{userId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="organizationId != null" >
|
||||
#{organizationId,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsUserOrganization" >
|
||||
update upms_user_organization
|
||||
<set >
|
||||
<if test="userId != null" >
|
||||
user_id = #{userId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="organizationId != null" >
|
||||
organization_id = #{organizationId,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where user_organization_id = #{userOrganizationId,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.micro.fast.upms.pojo.UpmsUserOrganization" >
|
||||
update upms_user_organization
|
||||
set user_id = #{userId,jdbcType=INTEGER},
|
||||
organization_id = #{organizationId,jdbcType=INTEGER}
|
||||
where user_organization_id = #{userOrganizationId,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -59,7 +59,7 @@
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsUserPermission" >
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsUserPermission" >
|
||||
update upms_user_permission
|
||||
<set >
|
||||
<if test="userId != null" >
|
||||
@@ -81,4 +81,5 @@
|
||||
type = #{type,jdbcType=TINYINT}
|
||||
where user_permission_id = #{userPermissionId,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||