commit
10f1ca3f3a
@ -0,0 +1,103 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 管理员
|
||||
*/
|
||||
public class Admin extends Account implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Integer id;
|
||||
/** 用户名 */
|
||||
private String username;
|
||||
/** 密码 */
|
||||
private String password;
|
||||
/** 姓名 */
|
||||
private String name;
|
||||
/** 电话 */
|
||||
private String phone;
|
||||
/** 邮箱 */
|
||||
private String email;
|
||||
/** 头像 */
|
||||
private String avatar;
|
||||
/** 角色标识 */
|
||||
private String role;
|
||||
|
||||
@Override
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Admin;
|
||||
import com.example.service.AdminService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理员前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/admin")
|
||||
public class AdminController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Admin admin) {
|
||||
adminService.add(admin);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
adminService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
adminService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Admin admin) {
|
||||
adminService.updateById(admin);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Admin admin = adminService.selectById(id);
|
||||
return Result.success(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Admin admin ) {
|
||||
List<Admin> list = adminService.selectAll(admin);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Admin admin,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Admin> page = adminService.selectPage(admin, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Admin;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作admin相关数据接口
|
||||
*/
|
||||
public interface AdminMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Admin admin);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Admin admin);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Admin selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Admin> selectAll(Admin admin);
|
||||
|
||||
@Select("select * from admin where username = #{username}")
|
||||
Admin selectByUsername(String username);
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.example.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.example.common.Constants;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.common.enums.RoleEnum;
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Admin;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.mapper.AdminMapper;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理员业务处理
|
||||
**/
|
||||
@Service
|
||||
public class AdminService {
|
||||
|
||||
@Resource
|
||||
private AdminMapper adminMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Admin admin) {
|
||||
Admin dbAdmin = adminMapper.selectByUsername(admin.getUsername());
|
||||
if (ObjectUtil.isNotNull(dbAdmin)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_EXIST_ERROR);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(admin.getPassword())) {
|
||||
admin.setPassword(Constants.USER_DEFAULT_PASSWORD);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(admin.getName())) {
|
||||
admin.setName(admin.getUsername());
|
||||
}
|
||||
admin.setRole(RoleEnum.ADMIN.name());
|
||||
adminMapper.insert(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
adminMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
adminMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Admin admin) {
|
||||
adminMapper.updateById(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Admin selectById(Integer id) {
|
||||
return adminMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Admin> selectAll(Admin admin) {
|
||||
return adminMapper.selectAll(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Admin> selectPage(Admin admin, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Admin> list = adminMapper.selectAll(admin);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
public Account login(Account account) {
|
||||
Account dbAdmin = adminMapper.selectByUsername(account.getUsername());
|
||||
if (ObjectUtil.isNull(dbAdmin)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_NOT_EXIST_ERROR);
|
||||
}
|
||||
if (!account.getPassword().equals(dbAdmin.getPassword())) {
|
||||
throw new CustomException(ResultCodeEnum.USER_ACCOUNT_ERROR);
|
||||
}
|
||||
// 生成token
|
||||
String tokenData = dbAdmin.getId() + "-" + RoleEnum.ADMIN.name();
|
||||
String token = TokenUtils.createToken(tokenData, dbAdmin.getPassword());
|
||||
dbAdmin.setToken(token);
|
||||
return dbAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register(Account account) {
|
||||
Admin admin = new Admin();
|
||||
BeanUtils.copyProperties(account, admin);
|
||||
add(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
public void updatePassword(Account account) {
|
||||
Admin dbAdmin = adminMapper.selectByUsername(account.getUsername());
|
||||
if (ObjectUtil.isNull(dbAdmin)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_NOT_EXIST_ERROR);
|
||||
}
|
||||
if (!account.getPassword().equals(dbAdmin.getPassword())) {
|
||||
throw new CustomException(ResultCodeEnum.PARAM_PASSWORD_ERROR);
|
||||
}
|
||||
dbAdmin.setPassword(account.getNewPassword());
|
||||
adminMapper.updateById(dbAdmin);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 公告信息表
|
||||
*/
|
||||
public class Notice implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Integer id;
|
||||
/** 标题 */
|
||||
private String title;
|
||||
/** 内容 */
|
||||
private String content;
|
||||
/** 创建时间 */
|
||||
private String time;
|
||||
/** 创建人 */
|
||||
private String user;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Notice;
|
||||
import com.example.service.NoticeService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告信息表前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/notice")
|
||||
public class NoticeController {
|
||||
|
||||
@Resource
|
||||
private NoticeService noticeService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Notice notice) {
|
||||
noticeService.add(notice);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
noticeService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
noticeService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Notice notice) {
|
||||
noticeService.updateById(notice);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Notice notice = noticeService.selectById(id);
|
||||
return Result.success(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Notice notice ) {
|
||||
List<Notice> list = noticeService.selectAll(notice);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Notice notice,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Notice> page = noticeService.selectPage(notice, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Notice;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作notice相关数据接口
|
||||
*/
|
||||
public interface NoticeMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Notice notice);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Notice notice);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Notice selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Notice> selectAll(Notice notice);
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.example.service;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Notice;
|
||||
import com.example.mapper.NoticeMapper;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告信息表业务处理
|
||||
**/
|
||||
@Service
|
||||
public class NoticeService {
|
||||
|
||||
@Resource
|
||||
private NoticeMapper noticeMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Notice notice) {
|
||||
notice.setTime(DateUtil.today());
|
||||
Account currentUser = TokenUtils.getCurrentUser();
|
||||
notice.setUser(currentUser.getUsername());
|
||||
noticeMapper.insert(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
noticeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
noticeMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Notice notice) {
|
||||
noticeMapper.updateById(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Notice selectById(Integer id) {
|
||||
return noticeMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Notice> selectAll(Notice notice) {
|
||||
return noticeMapper.selectAll(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Notice> selectPage(Notice notice, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Notice> list = noticeMapper.selectAll(notice);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.example.service;
|
||||
|
||||
|
||||
import com.example.entity.Type;
|
||||
import com.example.mapper.TypeMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分类信息表业务处理
|
||||
**/
|
||||
@Service
|
||||
public class TypeService {
|
||||
|
||||
@Resource
|
||||
private TypeMapper typeMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Type type) {
|
||||
typeMapper.insert(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
typeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
typeMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Type type) {
|
||||
typeMapper.updateById(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Type selectById(Integer id) {
|
||||
return typeMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Type> selectAll(Type type) {
|
||||
return typeMapper.selectAll(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Type> selectPage(Type type, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Type> list = typeMapper.selectAll(type);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.example.common.Result;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.common.enums.RoleEnum;
|
||||
import com.example.entity.Account;
|
||||
import com.example.service.AdminService;
|
||||
import com.example.service.BusinessService;
|
||||
import com.example.service.UserService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 基础前端接口
|
||||
*/
|
||||
@RestController
|
||||
public class WebController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
@Resource
|
||||
private BusinessService businessService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("/")
|
||||
public Result hello() {
|
||||
return Result.success("访问成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Result login(@RequestBody Account account) {
|
||||
if (ObjectUtil.isEmpty(account.getUsername()) || ObjectUtil.isEmpty(account.getPassword())
|
||||
|| ObjectUtil.isEmpty(account.getRole())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
if (RoleEnum.ADMIN.name().equals(account.getRole())) {
|
||||
account = adminService.login(account);
|
||||
}
|
||||
if (RoleEnum.BUSINESS.name().equals(account.getRole())){
|
||||
account = businessService.login(account);
|
||||
}
|
||||
if(RoleEnum.USER.name().equals(account.getRole())){
|
||||
account = userService.login(account);
|
||||
}
|
||||
return Result.success(account);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
public Result register(@RequestBody Account account) {
|
||||
if (StrUtil.isBlank(account.getUsername()) || StrUtil.isBlank(account.getPassword())
|
||||
|| ObjectUtil.isEmpty(account.getRole())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
if (RoleEnum.ADMIN.name().equals(account.getRole())) {
|
||||
adminService.register(account);
|
||||
}
|
||||
if (RoleEnum.BUSINESS.name().equals(account.getRole())) {
|
||||
businessService.register(account);
|
||||
}
|
||||
if (RoleEnum.USER.name().equals(account.getRole())) {
|
||||
userService.register(account);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@PutMapping("/updatePassword")
|
||||
public Result updatePassword(@RequestBody Account account) {
|
||||
if (StrUtil.isBlank(account.getUsername()) || StrUtil.isBlank(account.getPassword())
|
||||
|| ObjectUtil.isEmpty(account.getNewPassword())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
if (RoleEnum.ADMIN.name().equals(account.getRole())) {
|
||||
adminService.updatePassword(account);
|
||||
}
|
||||
if (RoleEnum.BUSINESS.name().equals(account.getRole())) {
|
||||
businessService.updatePassword(account);
|
||||
}
|
||||
if (RoleEnum.USER.name().equals(account.getRole())) {
|
||||
userService.updatePassword(account);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue