|
|
|
@ -1,18 +1,20 @@
|
|
|
|
|
package com.watu.demo1.Controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.watu.demo1.Service.IUserPlusService;
|
|
|
|
|
import com.watu.demo1.mapper.UserMapper;
|
|
|
|
|
import com.watu.demo1.pojo.DTO.UserDTO;
|
|
|
|
|
import com.watu.demo1.pojo.entity.User;
|
|
|
|
|
import com.watu.demo1.pojo.query.UserQuery;
|
|
|
|
|
import com.watu.demo1.pojo.vo.UserVO;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("v1/Plus/")
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class UserController {
|
|
|
|
|
// @Autowired(required = false)
|
|
|
|
|
// private UserMapper userMapper;
|
|
|
|
@ -51,24 +53,37 @@ public class UserController {
|
|
|
|
|
// return (insert != 0) ? "添加成功" : "添加失败";
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
IUserPlusService service;
|
|
|
|
|
private final IUserPlusService service;
|
|
|
|
|
|
|
|
|
|
@PostMapping("add")
|
|
|
|
|
public void addNewUser(@RequestBody UserDTO userDTO) {
|
|
|
|
|
service.addUser(userDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("delete/{id}")
|
|
|
|
|
public void delete(@PathVariable Long id) {
|
|
|
|
|
service.deleteById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("select")
|
|
|
|
|
public void select(@RequestBody UserDTO userDTO) {
|
|
|
|
|
service.selectByName(userDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("update/d1")
|
|
|
|
|
public void update(@RequestBody UserDTO userDTO) {
|
|
|
|
|
service.updateById(userDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**复杂的条件查询*/
|
|
|
|
|
/**条件多,定义对象去封装,,,哦~~师傅之前可能是这个意思*/
|
|
|
|
|
/**
|
|
|
|
|
* 是可以在Controller直接调用一些list方法的,但是代码会臃肿,可以自定义方法。
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
public List<UserVO> queryInFo(UserQuery query) {
|
|
|
|
|
List<User> users=service.queryUsers(query.getAge(),query.getId(),query.getName(),query.getVersion());
|
|
|
|
|
return BeanUtil.copyToList(users,UserVO.class);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|