13 changed files with 260 additions and 1055 deletions
@ -1,104 +0,0 @@ |
|||
package com.ruoyi.web.controller; |
|||
|
|||
import java.util.List; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import com.ruoyi.common.annotation.Log; |
|||
import com.ruoyi.common.core.controller.BaseController; |
|||
import com.ruoyi.common.core.domain.AjaxResult; |
|||
import com.ruoyi.common.enums.BusinessType; |
|||
import com.ruoyi.system.domain.Users; |
|||
import com.ruoyi.system.service.IUsersService; |
|||
import com.ruoyi.common.utils.poi.ExcelUtil; |
|||
import com.ruoyi.common.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 系统用户Controller |
|||
* |
|||
* @author ruoyi |
|||
* @date 2026-01-14 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/system/users") |
|||
public class UsersController extends BaseController |
|||
{ |
|||
@Autowired |
|||
private IUsersService usersService; |
|||
|
|||
/** |
|||
* 查询系统用户列表 |
|||
*/ |
|||
@PreAuthorize("@ss.hasPermi('system:users:list')") |
|||
@GetMapping("/list") |
|||
public TableDataInfo list(Users users) |
|||
{ |
|||
startPage(); |
|||
List<Users> list = usersService.selectUsersList(users); |
|||
return getDataTable(list); |
|||
} |
|||
|
|||
/** |
|||
* 导出系统用户列表 |
|||
*/ |
|||
@PreAuthorize("@ss.hasPermi('system:users:export')") |
|||
@Log(title = "系统用户", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
public void export(HttpServletResponse response, Users users) |
|||
{ |
|||
List<Users> list = usersService.selectUsersList(users); |
|||
ExcelUtil<Users> util = new ExcelUtil<Users>(Users.class); |
|||
util.exportExcel(response, list, "系统用户数据"); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统用户详细信息 |
|||
*/ |
|||
@PreAuthorize("@ss.hasPermi('system:users:query')") |
|||
@GetMapping(value = "/{id}") |
|||
public AjaxResult getInfo(@PathVariable("id") Long id) |
|||
{ |
|||
return success(usersService.selectUsersById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增系统用户 |
|||
*/ |
|||
@PreAuthorize("@ss.hasPermi('system:users:add')") |
|||
@Log(title = "系统用户", businessType = BusinessType.INSERT) |
|||
@PostMapping |
|||
public AjaxResult add(@RequestBody Users users) |
|||
{ |
|||
return toAjax(usersService.insertUsers(users)); |
|||
} |
|||
|
|||
/** |
|||
* 修改系统用户 |
|||
*/ |
|||
@PreAuthorize("@ss.hasPermi('system:users:edit')") |
|||
@Log(title = "系统用户", businessType = BusinessType.UPDATE) |
|||
@PutMapping |
|||
public AjaxResult edit(@RequestBody Users users) |
|||
{ |
|||
return toAjax(usersService.updateUsers(users)); |
|||
} |
|||
|
|||
/** |
|||
* 删除系统用户 |
|||
*/ |
|||
@PreAuthorize("@ss.hasPermi('system:users:remove')") |
|||
@Log(title = "系统用户", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public AjaxResult remove(@PathVariable Long[] ids) |
|||
{ |
|||
return toAjax(usersService.deleteUsersByIds(ids)); |
|||
} |
|||
} |
|||
@ -1,82 +0,0 @@ |
|||
package com.ruoyi.system.domain; |
|||
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder; |
|||
import org.apache.commons.lang3.builder.ToStringStyle; |
|||
import com.ruoyi.common.annotation.Excel; |
|||
import com.ruoyi.common.core.domain.BaseEntity; |
|||
|
|||
/** |
|||
* 系统用户对象 users |
|||
* |
|||
* @author ruoyi |
|||
* @date 2026-01-14 |
|||
*/ |
|||
public class Users extends BaseEntity |
|||
{ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** 主键ID */ |
|||
private Long id; |
|||
|
|||
/** 登录账号 */ |
|||
@Excel(name = "登录账号") |
|||
private String username; |
|||
|
|||
/** 密码 (建议存哈希值) */ |
|||
@Excel(name = "密码 (建议存哈希值)") |
|||
private String password; |
|||
|
|||
/** 权限等级: 1=管理员(L1), 2=房主(L2), 3=操作员(L3) */ |
|||
@Excel(name = "权限等级: 1=管理员(L1), 2=房主(L2), 3=操作员(L3)") |
|||
private Long role; |
|||
|
|||
public void setId(Long id) |
|||
{ |
|||
this.id = id; |
|||
} |
|||
|
|||
public Long getId() |
|||
{ |
|||
return id; |
|||
} |
|||
|
|||
public void setUsername(String username) |
|||
{ |
|||
this.username = username; |
|||
} |
|||
|
|||
public String getUsername() |
|||
{ |
|||
return username; |
|||
} |
|||
|
|||
public void setPassword(String password) |
|||
{ |
|||
this.password = password; |
|||
} |
|||
|
|||
public String getPassword() |
|||
{ |
|||
return password; |
|||
} |
|||
|
|||
public void setRole(Long role) |
|||
{ |
|||
this.role = role; |
|||
} |
|||
|
|||
public Long getRole() |
|||
{ |
|||
return role; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
|||
.append("id", getId()) |
|||
.append("username", getUsername()) |
|||
.append("password", getPassword()) |
|||
.append("role", getRole()) |
|||
.toString(); |
|||
} |
|||
} |
|||
@ -1,65 +0,0 @@ |
|||
package com.ruoyi.system.mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
import com.ruoyi.common.core.domain.entity.SysUser; |
|||
import com.ruoyi.system.domain.Users; |
|||
|
|||
/** |
|||
* 系统用户Mapper接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2026-01-14 |
|||
*/ |
|||
public interface UsersMapper |
|||
{ |
|||
/** |
|||
* 查询系统用户 |
|||
* |
|||
* @param id 系统用户主键 |
|||
* @return 系统用户 |
|||
*/ |
|||
public Users selectUsersById(Long id); |
|||
|
|||
/** |
|||
* 查询系统用户列表 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 系统用户集合 |
|||
*/ |
|||
public List<Users> selectUsersList(Users users); |
|||
|
|||
/** |
|||
* 新增系统用户 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertUsers(Users users); |
|||
|
|||
/** |
|||
* 修改系统用户 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateUsers(Users users); |
|||
|
|||
/** |
|||
* 删除系统用户 |
|||
* |
|||
* @param id 系统用户主键 |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteUsersById(Long id); |
|||
|
|||
/** |
|||
* 批量删除系统用户 |
|||
* |
|||
* @param ids 需要删除的数据主键集合 |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteUsersByIds(Long[] ids); |
|||
|
|||
SysUser selectUserByUserName(String userName); |
|||
} |
|||
@ -1,61 +0,0 @@ |
|||
package com.ruoyi.system.service; |
|||
|
|||
import java.util.List; |
|||
import com.ruoyi.system.domain.Users; |
|||
|
|||
/** |
|||
* 系统用户Service接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2026-01-14 |
|||
*/ |
|||
public interface IUsersService |
|||
{ |
|||
/** |
|||
* 查询系统用户 |
|||
* |
|||
* @param id 系统用户主键 |
|||
* @return 系统用户 |
|||
*/ |
|||
public Users selectUsersById(Long id); |
|||
|
|||
/** |
|||
* 查询系统用户列表 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 系统用户集合 |
|||
*/ |
|||
public List<Users> selectUsersList(Users users); |
|||
|
|||
/** |
|||
* 新增系统用户 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertUsers(Users users); |
|||
|
|||
/** |
|||
* 修改系统用户 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateUsers(Users users); |
|||
|
|||
/** |
|||
* 批量删除系统用户 |
|||
* |
|||
* @param ids 需要删除的系统用户主键集合 |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteUsersByIds(Long[] ids); |
|||
|
|||
/** |
|||
* 删除系统用户信息 |
|||
* |
|||
* @param id 系统用户主键 |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteUsersById(Long id); |
|||
} |
|||
@ -1,93 +0,0 @@ |
|||
package com.ruoyi.system.service.impl; |
|||
|
|||
import java.util.List; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import com.ruoyi.system.mapper.UsersMapper; |
|||
import com.ruoyi.system.domain.Users; |
|||
import com.ruoyi.system.service.IUsersService; |
|||
|
|||
/** |
|||
* 系统用户Service业务层处理 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2026-01-14 |
|||
*/ |
|||
@Service |
|||
public class UsersServiceImpl implements IUsersService |
|||
{ |
|||
@Autowired |
|||
private UsersMapper usersMapper; |
|||
|
|||
/** |
|||
* 查询系统用户 |
|||
* |
|||
* @param id 系统用户主键 |
|||
* @return 系统用户 |
|||
*/ |
|||
@Override |
|||
public Users selectUsersById(Long id) |
|||
{ |
|||
return usersMapper.selectUsersById(id); |
|||
} |
|||
|
|||
/** |
|||
* 查询系统用户列表 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 系统用户 |
|||
*/ |
|||
@Override |
|||
public List<Users> selectUsersList(Users users) |
|||
{ |
|||
return usersMapper.selectUsersList(users); |
|||
} |
|||
|
|||
/** |
|||
* 新增系统用户 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int insertUsers(Users users) |
|||
{ |
|||
return usersMapper.insertUsers(users); |
|||
} |
|||
|
|||
/** |
|||
* 修改系统用户 |
|||
* |
|||
* @param users 系统用户 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int updateUsers(Users users) |
|||
{ |
|||
return usersMapper.updateUsers(users); |
|||
} |
|||
|
|||
/** |
|||
* 批量删除系统用户 |
|||
* |
|||
* @param ids 需要删除的系统用户主键 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int deleteUsersByIds(Long[] ids) |
|||
{ |
|||
return usersMapper.deleteUsersByIds(ids); |
|||
} |
|||
|
|||
/** |
|||
* 删除系统用户信息 |
|||
* |
|||
* @param id 系统用户主键 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int deleteUsersById(Long id) |
|||
{ |
|||
return usersMapper.deleteUsersById(id); |
|||
} |
|||
} |
|||
@ -1,72 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ruoyi.system.mapper.UsersMapper"> |
|||
|
|||
<resultMap type="Users" id="UsersResult"> |
|||
<result property="id" column="id" /> |
|||
<result property="username" column="username" /> |
|||
<result property="password" column="password" /> |
|||
<result property="role" column="role" /> |
|||
</resultMap> |
|||
|
|||
<sql id="selectUsersVo"> |
|||
select id, username, password, role from users |
|||
</sql> |
|||
|
|||
<select id="selectUsersList" parameterType="Users" resultMap="UsersResult"> |
|||
<include refid="selectUsersVo"/> |
|||
<where> |
|||
<if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if> |
|||
<if test="password != null and password != ''"> and password = #{password}</if> |
|||
<if test="role != null "> and role = #{role}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectUsersById" parameterType="Long" resultMap="UsersResult"> |
|||
<include refid="selectUsersVo"/> |
|||
where id = #{id} |
|||
</select> |
|||
|
|||
<select id="selectUserByUserName" parameterType="String" resultMap="com.ruoyi.system.mapper.UsersMapper.UsersResult"> |
|||
select id, username, password, role |
|||
from users |
|||
where username = #{userName} |
|||
</select> |
|||
|
|||
<insert id="insertUsers" parameterType="Users" useGeneratedKeys="true" keyProperty="id"> |
|||
insert into users |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="username != null and username != ''">username,</if> |
|||
<if test="password != null and password != ''">password,</if> |
|||
<if test="role != null">role,</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="username != null and username != ''">#{username},</if> |
|||
<if test="password != null and password != ''">#{password},</if> |
|||
<if test="role != null">#{role},</if> |
|||
</trim> |
|||
</insert> |
|||
|
|||
<update id="updateUsers" parameterType="Users"> |
|||
update users |
|||
<trim prefix="SET" suffixOverrides=","> |
|||
<if test="username != null and username != ''">username = #{username},</if> |
|||
<if test="password != null and password != ''">password = #{password},</if> |
|||
<if test="role != null">role = #{role},</if> |
|||
</trim> |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
<delete id="deleteUsersById" parameterType="Long"> |
|||
delete from users where id = #{id} |
|||
</delete> |
|||
|
|||
<delete id="deleteUsersByIds" parameterType="String"> |
|||
delete from users where id in |
|||
<foreach item="id" collection="array" open="(" separator="," close=")"> |
|||
#{id} |
|||
</foreach> |
|||
</delete> |
|||
</mapper> |
|||
File diff suppressed because it is too large
Loading…
Reference in new issue