道路环境监测node后端和java后台代码
wangrong
2021-11-24 ac1a5f4542431c28b5865acbeb81985cefdbc2a8
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
package com.example.demo.handler;
 
import com.example.demo.dao.TaxiDataRepository;
import com.example.demo.model.roades.TaxiRealtimedata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xyz.erupt.annotation.fun.OperationHandler;
import xyz.erupt.core.exception.EruptApiErrorTip;
import xyz.erupt.core.view.EruptApiModel;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
/**
 * @author liyuepeng
 * @date 2018-10-10.
 */
@Component
public class OperationHandler2Impl implements OperationHandler<TaxiRealtimedata, Void> {
 
    @Resource
    private HttpServletRequest request; //展示自动注入功能
 
    @Autowired
    private TaxiDataRepository taxiDataRepository;
 
    @Override
    public void exec(List<TaxiRealtimedata> data, Void vo, String[] param) {
        System.out.println(request.getAttributeNames());
        for (int i = 0; i < data.size(); i++) {
            TaxiRealtimedata taxiRealtimedata =  data.get(i);
            taxiRealtimedata.setFlag("N");
            taxiDataRepository.save(taxiRealtimedata);
        }
//        throw new EruptApiErrorTip(new EruptApiModel(EruptApiModel.Status.WARNING,
//                "自定义报错提示:" + request.getServletPath(), EruptApiModel.PromptWay.NOTIFY));
    }
 
    //1.7.3及以上版本致辞此功能
    //exec 执行成功后需要执行的 JavaScript 表达式
    public String afterJS(List<TaxiRealtimedata> data, Void vo, String[] param) {
        return "alert('自定义按钮执行成功后,执行的JS脚本')";
    }
 
}