1
3 天以前 7fb2fa2382a4de194c0e906a8b206f854a3de17f
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
package com.zy.asrs.controller;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.zy.asrs.entity.BasArm;
import com.zy.asrs.service.BasArmService;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.*;
 
@RestController
public class BasArmController extends BaseController {
 
    @Autowired
    private BasArmService basArmService;
 
    @RequestMapping(value = "/basArm/{id}/auth")
    @ManagerAuth
    public R get(@PathVariable("id") String id) {
        return R.ok(basArmService.selectById(String.valueOf(id)));
    }
 
    @RequestMapping(value = "/basArm/add/auth")
    @ManagerAuth
    public R add(BasArm basArm) {
        basArmService.insert(basArm);
        return R.ok();
    }
 
    @RequestMapping(value = "/basArm/update/auth")
    @ManagerAuth
    public R update(BasArm basArm){
        if (Cools.isEmpty(basArm) || null==basArm.getId()){
            return R.error();
        }
        basArmService.updateById(basArm);
        return R.ok();
    }
 
    @RequestMapping(value = "/basArm/delete/auth")
    @ManagerAuth
    public R delete(@RequestParam(value="ids[]") Long[] ids){
         for (Long id : ids){
            basArmService.deleteById(id);
        }
        return R.ok();
    }
 
    @RequestMapping(value = "/basArmQuery/auth")
    @ManagerAuth
    public R query(String condition) {
        EntityWrapper<BasArm> wrapper = new EntityWrapper<>();
        wrapper.like("id", condition);
        Page<BasArm> page = basArmService.selectPage(new Page<>(0, 10), wrapper);
        List<Map<String, Object>> result = new ArrayList<>();
        for (BasArm basArm : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", basArm.getId());
            map.put("value", basArm.getId());
            result.add(map);
        }
        return R.ok(result);
    }
 
    @RequestMapping(value = "/basArm/check/column/auth")
    @ManagerAuth
    public R query(@RequestBody JSONObject param) {
        Wrapper<BasArm> wrapper = new EntityWrapper<BasArm>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
        if (null != basArmService.selectOne(wrapper)){
            return R.parse(BaseRes.REPEAT).add(getComment(BasArm.class, String.valueOf(param.get("key"))));
        }
        return R.ok();
    }
 
}