code quality record

The following methods provided by the service to the outside will ensure that the ActStepDesc ​​object can be obtained, so that there is no need to judge null when using it externally.

public ActStepDesc selectByBPK(Integer activityId, Integer tplStepId){
        ActStepDesc actStepDesc= actStepDescMapper.selectByBPK(activityId, tplStepId);
        if (null==actStepDesc||null == actStepDesc.getId()) {
            actStepDesc = new ActStepDesc();
            actStepDesc.setActivityId(activityId);
            actStepDesc.setTplStepId(tplStepId);
            actStepDesc.setProjectId(ProjectContextUtils.getProjectContext().getProjectId());
            actStepDesc.setId(saveOrUpdate(actStepDesc));
        }
        return actStepDesc;
    }

The following is the method of calling the above method inside the same class, which directly uses the underlying query, resulting in null sometimes.

The above method should also be used directly, that is to say, the method of the class itself should also be used inside the class.

public Integer selectUploadCount(@InvokeParam(value="activityId",required=true) String activityId,@InvokeParam(value="tplStepId",required=true) String tplStepId){
        ActStepDesc actStepDesc= actStepDescMapper.selectByBPK(Integer.valueOf(activityId), Integer.valueOf(tplStepId));

//改成下面 ActStepDesc actStepDesc= selectByBPK(Integer.valueOf(activityId), //Integer.valueOf(tplStepId));
        return resourceService.selectUserCount(Const.RESOURCE_ORIGIN.ACT_STEP, actStepDesc.getId());
    }

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326673072&siteId=291194637