-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from zhaojun1998/dev
✨ 角色列表, 激活, 禁用功能.
- Loading branch information
Showing
24 changed files
with
341 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,50 @@ | ||
package im.zhaojun.controller; | ||
|
||
import im.zhaojun.mapper.UserMapper; | ||
import im.zhaojun.model.User; | ||
import com.github.pagehelper.PageInfo; | ||
import im.zhaojun.model.vo.UserVO; | ||
import im.zhaojun.service.UserService; | ||
import im.zhaojun.util.PageResultBean; | ||
import im.zhaojun.util.ResultBean; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import javax.annotation.Resource; | ||
import java.util.List; | ||
|
||
@Controller | ||
public class UserController { | ||
|
||
@Resource | ||
private UserMapper userMapper; | ||
private UserService userService; | ||
|
||
@RequestMapping("/user") | ||
@GetMapping("/users") | ||
public String getUsers() { | ||
return "member-list"; | ||
} | ||
|
||
@GetMapping("/users/page") | ||
@ResponseBody | ||
public PageResultBean<UserVO> userList(@RequestParam(value = "username", required = false) String username, | ||
@RequestParam(value = "page", defaultValue = "1") int page, | ||
@RequestParam(value = "limit", defaultValue = "10")int limit) { | ||
List<UserVO> users = userService.findListByUserName(username, page, limit); | ||
PageInfo<UserVO> userPageInfo = new PageInfo<>(users); | ||
return new PageResultBean<>(userPageInfo.getTotal(), userPageInfo.getList()); | ||
} | ||
|
||
|
||
@PostMapping("/user/disable") | ||
@ResponseBody | ||
public ResultBean<Boolean> disable(Integer id) { | ||
return new ResultBean<>(userService.disableUserByID(id)); | ||
} | ||
|
||
@PostMapping("/user/enable") | ||
@ResponseBody | ||
public User get() { | ||
return userMapper.selectByPrimaryKey(1); | ||
public ResultBean<Boolean> enable(Integer id) { | ||
return new ResultBean<>(userService.enableUserByID(id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package im.zhaojun.model.vo; | ||
|
||
import java.util.Date; | ||
|
||
public class UserVO { | ||
private Integer userId; | ||
|
||
private String username; | ||
|
||
private String email; | ||
|
||
private String status; | ||
|
||
private Date lastLoginTime; | ||
|
||
public Integer getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(Integer userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(String status) { | ||
this.status = status; | ||
} | ||
|
||
public Date getLastLoginTime() { | ||
return lastLoginTime; | ||
} | ||
|
||
public void setLastLoginTime(Date lastLoginTime) { | ||
this.lastLoginTime = lastLoginTime; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package im.zhaojun.service; | ||
|
||
import com.github.pagehelper.PageHelper; | ||
import im.zhaojun.mapper.UserMapper; | ||
import im.zhaojun.model.User; | ||
import im.zhaojun.model.vo.UserVO; | ||
import org.springframework.beans.BeanUtils; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.annotation.Resource; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Service | ||
public class UserService { | ||
|
||
@Resource | ||
private UserMapper userMapper; | ||
|
||
public List<UserVO> findListByUserName(String username, int page, int rows) { | ||
PageHelper.startPage(page, rows); | ||
List<User> userList = userMapper.findListByUserName(username); | ||
List<UserVO> userVOList = new ArrayList<>(); | ||
for (User user : userList) { | ||
UserVO userVO = new UserVO(); | ||
BeanUtils.copyProperties(user, userVO); | ||
userVOList.add(userVO); | ||
} | ||
return userVOList; | ||
} | ||
|
||
public boolean disableUserByID(Integer id) { | ||
return userMapper.updateStatusByPrimaryKey(id, 0) == 1; | ||
} | ||
|
||
public boolean enableUserByID(Integer id) { | ||
return userMapper.updateStatusByPrimaryKey(id, 1) == 1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.