Commit 88879a82 by guojuxing

功能下拉接口

parent 2e28a5f9
......@@ -7,40 +7,37 @@ package com.gic.cloud.constants;
* @date 2020/7/7 4:15 PM

*/
public enum FunctionEnum {
RANK_LIST(1, "排行榜"),
MEMBER_PROFILE(2, "会员概况"),
RECRUITMENT_ANALYSIS(3, "招募分析"),
MEMBER_PORTRAIT(4, "会员画像"),
PERFORMANCE_OVERVIEW(5, "业绩概览"),
CONSUME_COMPOSITION(6, "消费构成"),
ITEM_RANK(7, "单品排行"),
BASIC_PERFORMANCE(8, "基础业绩");
RANK_LIST("FUC001", "排行榜"),
MEMBER_PROFILE("FUC002", "会员概况"),
RECRUITMENT_ANALYSIS("FUC003", "招募分析"),
MEMBER_PORTRAIT("FUC004", "会员画像"),
PERFORMANCE_OVERVIEW("FUC005", "业绩概览"),
CONSUME_COMPOSITION("FUC006", "消费构成"),
ITEM_RANK("FUC007", "单品排行"),
BASIC_PERFORMANCE("FUC008", "基础业绩");
private int code;
private String code;
private String name;
private FunctionEnum(int code, String name) {
private FunctionEnum(String code, String name) {
this.code = code;
this.name = name;
}
public static boolean isRightCode(Integer code) {
if (code == null) {
return false;
}
public static boolean isRightCode(String code) {
for (FunctionEnum functionEnum : values()) {
if (code.intValue() == functionEnum.getCode()) {
if (functionEnum.getCode().equals(code)) {
return true;
}
}
return false;
}
public int getCode() {
public String getCode() {
return code;
}
public FunctionEnum setCode(int code) {
public FunctionEnum setCode(String code) {
this.code = code;
return this;
}
......
......@@ -4,6 +4,8 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.FunctionDTO;
import java.util.List;
public interface FunctionApiService {
/**
* 新增功能权限集
......@@ -20,4 +22,6 @@ public interface FunctionApiService {
ServiceResponse<Void> deleteFunction(Integer functionId);
ServiceResponse<Page<FunctionDTO>> pageFunction(Integer enterpriseId, String functionName, Integer currentPage, Integer pageSize);
ServiceResponse<List<FunctionDTO>> listFunction(Integer enterpriseId, String functionName);
}
......@@ -4,6 +4,8 @@ import com.gic.cloud.dto.FunctionDTO;
import com.gic.cloud.entity.TabSysFunction;
import com.github.pagehelper.Page;
import java.util.List;
public interface FunctionService {
Integer saveFunction(FunctionDTO dto);
......@@ -17,4 +19,6 @@ public interface FunctionService {
Page<TabSysFunction> pageFunction(Integer enterpriseId, String functionName,
Integer currentPage, Integer pageSize);
List<TabSysFunction> listFunction(Integer enterpriseId, String functionName);
}
......@@ -66,4 +66,9 @@ public class FunctionServiceImpl implements FunctionService{
List<TabSysFunction> list = tabSysFunctionMapper.listFunction(enterpriseId, functionName);
return (Page<TabSysFunction>) list;
}
@Override
public List<TabSysFunction> listFunction(Integer enterpriseId, String functionName) {
return tabSysFunctionMapper.listFunction(enterpriseId, functionName);
}
}
......@@ -9,6 +9,7 @@ import com.gic.cloud.entity.TabSysFunction;
import com.gic.cloud.service.FunctionApiService;
import com.gic.cloud.service.FunctionService;
import com.gic.cloud.service.UserService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.error.ErrorCode;
import org.apache.commons.collections.CollectionUtils;
......@@ -16,9 +17,7 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -79,6 +78,13 @@ public class FunctionApiServiceImpl implements FunctionApiService{
return ServiceResponse.success(new Page<>());
}
@Override
public ServiceResponse<List<FunctionDTO>> listFunction(Integer enterpriseId, String functionName) {
return ServiceResponse.success(Optional.ofNullable(EntityUtil.changeEntityListNew(FunctionDTO.class,
functionService.listFunction(enterpriseId, functionName)))
.orElse(Collections.EMPTY_LIST));
}
private ServiceResponse<Void> validParam(FunctionDTO dto) {
if (dto.getFunctionId() != null) {
TabSysFunction record = functionService.getFunction(dto.getFunctionId());
......@@ -104,16 +110,12 @@ public class FunctionApiServiceImpl implements FunctionApiService{
}
//一个流只能用一次
Stream<String> stream = Arrays.stream(functionComponent.split(","));
Stream<String> stream2 = Arrays.stream(functionComponent.split(","));
Stream<String> stream3 = Arrays.stream(functionComponent.split(","));
if (stream.anyMatch(e -> !StringUtils.isNumeric(e))) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "功能组件值非法");
}
if (stream2.anyMatch(e -> !FunctionEnum.isRightCode(Integer.parseInt(e)))) {
Stream<String> stream1 = Arrays.stream(functionComponent.split(","));
if (stream.anyMatch(e -> !FunctionEnum.isRightCode(e))) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "功能组件值非法");
}
StringBuilder temp = new StringBuilder("_");
stream3.mapToInt(e -> Integer.parseInt(e)).boxed().sorted().forEach(e -> {
stream1.sorted().forEach(e -> {
temp.append(e).append("_");
});
dto.setFunctionComponent(temp.toString());
......
package com.gic.cloud.web.controller;
import com.gic.cloud.constants.FunctionEnum;
import com.gic.cloud.dto.AccountGroupDTO;
import com.gic.cloud.dto.UserDTO;
import com.gic.cloud.qo.UserQO;
import com.gic.cloud.service.AccountGroupApiService;
import com.gic.cloud.service.FunctionApiService;
import com.gic.cloud.service.UserApiService;
import com.gic.cloud.web.vo.AccountGroupVO;
import com.gic.cloud.web.vo.FunctionListVO;
import com.gic.cloud.web.vo.UserVO;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.ResultControllerUtils;
......@@ -17,8 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@RestController
......@@ -30,6 +32,8 @@ public class UserController {
private AccountGroupApiService accountGroupApiService;
@Autowired
private UserApiService userApiService;
@Autowired
private FunctionApiService functionApiService;
@RequestMapping("/save-account-group")
public RestResponse saveAccountGroup(AccountGroupDTO dto) {
......@@ -74,8 +78,26 @@ public class UserController {
return ResultControllerUtils.commonResult(userApiService.deleteUser(userId));
}
@RequestMapping("/list-function-component")
public RestResponse listFunctionComponent() {
List<Map<String, String>> list = new ArrayList<>(8);
for (FunctionEnum functionEnum : FunctionEnum.values()) {
Map<String, String> map = new HashMap<>(2);
map.put(functionEnum.getCode(), functionEnum.getName());
list.add(map);
}
return RestResponse.success(list);
}
@RequestMapping("/list-function")
public RestResponse listFunction(String functionName) {
return ResultControllerUtils.commonResult(functionApiService
.listFunction(UserDetailUtils.getUserDetail().getEnterpriseId(), functionName), FunctionListVO.class);
}
@RequestMapping("/page-user")
public RestResponse pageUser(UserQO userQO) {
userQO.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
return ResultControllerUtils.commonPageResult(userApiService.pageUser(userQO), UserVO.class);
}
......
package com.gic.cloud.web.vo;
import java.io.Serializable;
public class FunctionListVO implements Serializable{
private static final long serialVersionUID = 855201859340536651L;
/**
* ID
*/
private Integer functionId;
/**
* 名称
*/
private String functionName;
public Integer getFunctionId() {
return functionId;
}
public FunctionListVO setFunctionId(Integer functionId) {
this.functionId = functionId;
return this;
}
public String getFunctionName() {
return functionName;
}
public FunctionListVO setFunctionName(String functionName) {
this.functionName = functionName;
return this;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment