diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/backstage/BackstageController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/backstage/BackstageController.java index 88888e20..efc52567 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/backstage/BackstageController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/backstage/BackstageController.java @@ -1,6 +1,7 @@ package com.ruoyi.web.controller.backstage; import com.github.pagehelper.PageInfo; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.HttpStatus; @@ -9,6 +10,7 @@ import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.AppLoginBody; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.ip.IpUtils; import com.ruoyi.framework.web.service.SysLoginService; @@ -76,6 +78,11 @@ public class BackstageController { @Autowired private SysLoginService loginService; +// @Autowired +// private ISysUserService userService; + + + // 查看系统用户 @GetMapping("/getAllUserInfo") public TableDataInfo getAllUserInfo(){ @@ -102,6 +109,7 @@ public class BackstageController { } + // 修改用户状态 @PostMapping("/changeUserStatus") public AjaxResult changeUserState(@RequestBody UpdateUserStateDto updateUserStateDto){ @@ -125,6 +133,7 @@ public class BackstageController { } + //获取所有用户总数 @GetMapping("/getUserCount") public AjaxResult getUserCount(){ @@ -143,6 +152,7 @@ public class BackstageController { } + // 获取近7天用户总数 @GetMapping("/getSeUserCount") public AjaxResult getSeUserCount(){ if(isAuthority(Constants.USER_TYPE_ADMIN)){ @@ -191,6 +201,7 @@ public class BackstageController { } } + @Log(title = "内容审核--审核作品", businessType = BusinessType.UPDATE) //审核作品 @PostMapping("reviewWork") public AjaxResult reviewWork(@RequestBody ReviewWorkDto reviewWorkDto){ @@ -248,6 +259,7 @@ public class BackstageController { } + /* * 获取所有城市数景区数资源位数*/ @GetMapping("stCityScenicSource") @@ -269,21 +281,22 @@ public class BackstageController { return error("无权限访问"); } +// @Log(title = "产品管理--获取所有资源位详情", businessType = BusinessType.GET) /* * 获取所有资源位详情*/ @GetMapping("getAllSource") - public AjaxResult getAllSource(){ + public TableDataInfo getAllSource(){ if(isAuthority(Constants.USER_TYPE_ADMIN)){ startPage(); List sysSourceList = sysSourceService.selectSysSourceList(new SysSource()); - AjaxResult ajax = new AjaxResult(); - ajax.put("sourceList", sysSourceList); - return ajax; + + return getDataTable(sysSourceList); } - return error("无权限访问"); + return noAuthority(); } + @Log(title = "产品管理--更换资源的默认背景", businessType = BusinessType.UPDATE) // 更换资源的默认背景 @PostMapping("/changeSourceBackground") public AjaxResult updateUserInfo(@RequestParam("changeSourceBackgroundDto") String changeSourceBackgroundDt,@RequestParam("work") MultipartFile work) @@ -341,6 +354,7 @@ public class BackstageController { // return AjaxResult.success(); } + @Log(title = "产品管理--修改资源位价格", businessType = BusinessType.UPDATE) //修改资源位价格, // 参数: 城市,景区,区域,价格 @PostMapping("/changeSourcePrice") @@ -366,6 +380,7 @@ public class BackstageController { } +// @Log(title = "系统管理--角色管理--获取用户类型", businessType = BusinessType.GET) //获取系统所有用户 @GetMapping("/getAllUserType") public TableDataInfo getAllUser(){ @@ -378,6 +393,7 @@ public class BackstageController { return noAuthority(); } + @Log(title = "系统管理--角色管理--修改用户类型", businessType = BusinessType.UPDATE) //修改用户类型内容 @PostMapping("/changeUserType") public AjaxResult changeUserType(@RequestBody UserType userType){ @@ -393,6 +409,7 @@ public class BackstageController { } + @Log(title = "系统管理--角色管理--新建用户类型", businessType = BusinessType.INSERT) // 新建用户类型 @PostMapping("/createUserType") public AjaxResult createUserType(@RequestBody UserType userType){ @@ -408,6 +425,7 @@ public class BackstageController { } + @Log(title = "系统管理--角色管理--删除用户类型", businessType = BusinessType.DELETE) //删除用户类型 @PostMapping("/deleteUserType") public AjaxResult deleteUserType(@RequestParam("typeId") Long typeId){ @@ -421,6 +439,7 @@ public class BackstageController { return error("无权限访问"); } + @Log(title = "系统登录--账密登录", businessType = BusinessType.OTHER) // 后台账密登录 @PostMapping("/loginPassword") public AjaxResult loginPassword(@RequestBody AppLoginBody loginBody) { @@ -431,6 +450,7 @@ public class BackstageController { return ajax; } + @Log(title = "系统登录--验证码登录", businessType = BusinessType.OTHER) // 后台验证码登录 @PostMapping("/loginSms") public AjaxResult loginMessage(@RequestBody AppLoginBody loginBody) { @@ -441,6 +461,97 @@ public class BackstageController { return ajax; } +// @Log(title = "系统管理--人员管理--获取所有后台系统用户", businessType = BusinessType.GET) + //人员管理---获取所有后台系统用户 + @GetMapping("/getAllBackstageUser") + public TableDataInfo getAllBackstageUser() { + if(isAuthority(Constants.USER_TYPE_ADMIN)){ + startPage(); + List sysUserList = sysUserService.selectBackstageUserList(); + return getDataTable(sysUserList); + } + return noAuthority(); + + } + + //新建后台用户 + @Log(title = "系统管理--人员管理--新建后台用户", businessType = BusinessType.INSERT) + @PostMapping("/createBackstageUser") + public AjaxResult createBackstageUser(@RequestBody BackstageUserDto backstageUserDto){ + if(isAuthority(Constants.USER_TYPE_ADMIN)){ + String nickName = backstageUserDto.getNickName(); + String phone = backstageUserDto.getPhone(); + String realName = backstageUserDto.getRealName(); + String status = backstageUserDto.getStatus(); + String userType = backstageUserDto.getUserType(); + String password = backstageUserDto.getPassword(); + + //先验证手机号是否已经注册 + int i = sysUserService.checkUserPhone(phone); + if (i > 0) { + return error("该手机号已经注册"); + } + + SysUser sysUser = new SysUser(); + sysUser.setNickName(nickName); + sysUser.setPhonenumber(phone); + sysUser.setStatus(status); + sysUser.setUserType(userType); + sysUser.setUserName(phone); + sysUser.setAvatar("https://gips0.baidu.com/it/u=3124792457,2870658645&fm=3039&app=3039&f=JPEG"); + sysUser.setPassword(SecurityUtils.encryptPassword(password)); + + UserInfo userInfo = new UserInfo(); + + + int back = sysUserService.insertUser(sysUser); + + if (back > 0){ + System.out.println(nickName+","+phone+","+realName+","+status+","+userType); + + // 查询数据库中的用户账号信息 + SysUser newSysUser = sysUserService.selectUserByUserName(phone); + //---------------------------- 新建用户个人信息-------------------------------------------- + userInfo.setUserId(newSysUser.getUserId()); + userInfo.setRealName(realName); + userInfo.setPhonenumber(phone); + userInfo.setBackGround("https://img.keaitupian.cn/newupload/11/1668068437206545.jpg"); + // 获取当前时间的毫秒值 + long currentTimeMillis = System.currentTimeMillis(); + // 利用毫秒值构造Date对象 + Date currentDate = new Date(currentTimeMillis); + userInfo.setUpdateTime(currentDate); + + //设置上一次计算时间大约为10天前 + Date calculationTime = new Date(currentTimeMillis-1000000000); + userInfo.setCalculationTime(calculationTime); + + int infoFlag = userInfoService.insertUserInfo(userInfo); + if (infoFlag == 0) { + return error("个人信息注册失败,请联系系统管理人员"); + } + return success("新建用户成功"); + } + + return error("新建用户失败, 请联系管理员"); + } + return error("无权限访问"); + } + + @Log(title = "系统管理--人员管理--删除后台用户", businessType = BusinessType.DELETE) + // 删除后台用户 + @PostMapping("/deleteBackstageUser") + public AjaxResult deleteBackstageUser(@RequestParam("userId") Long userId){ + if(isAuthority(Constants.USER_TYPE_ADMIN)){ + int back = sysUserService.deleteUserById(userId); + if(back > 0){ + return success("删除用户成功"); + } + return error("删除用户失败"); + } + return error("无权限访问"); + } + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java index 5378424a..dd494119 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java @@ -2,6 +2,13 @@ package com.ruoyi.web.controller.monitor; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.ip.IpUtils; +import com.ruoyi.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; @@ -31,13 +38,20 @@ public class SysOperlogController extends BaseController @Autowired private ISysOperLogService operLogService; - @PreAuthorize("@ss.hasPermi('monitor:operlog:list')") + @Autowired + private ISysUserService sysUserService; + +// @PreAuthorize("@ss.hasPermi('monitor:operlog:list')") @GetMapping("/list") public TableDataInfo list(SysOperLog operLog) { - startPage(); - List list = operLogService.selectOperLogList(operLog); - return getDataTable(list); + if(isAuthority(Constants.USER_TYPE_ADMIN)){ + startPage(); + List list = operLogService.selectOperLogList(operLog); + return getDataTable(list); + } + return noAuthority(); + } @Log(title = "操作日志", businessType = BusinessType.EXPORT) @@ -51,11 +65,14 @@ public class SysOperlogController extends BaseController } @Log(title = "操作日志", businessType = BusinessType.DELETE) - @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") +// @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") @DeleteMapping("/{operIds}") public AjaxResult remove(@PathVariable Long[] operIds) { - return toAjax(operLogService.deleteOperLogByIds(operIds)); + if(isAuthority(Constants.USER_TYPE_ADMIN)) { + return toAjax(operLogService.deleteOperLogByIds(operIds)); + } + return error("无权限操作, 以记录登录ip"); } @Log(title = "操作日志", businessType = BusinessType.CLEAN) @@ -66,4 +83,29 @@ public class SysOperlogController extends BaseController operLogService.cleanOperLog(); return success(); } + + private boolean isAuthority(String type){ + SysUser user = SecurityUtils.getLoginUser().getUser(); + Long userId = user.getUserId(); + SysUser user1 = sysUserService.selectUserById(userId); + String userType = user1.getUserType(); + + if(userType.equals(type)){ + return true; + } + + String ip = IpUtils.getIpAddr(); +// LOGGER.info("无权限用户认证,ip:"+ip); + + return false; + + } + + private TableDataInfo noAuthority() + { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.ERROR); + rspData.setMsg("无权限"); + return rspData; + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java index 2bbeaf7d..322e7dd5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java @@ -56,4 +56,9 @@ public enum BusinessType * 清空数据 */ CLEAN, + + /* + * 获取列表 + * */ + GET, } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BackstageUserDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BackstageUserDto.java new file mode 100644 index 00000000..d27a774b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BackstageUserDto.java @@ -0,0 +1,65 @@ +package com.ruoyi.system.domain.dto; + +import java.util.Date; + +public class BackstageUserDto { + private Long userId; + private String nickName; + private String realName; + private String userType; + private String phone; + private String password; + private String status; + private Date createTime; + + public Long getUserId() { + return userId; + } + public void setUserId(Long userId) { + this.userId = userId; + } + public String getNickName() { + return nickName; + } + public void setNickName(String nickName) { + this.nickName = nickName; + } + public String getRealName() { + return realName; + } + public void setRealName(String realName) { + this.realName = realName; + } + public String getUserType() { + return userType; + } + public void setUserType(String userType) { + this.userType = userType; + } + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public String getStatus() { + return status; + } + public void setStatus(String status) { + this.status = status; + } + public Date getCreateTime() { + return createTime; + } + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 2d54997f..e0847dda 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -1,6 +1,8 @@ package com.ruoyi.system.mapper; import java.util.List; + +import com.ruoyi.system.domain.dto.BackstageUserDto; import org.apache.ibatis.annotations.Param; import com.ruoyi.common.core.domain.entity.SysUser; @@ -43,6 +45,9 @@ public interface SysUserMapper */ public SysUser selectUserByUserName(String userName); + //查询系统后台用户 + public List selectBackstageUserList(); + /** * 通过用户ID查询用户 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 022e5471..664d1d92 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -2,6 +2,7 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.domain.dto.BackstageUserDto; /** * 用户 业务层 @@ -34,6 +35,8 @@ public interface ISysUserService */ public List selectUnallocatedList(SysUser user); + public List selectBackstageUserList(); + /** * 通过用户名查询用户 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index d8f5d3ff..54470da5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import javax.validation.Validator; + +import com.ruoyi.system.domain.dto.BackstageUserDto; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -100,6 +102,13 @@ public class SysUserServiceImpl implements ISysUserService return userMapper.selectUnallocatedList(user); } + // 查询后台系统用户 + @Override + public List selectBackstageUserList(){ + return userMapper.selectBackstageUserList(); + } + + /** * 通过用户名查询用户 * diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 5851249f..59fd02af 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -46,6 +46,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + select u.user_id, u.dept_id, u.user_name ,u.nick_name,u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, @@ -154,6 +164,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + insert into sys_user( @@ -230,10 +246,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update sys_user set password = #{password} where user_name = #{userName} + + delete from sys_user where user_id = #{userId} + - - update sys_user set del_flag = '2' where user_id = #{userId} - + + + update sys_user set del_flag = '2' where user_id in