| | |
| | | package com.zy.system.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | |
| | | @RequestMapping(value = "/userLogin/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok(userLoginService.selectById(String.valueOf(id))); |
| | | return R.ok(userLoginService.getById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/userLogin/list/auth") |
| | |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | excludeTrash(param); |
| | | EntityWrapper<UserLogin> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<UserLogin> wrapper = new QueryWrapper<>(); |
| | | convert(param, wrapper); |
| | | wrapper.orderBy("id", false); |
| | | return R.ok(userLoginService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | wrapper.orderByDesc("id"); |
| | | return R.ok(userLoginService.page(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private void convert(Map<String, Object> map, EntityWrapper wrapper){ |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | |
| | | return R.error(); |
| | | } |
| | | if (null == userLogin.getId()){ |
| | | userLoginService.insert(userLogin); |
| | | userLoginService.save(userLogin); |
| | | } else { |
| | | userLoginService.updateById(userLogin); |
| | | } |
| | |
| | | @RequestMapping(value = "/userLogin/add/auth") |
| | | @ManagerAuth |
| | | public R add(UserLogin userLogin) { |
| | | userLoginService.insert(userLogin); |
| | | userLoginService.save(userLogin); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | if (Cools.isEmpty(ids)){ |
| | | return R.error(); |
| | | } |
| | | userLoginService.deleteBatchIds(Arrays.asList(ids)); |
| | | userLoginService.removeByIds(Arrays.asList(ids)); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | EntityWrapper<UserLogin> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<UserLogin> wrapper = new QueryWrapper<>(); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("userLogin")); |
| | | convert(map, wrapper); |
| | | List<UserLogin> list = userLoginService.selectList(wrapper); |
| | | List<UserLogin> list = userLoginService.list(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/userLoginQuery/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<UserLogin> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<UserLogin> wrapper = new QueryWrapper<>(); |
| | | wrapper.like("token", condition); |
| | | Page<UserLogin> page = userLoginService.selectPage(new Page<>(0, 10), wrapper); |
| | | Page<UserLogin> page = userLoginService.page(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (UserLogin userLogin : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |