工具类中这样子注入是失败的,空指针。因为ClientMasterDataService没有被实例化
@Resource
private ClientMasterDataService clientMasterDataService;
通过构造注入
public class AuthorityUtils {
private ClientMasterDataService clientMasterDataService;
public AuthorityUtils(ClientMasterDataService clientMasterDataService){
this.clientMasterDataService = clientMasterDataService;
}
/**
* 根据集团id,公司id,获取权限
* @param groupId
* @param companyId
* @return
* @throws Exception
*/
public ResultModel<MasterDataOperateDTO> postDataEntity(Long groupId,Long companyId) throws Exception {
Long groupId1 = null;
Long companyId1 = null;
if (groupId != null) {
groupId1 = groupId;
}
if (companyId != null) {
companyId1 = companyId;
}
return clientMasterDataService.getMasterDataOperator(RequestUtil.getCurrentUserName(), groupId1, companyId1);
}
}