| | |
| | | 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.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.service.DeviceConfigService; |
| | |
| | | @RequestMapping(value = "/deviceConfig/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(deviceConfigService.selectById(String.valueOf(id))); |
| | | return R.ok(deviceConfigService.getById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deviceConfig/list/auth") |
| | |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<DeviceConfig> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<DeviceConfig> wrapper = new QueryWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | allLike(DeviceConfig.class, param.keySet(), wrapper, condition); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(deviceConfigService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(true, "asc".equals(orderByType), humpToLine(orderByField));} |
| | | return R.ok(deviceConfigService.page(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | private <T> void convert(Map<String, Object> map, QueryWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | |
| | | @ManagerAuth |
| | | public R add(DeviceConfig deviceConfig) { |
| | | deviceConfig.setCreateTime(new Date()); |
| | | deviceConfigService.insert(deviceConfig); |
| | | deviceConfigService.save(deviceConfig); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Integer[] ids){ |
| | | for (Integer id : ids){ |
| | | deviceConfigService.deleteById(id); |
| | | deviceConfigService.removeById(id); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | @RequestMapping(value = "/deviceConfig/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | EntityWrapper<DeviceConfig> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<DeviceConfig> wrapper = new QueryWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("deviceConfig")); |
| | | convert(map, wrapper); |
| | | List<DeviceConfig> list = deviceConfigService.selectList(wrapper); |
| | | List<DeviceConfig> list = deviceConfigService.list(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deviceConfigQuery/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<DeviceConfig> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<DeviceConfig> wrapper = new QueryWrapper<>(); |
| | | wrapper.like("id", condition); |
| | | Page<DeviceConfig> page = deviceConfigService.selectPage(new Page<>(0, 10), wrapper); |
| | | Page<DeviceConfig> page = deviceConfigService.page(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (DeviceConfig deviceConfig : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | @RequestMapping(value = "/deviceConfig/check/column/auth") |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<DeviceConfig> wrapper = new EntityWrapper<DeviceConfig>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != deviceConfigService.selectOne(wrapper)){ |
| | | QueryWrapper<DeviceConfig> wrapper = new QueryWrapper<DeviceConfig>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != deviceConfigService.getOne(wrapper)){ |
| | | return R.parse(BaseRes.REPEAT).add(getComment(DeviceConfig.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |