Commit 69dbbce8 authored by ligang's avatar ligang
Browse files

update getReceiverCc add processInstanceId

parent d86a4bed
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -149,10 +149,11 @@ public class ExecutorController extends BaseController {
    @GetMapping(value = "/get-receiver-cc")
    @ResponseStatus(HttpStatus.OK)
    public Result getReceiverCc(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
                                                        @RequestParam(value = "processDefinitionId") int processDefinitionId){
                                @RequestParam(value = "processDefinitionId",required = false) Integer processDefinitionId,
                                @RequestParam(value = "processInstanceId",required = false) Integer processInstanceId) {
        logger.info("login user {}, get process definition receiver and cc", loginUser.getUserName());
        try {
            Map<String, Object> result = execService.getReceiverCc(processDefinitionId);
            Map<String, Object> result = execService.getReceiverCc(processDefinitionId,processInstanceId);
            return returnDataList(result);
        } catch (Exception e) {
            logger.error(QUERY_RECIPIENTS_AND_COPYERS_BY_PROCESS_DEFINITION_ERROR.getMsg(),e);
+15 −4
Original line number Diff line number Diff line
@@ -361,18 +361,29 @@ public class ExecutorService extends BaseService{
    }

    /**
     * query recipients and copyers by process definition id
     * query recipients and copyers by process definition id or processInstanceId
     *
     * @param processDefineId
     * @return
     */
    public Map<String, Object> getReceiverCc(int processDefineId) {
    public Map<String, Object> getReceiverCc(Integer processDefineId,Integer processInstanceId) {
        Map<String, Object> result = new HashMap<>();

        logger.info("processInstanceId {}",processInstanceId);
        if(processDefineId == null && processInstanceId == null){
            throw new RuntimeException("You must set values for parameters processDefineId or processInstanceId");
        }
        if(processDefineId == null && processInstanceId != null) {
            ProcessInstance processInstance = processInstanceMapper.queryById(processInstanceId);
            if (processInstance == null) {
                throw new RuntimeException("processInstanceId is not exists");
            }
            processDefineId = processInstance.getProcessDefinitionId();
        }
        ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineId(processDefineId);
        if (processDefinition == null){
            throw new RuntimeException("processDefineId is not exists");
            throw new RuntimeException(String.format("processDefineId %d is not exists",processDefineId));
        }

        String receivers = processDefinition.getReceivers();
        String receiversCc = processDefinition.getReceiversCc();
        Map<String,String> dataMap = new HashMap<>();
+20 −0
Original line number Diff line number Diff line
@@ -32,8 +32,11 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.WebApplicationContext;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -66,4 +69,21 @@ public class ExecutorControllerTest {
        Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
        logger.info(mvcResult.getResponse().getContentAsString());
    }

    @Test
    public void getReceiverCc() throws Exception {
        MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
        //paramsMap.add("processDefinitionId","4");
        paramsMap.add("processInstanceId","13");
        //paramsMap.add("processInstanceId","13");
        MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/executors/get-receiver-cc","li_sql_test")
                .header("sessionId", "e79b3353-e227-4680-88c0-544194e64025")
                .params(paramsMap))
                .andExpect(status().isOk())
                .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
                .andReturn();
        Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
        Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
        logger.info(mvcResult.getResponse().getContentAsString());
    }
}
 No newline at end of file