parent
a6ff240369
commit
58bf3e38b6
@ -0,0 +1,20 @@
|
||||
package com.xiaojusurvey.engine.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author zhongbo
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum SurveyPermissionEnum {
|
||||
SURVEY_CONF_MANAGE("SURVEY_CONF_MANAGE"),
|
||||
SURVEY_RESPONSE_MANAGE("SURVEY_RESPONSE_MANAGE"),
|
||||
SURVEY_COOPERATION_MANAGE("SURVEY_COOPERATION_MANAGE");
|
||||
|
||||
private final String permissionDescription;
|
||||
|
||||
SurveyPermissionEnum(String permissionDescription) {
|
||||
this.permissionDescription = permissionDescription;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.xiaojusurvey.engine.core.survey;
|
||||
|
||||
import com.xiaojusurvey.engine.common.entity.survey.SurveyMeta;
|
||||
import com.xiaojusurvey.engine.core.reslut.IdResult;
|
||||
|
||||
public interface CollaboratorService {
|
||||
IdResult createSurvey(SurveyMeta surveyMeta);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.xiaojusurvey.engine.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xiaojusurvey.engine.common.enums.SurveyPermissionEnum;
|
||||
import com.xiaojusurvey.engine.common.rpc.RpcResult;
|
||||
import com.xiaojusurvey.engine.common.util.RpcResultUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author zhongbo
|
||||
*/
|
||||
@RequestMapping("/api/collaborator")
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class CollaboratorController {
|
||||
|
||||
/**
|
||||
* 获取权限列表
|
||||
*/
|
||||
@GetMapping("/getPermissionList")
|
||||
public RpcResult<JSONArray> getPermissionList() {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject surveyConfManage = new JSONObject();
|
||||
surveyConfManage.put("name", "问卷配置管理");
|
||||
surveyConfManage.put("value", SurveyPermissionEnum.SURVEY_CONF_MANAGE);
|
||||
|
||||
JSONObject surveyResManage = new JSONObject();
|
||||
surveyResManage.put("name", "问卷分析管理");
|
||||
surveyResManage.put("value", SurveyPermissionEnum.SURVEY_RESPONSE_MANAGE);
|
||||
|
||||
JSONObject surveyCoManage = new JSONObject();
|
||||
surveyCoManage.put("name", "协作者管理");
|
||||
surveyCoManage.put("value", SurveyPermissionEnum.SURVEY_COOPERATION_MANAGE);
|
||||
|
||||
jsonArray.add(surveyConfManage);
|
||||
jsonArray.add(surveyResManage);
|
||||
jsonArray.add(surveyCoManage);
|
||||
|
||||
return RpcResultUtil.createSuccessResult(jsonArray);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.xiaojusurvey.engine.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.xiaojusurvey.engine.common.entity.user.User;
|
||||
import com.xiaojusurvey.engine.common.rpc.RpcResult;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class CollaboratorControllerTest {
|
||||
@InjectMocks
|
||||
CollaboratorController collaboratorController;
|
||||
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Before
|
||||
public void initBean() {
|
||||
httpServletRequest = new MockHttpServletRequest();
|
||||
User user = new User();
|
||||
user.setId("123");
|
||||
user.setUsername("maple");
|
||||
httpServletRequest.setAttribute("user", user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPermissionList() {
|
||||
RpcResult<JSONArray> permissionListResult = collaboratorController.getPermissionList();
|
||||
Assert.assertTrue(permissionListResult.getSuccess());
|
||||
Assert.assertEquals(new Integer(200), permissionListResult.getCode());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user