SZH
2022-06-29 00a4338443d09932ed4c56266d8c4e73ff60b46c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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<TestTable> getById(Long id) {
        ResultVO<TestTable> 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<TestTable> saveOne(String title) {
        ResultVO<TestTable> 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;
    }
}