whycrzg
2021-02-19 656bd1b190ed296a7bf63623dc8e9fe2bc9d3098
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.fgkj.controller;
 
import com.fgkj.dto.*;
import com.fgkj.mapper.UinfDaoFactory;
import com.fgkj.services.Batt_attentionService;
import com.fgkj.services.User_logService;
import com.fgkj.util.ActionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
@RequestMapping("battAttention")
@RestController
@Api(tags = "battAttention接口")
public class Batt_attentionController{
 
    @Resource
    private Batt_attentionService service;
 
    @Resource
    private User_logService uservice;
 
    
    //添加关注
    @PostMapping("/")
    @ApiOperation(notes = "",value="添加关注")
    public ServiceModel add(@RequestParam Integer battGroupId,@RequestParam Integer monNum) {
        Batt_attention attention = new Batt_attention();
        User_inf uinf = (User_inf)ActionUtil.getUser();
//        User_inf uinf = new User_inf();
//        uinf.setuId(1001);
        attention.setUid(uinf.getuId());
        attention.setBattGroupId(battGroupId);
        attention.setMonNum(monNum);
        ServiceModel model = service.add(attention);
        if (model.getCode().equals(1)){
            String msg="添加对"+attention.getBattGroupId()+"电池组的"+attention.getMonNum()+"单体的关注";
            User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
            uservice.add(ulog);//将用户的操作记录下来
        }
 
        return model;
 
    }
 
    /*@PutMapping("/")
    public ServiceModel update(@RequestBody Batt_attention attention) {
        // Batt_attention attention = getGson().fromJson(json, Batt_attention.class);
        ServiceModel model = service.update(attention);
 
        return model;
    }*/
    
    //取消关注
    @DeleteMapping("/")
    @ApiOperation(notes = "",value="取消关注")
    public ServiceModel delete(@RequestParam Integer battGroupId,@RequestParam Integer monNum) {
        Batt_attention attention = new Batt_attention();
        User_inf uinf = (User_inf)ActionUtil.getUser();
        attention.setUid(uinf.getuId());
        attention.setBattGroupId(battGroupId);
        attention.setMonNum(monNum);
        ServiceModel model = service.delete(attention);
        if (model.getCode().equals(1)){
            String msg="取消对"+attention.getBattGroupId()+"电池组的"+attention.getMonNum()+"号单体的关注";
            User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg);
            uservice.add(ulog);//将用户的操作记录下来
        }
 
        return model;
    }
 
    //根据电池组的筛选条件,查询单体的实际电压
    @PostMapping("byCondition")
    @ApiOperation(notes = "{ \"binf\": { \"stationName1\": \"\", \"stationName\": \"\", \"battGroupId\": 0, \"monNum\": 0 },\"pageBean\": { \"pageNum\": 1, \"pageSize\": 3 } }",value="根据电池组的筛选条件,查询单体的实际电压")
    public ServiceModel serchByCondition(@RequestBody Batt_Maint_Dealarm bmd) {
        // Batt_Maint_Dealarm bmd = getGson().fromJson(json, Batt_Maint_Dealarm.class);
        User_inf uinf = (User_inf)ActionUtil.getUser();
        bmd.getBinf().setNum(uinf.getuId());
        ServiceModel model = service.serchByCondition(bmd);
 
        return model;
    }
     //关注之前识别是否关注过
    @GetMapping("judge")
    @ApiOperation(notes = "",value="关注之前识别是否关注过")
    public ServiceModel judgeInOrNot(@RequestParam Integer battGroupId,@RequestParam Integer monNum) {
        Batt_attention attention = new Batt_attention();
        User_inf uinf = (User_inf)ActionUtil.getUser();
        attention.setUid(uinf.getuId());
        attention.setBattGroupId(battGroupId);
        attention.setMonNum(monNum);
        ServiceModel model = service.judgeInOrNot(attention);
 
        return model;
    }
 
}