完成人员管理 和 日志管理。

This commit is contained in:
haotianmingyue 2024-11-19 15:17:45 +08:00
parent 8ced6112e6
commit b6067330e1
8 changed files with 273 additions and 14 deletions

View File

@ -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<SysSource> 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<BackstageUserDto> 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("无权限访问");
}

View File

@ -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<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list);
if(isAuthority(Constants.USER_TYPE_ADMIN)){
startPage();
List<SysOperLog> 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;
}
}

View File

@ -56,4 +56,9 @@ public enum BusinessType
* 清空数据
*/
CLEAN,
/*
* 获取列表
* */
GET,
}

View File

@ -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;
}
}

View File

@ -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<BackstageUserDto> selectBackstageUserList();
/**
* 通过用户ID查询用户
*

View File

@ -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<SysUser> selectUnallocatedList(SysUser user);
public List<BackstageUserDto> selectBackstageUserList();
/**
* 通过用户名查询用户
*

View File

@ -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<BackstageUserDto> selectBackstageUserList(){
return userMapper.selectBackstageUserList();
}
/**
* 通过用户名查询用户
*

View File

@ -46,6 +46,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="dataScope" column="data_scope" />
<result property="status" column="role_status" />
</resultMap>
<resultMap id="BackstageUserResult" type="com.ruoyi.system.domain.dto.BackstageUserDto">
<id property="userId" column="user_id" />
<result property="nickName" column="nick_name" />
<result property="realName" column="real_name" />
<result property="userType" column="user_type" />
<result property="phone" column="phonenumber" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectUserVo">
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"
<select id="getUserCount" resultType="java.lang.Long">
select count(*) from sys_user
</select>
<select id="selectBackstageUserList" resultMap="BackstageUserResult">
select sys_user.user_id, sys_user.nick_name, user_info.real_name, sys_user.user_type, sys_user.phonenumber, sys_user.status, sys_user.create_time
from sys_user
left join user_info on sys_user.user_id = user_info.user_id
where sys_user.user_type != '0000000000'
</select>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
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}
</update>
<delete id="deleteUserById" parameterType="Long">
delete from sys_user where user_id = #{userId}
</delete>
<delete id="deleteUserById" parameterType="Long">
update sys_user set del_flag = '2' where user_id = #{userId}
</delete>
<!-- <delete id="deleteUserById" parameterType="Long">-->
<!-- update sys_user set del_flag = '2' where user_id = #{userId}-->
<!-- </delete>-->
<delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in