|
|
@ -1,5 +1,6 @@
|
|
|
|
package com.watu.demo1.Controller;
|
|
|
|
package com.watu.demo1.Controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.watu.demo1.Service.IUserPlusService;
|
|
|
|
import com.watu.demo1.mapper.UserMapper;
|
|
|
|
import com.watu.demo1.mapper.UserMapper;
|
|
|
|
import com.watu.demo1.pojo.DTO.UserDTO;
|
|
|
|
import com.watu.demo1.pojo.DTO.UserDTO;
|
|
|
|
import com.watu.demo1.pojo.entity.User;
|
|
|
|
import com.watu.demo1.pojo.entity.User;
|
|
|
@ -11,45 +12,63 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("v1/test/")
|
|
|
|
@RequestMapping("v1/Plus/")
|
|
|
|
public class UserController {
|
|
|
|
public class UserController {
|
|
|
|
@Autowired(required = false)
|
|
|
|
// @Autowired(required = false)
|
|
|
|
private UserMapper userMapper;
|
|
|
|
// private UserMapper userMapper;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// /**添加员工*/
|
|
|
|
|
|
|
|
// @PostMapping("insert")
|
|
|
|
|
|
|
|
// public String addUser(@RequestBody UserDTO userDTO){
|
|
|
|
|
|
|
|
// User user = new User();
|
|
|
|
|
|
|
|
// BeanUtils.copyProperties(userDTO,user);
|
|
|
|
|
|
|
|
// int insert = userMapper.insertUser(user);
|
|
|
|
|
|
|
|
// return (insert != 0) ? "添加成功" : "添加失败";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//// /**查询员工*/
|
|
|
|
|
|
|
|
//// @GetMapping("select")
|
|
|
|
|
|
|
|
//// public UserVO selectUser(){
|
|
|
|
|
|
|
|
//// List<UserVO> List = userMapper.selectAll();
|
|
|
|
|
|
|
|
//// return new JsonResult(StatusCode.OPERATION_SUCCESS,list);
|
|
|
|
|
|
|
|
//// }
|
|
|
|
|
|
|
|
// /**根据ID来查询员工*/
|
|
|
|
|
|
|
|
// @GetMapping("select/{id}")
|
|
|
|
|
|
|
|
// public UserVO selectUser(@PathVariable int id){
|
|
|
|
|
|
|
|
// UserVO userVO = userMapper.selectById(id);
|
|
|
|
|
|
|
|
// return userVO;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// /**更新*/
|
|
|
|
|
|
|
|
// @PostMapping("/update")
|
|
|
|
|
|
|
|
// public String updateUser(@RequestBody User user){
|
|
|
|
|
|
|
|
// int insert = userMapper.updateUser(user);
|
|
|
|
|
|
|
|
// return (insert != 0) ? "添加成功" : "添加失败";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// /**删除*/
|
|
|
|
|
|
|
|
// @GetMapping("delete/{id}")
|
|
|
|
|
|
|
|
// public String deleteUser(@PathVariable int id){
|
|
|
|
|
|
|
|
// int insert = userMapper.deleteUser(id);
|
|
|
|
|
|
|
|
// return (insert != 0) ? "添加成功" : "添加失败";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/**添加员工*/
|
|
|
|
@Autowired
|
|
|
|
@PostMapping("insert")
|
|
|
|
IUserPlusService service;
|
|
|
|
public String addUser(@RequestBody UserDTO userDTO){
|
|
|
|
@PostMapping("add")
|
|
|
|
User user = new User();
|
|
|
|
public void addNewUser(@RequestBody UserDTO userDTO){
|
|
|
|
BeanUtils.copyProperties(userDTO,user);
|
|
|
|
service.addUser(userDTO);
|
|
|
|
int insert = userMapper.insertUser(user);
|
|
|
|
|
|
|
|
if (insert!=0){
|
|
|
|
|
|
|
|
return "添加成功";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "添加失败";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("delete/{id}")
|
|
|
|
// /**查询员工*/
|
|
|
|
public void delete(@PathVariable Long id){
|
|
|
|
// @GetMapping("select")
|
|
|
|
service.deleteById(id);
|
|
|
|
// public UserVO selectUser(){
|
|
|
|
|
|
|
|
// List<UserVO> List = userMapper.selectAll();
|
|
|
|
|
|
|
|
// return new JsonResult(StatusCode.OPERATION_SUCCESS,list);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
/**根据ID来查询员工*/
|
|
|
|
|
|
|
|
@GetMapping("select/{id}")
|
|
|
|
|
|
|
|
public UserVO selectUser(@PathVariable int id){
|
|
|
|
|
|
|
|
UserVO userVO = userMapper.selectById(id);
|
|
|
|
|
|
|
|
return userVO;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**更新*/
|
|
|
|
@PostMapping("select")
|
|
|
|
@PostMapping("/update")
|
|
|
|
public void select(@RequestBody UserDTO userDTO){
|
|
|
|
public String updateUser(@RequestBody User user){
|
|
|
|
service.selectByName(userDTO);
|
|
|
|
int insert = userMapper.updateUser(user);
|
|
|
|
|
|
|
|
return (insert != 0) ? "添加成功" : "添加失败";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**删除*/
|
|
|
|
@PostMapping("update/d1")
|
|
|
|
@GetMapping("delete/{id}")
|
|
|
|
public void update(@RequestBody UserDTO userDTO){
|
|
|
|
public String deleteUser(@PathVariable int id){
|
|
|
|
service.updateById(userDTO);
|
|
|
|
int insert = userMapper.deleteUser(id);
|
|
|
|
|
|
|
|
return (insert != 0) ? "添加成功" : "添加失败";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|