#
Junjie
3 天以前 8a50a90c91918b7a97ae778c0fc63480279598db
src/main/java/com/zy/system/controller/UserLoginController.java
@@ -1,8 +1,8 @@
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;
@@ -24,7 +24,7 @@
    @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")
@@ -35,20 +35,22 @@
                  @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.orderBy(true, false, "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())));
            } else if (entry.getKey().endsWith("<")) {
                wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue())));
            String val = String.valueOf(entry.getValue());
            String column = humpToLine(entry.getKey());
            if (val.contains(" - ")) {
                String[] dates = val.split(" - ");
                wrapper.ge(column, DateUtils.convert(dates[0]));
                wrapper.le(column, DateUtils.convert(dates[1]));
            } else {
                wrapper.like(entry.getKey(), String.valueOf(entry.getValue()));
                wrapper.like(column, val);
            }
        }
    }
@@ -60,7 +62,7 @@
            return R.error();
        }
        if (null == userLogin.getId()){
            userLoginService.insert(userLogin);
            userLoginService.save(userLogin);
        } else {
            userLoginService.updateById(userLogin);
        }
@@ -70,7 +72,7 @@
    @RequestMapping(value = "/userLogin/add/auth")
    @ManagerAuth
    public R add(UserLogin userLogin) {
        userLoginService.insert(userLogin);
        userLoginService.save(userLogin);
        return R.ok();
    }
@@ -90,7 +92,7 @@
        if (Cools.isEmpty(ids)){
            return R.error();
        }
        userLoginService.deleteBatchIds(Arrays.asList(ids));
        userLoginService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
@@ -98,19 +100,19 @@
    @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<>();