| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class UserController extends BaseController { |
| | | |
| | | public static final String COMMON_PASSWORD = "123456"; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | |
| | | @OperationLog("添加用户") |
| | | @PostMapping("/user/save") |
| | | public R save(@RequestBody User user) { |
| | | |
| | | user.setPassword(userService.encodePassword(COMMON_PASSWORD)); |
| | | |
| | | user.setCreateBy(getLoginUserId()); |
| | | user.setCreateTime(new Date()); |
| | | user.setUpdateBy(getLoginUserId()); |
| | | user.setUpdateTime(new Date()); |
| | | |
| | | if (!userService.save(user)) { |
| | | return R.error("添加失败"); |
| | | } |
| | |
| | | @OperationLog("修改用户") |
| | | @PostMapping("/user/update") |
| | | public R update(@RequestBody User user) { |
| | | |
| | | if (!Cools.isEmpty(user.getPassword())) { |
| | | user.setPassword(userService.encodePassword(user.getPassword())); |
| | | } |
| | | |
| | | user.setUpdateBy(getLoginUserId()); |
| | | user.setUpdateTime(new Date()); |
| | | |
| | | if (!userService.updateById(user)) { |
| | | return R.error("修改失败"); |
| | | } |