许鹏程
2024-05-28 e6720f333268682d11aedb3b3308fa2f2c3a40df
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.product.data.sync.controller;
 
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.data.sync.config.CmnConst;
import com.product.data.sync.config.SystemCode;
import com.product.data.sync.service.FeDataDSService;
import com.product.data.sync.service.SyFeDataService;
import com.product.module.sys.version.ApiVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
 
 
@RestController
@RequestMapping("/api/syncfe")
public class SyFeDataController extends AbstractBaseController {
    @Autowired
    public SyFeDataService syFeDataService;
 
    @Autowired
    public FeDataDSService feDataDSService;
 
    @RequestMapping(value = "/sy-oracle-fun/{version}", method = RequestMethod.POST)
    public String saveSyncConfig(HttpServletRequest request) {
        try {
            //获取参数
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            //判断参数是否为空
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            //判断表名是否正常
            if (!CmnConst.PRODUCT_SYS_FUNCTIONS.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            String uuid = syFeDataService.saveSyncFedata(fse);
 
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e);
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getValue(), SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getText());
        }
    }
 
 
    @PostMapping("/flow-sync/{version}")
    @ApiVersion(1)
    public String flowSync() {
        try {
            syFeDataService.flowPermission();
            return OK();
        } catch (Exception e) {
            e.printStackTrace();
            return error(new BaseException(e));
        }
    }
 
}