package com.gkhy.safePlatform.goalManage.service.impl; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.emergency.rpc.api.EmergencyDemoRpcAPi; import com.gkhy.safePlatform.emergency.rpc.api.model.User; import com.gkhy.safePlatform.goalManage.entity.TestTable; import com.gkhy.safePlatform.goalManage.service.DemoService; import com.gkhy.safePlatform.goalManage.service.baseService.TestTableService; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class DemoServiceImpl implements DemoService { @DubboReference(check = false) private EmergencyDemoRpcAPi emergencyDemoRpcProvider; @Autowired private TestTableService testTableService; @Override public String getUserDescInfo(String name, String email) { User user = new User(); user.setName(name); user.setEmail(email); return emergencyDemoRpcProvider.sayHello(user); } @Override public ResultVO getById(Long id) { ResultVO resultVO = new ResultVO<>(); TestTable testTableInfo = testTableService.getById(id); if(testTableInfo != null){ resultVO.setCode(ResultCodes.OK.getCode()); resultVO.setData(testTableInfo); }else { resultVO.setCode(ResultCodes.OK.getCode()); } return resultVO; } @Override public ResultVO saveOne(String title) { ResultVO resultVO = new ResultVO<>(); TestTable testTable = new TestTable(); if(title == null || title.isEmpty() || title.trim().isEmpty()){ resultVO.setCode(ResultCodes.SERVER_PARAM_NULL.getCode()); }else { testTable.setTitle(title); if(testTableService.save(testTable)){ resultVO.setCode(ResultCodes.OK.getCode()); }else { resultVO.setCode(ResultCodes.SERVER_UPDATE_ERROR.getCode()); } } return resultVO; } }