package com.zy.asrs.common.sys.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.zy.asrs.common.sys.entity.UserLogin;
|
import com.zy.asrs.common.sys.service.UserLoginService;
|
import com.zy.asrs.common.web.BaseController;
|
import com.zy.asrs.framework.annotations.ManagerAuth;
|
import com.zy.asrs.framework.common.Cools;
|
import com.zy.asrs.framework.common.R;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.*;
|
|
@RestController
|
public class UserLoginController extends BaseController {
|
|
@Autowired
|
private UserLoginService userLoginService;
|
|
@RequestMapping(value = "/userLogin/{id}/auth")
|
@ManagerAuth
|
public R get(@PathVariable("id") Long id) {
|
return R.ok(userLoginService.getById(String.valueOf(id)));
|
}
|
|
@RequestMapping(value = "/userLogin/list/auth")
|
@ManagerAuth
|
public R list(@RequestParam(defaultValue = "1")Integer curr,
|
@RequestParam(defaultValue = "10")Integer limit,
|
@RequestParam Map<String, Object> param){
|
LambdaQueryWrapper<UserLogin> wrapper = new LambdaQueryWrapper<>();
|
return R.ok(userLoginService.page(new Page<>(curr, limit), wrapper));
|
}
|
|
@RequestMapping(value = "/userLogin/edit/auth")
|
@ManagerAuth
|
public R edit(UserLogin userLogin) {
|
if (Cools.isEmpty(userLogin)){
|
return R.error();
|
}
|
if (null == userLogin.getId()){
|
userLoginService.save(userLogin);
|
} else {
|
userLoginService.updateById(userLogin);
|
}
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/userLogin/add/auth")
|
@ManagerAuth
|
public R add(UserLogin userLogin) {
|
userLoginService.save(userLogin);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/userLogin/update/auth")
|
@ManagerAuth
|
public R update(UserLogin userLogin){
|
if (Cools.isEmpty(userLogin) || null==userLogin.getId()){
|
return R.error();
|
}
|
userLoginService.updateById(userLogin);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/userLogin/delete/auth")
|
@ManagerAuth
|
public R delete(Integer[] ids){
|
if (Cools.isEmpty(ids)){
|
return R.error();
|
}
|
userLoginService.removeByIds(Arrays.asList(ids));
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/userLoginQuery/auth")
|
@ManagerAuth
|
public R query(String condition) {
|
LambdaQueryWrapper<UserLogin> wrapper = new LambdaQueryWrapper<>();
|
wrapper.like(UserLogin::getToken, condition);
|
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<>();
|
map.put("id", userLogin.getId());
|
map.put("value", userLogin.getToken());
|
result.add(map);
|
}
|
return R.ok(result);
|
}
|
|
}
|