This commit is contained in:
hezi66677 2024-12-07 18:21:55 +08:00
parent 4903e81234
commit 10139db303
9 changed files with 514 additions and 0 deletions

View File

@ -2,6 +2,8 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.annotation.Anonymous;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;

View File

@ -3,6 +3,8 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.annotation.Anonymous;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -56,6 +58,7 @@ public class SysUserController extends BaseController
/**
* 获取用户列表
*/
/*@Anonymous*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list")
public TableDataInfo list(SysUser user)
@ -65,6 +68,7 @@ public class SysUserController extends BaseController
return getDataTable(list);
}
/*@Anonymous*/
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export")
@ -75,6 +79,7 @@ public class SysUserController extends BaseController
util.exportExcel(response, list, "用户数据");
}
/* @Anonymous*/
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:user:import')")
@PostMapping("/importData")
@ -97,6 +102,8 @@ public class SysUserController extends BaseController
/**
* 根据用户编号获取详细信息
*/
/* @Anonymous*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
@ -119,6 +126,7 @@ public class SysUserController extends BaseController
/**
* 新增用户
*/
/* @Anonymous*/
@PreAuthorize("@ss.hasPermi('system:user:add')")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping

View File

@ -3,6 +3,8 @@ package com.ruoyi.common.utils;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

View File

@ -0,0 +1,104 @@
package com.ruoyi.system.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.Mycache;
import com.ruoyi.system.service.IMycacheService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 内存管理Controller
*
* @author 徐天乐
* @date 2024-12-06
*/
@RestController
@RequestMapping("/system/mycache")
public class MycacheController extends BaseController
{
@Autowired
private IMycacheService mycacheService;
/**
* 查询内存管理列表
*/
@PreAuthorize("@ss.hasPermi('system:mycache:list')")
@GetMapping("/list")
public TableDataInfo list(Mycache mycache)
{
startPage();
List<Mycache> list = mycacheService.selectMycacheList(mycache);
return getDataTable(list);
}
/**
* 导出内存管理列表
*/
@PreAuthorize("@ss.hasPermi('system:mycache:export')")
@Log(title = "内存管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Mycache mycache)
{
List<Mycache> list = mycacheService.selectMycacheList(mycache);
ExcelUtil<Mycache> util = new ExcelUtil<Mycache>(Mycache.class);
util.exportExcel(response, list, "内存管理数据");
}
/**
* 获取内存管理详细信息
*/
@PreAuthorize("@ss.hasPermi('system:mycache:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(mycacheService.selectMycacheById(id));
}
/**
* 新增内存管理
*/
@PreAuthorize("@ss.hasPermi('system:mycache:add')")
@Log(title = "内存管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Mycache mycache)
{
return toAjax(mycacheService.insertMycache(mycache));
}
/**
* 修改内存管理
*/
@PreAuthorize("@ss.hasPermi('system:mycache:edit')")
@Log(title = "内存管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Mycache mycache)
{
return toAjax(mycacheService.updateMycache(mycache));
}
/**
* 删除内存管理
*/
@PreAuthorize("@ss.hasPermi('system:mycache:remove')")
@Log(title = "内存管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(mycacheService.deleteMycacheByIds(ids));
}
}

View File

@ -0,0 +1,107 @@
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;
/**
* 内存管理对象 mycache
*
* @author 徐天乐
* @date 2024-12-06
*/
public class Mycache extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 总内存 */
@Excel(name = "总内存")
private String allcache;
/** 使用内存 */
@Excel(name = "使用内存")
private String usecache;
/** 本地缓存 */
@Excel(name = "本地缓存")
private String homecache;
/** 剩余内存 */
@Excel(name = "剩余内存")
private String surpluscache;
/** 用户名 */
@Excel(name = "用户名")
private String username;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setAllcache(String allcache)
{
this.allcache = allcache;
}
public String getAllcache()
{
return allcache;
}
public void setUsecache(String usecache)
{
this.usecache = usecache;
}
public String getUsecache()
{
return usecache;
}
public void setHomecache(String homecache)
{
this.homecache = homecache;
}
public String getHomecache()
{
return homecache;
}
public void setSurpluscache(String surpluscache)
{
this.surpluscache = surpluscache;
}
public String getSurpluscache()
{
return surpluscache;
}
public void setUsername(String username)
{
this.username = username;
}
public String getUsername()
{
return username;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("allcache", getAllcache())
.append("usecache", getUsecache())
.append("homecache", getHomecache())
.append("surpluscache", getSurpluscache())
.append("username", getUsername())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.Mycache;
/**
* 内存管理Mapper接口
*
* @author 徐天乐
* @date 2024-12-06
*/
public interface MycacheMapper
{
/**
* 查询内存管理
*
* @param id 内存管理主键
* @return 内存管理
*/
public Mycache selectMycacheById(Long id);
/**
* 查询内存管理列表
*
* @param mycache 内存管理
* @return 内存管理集合
*/
public List<Mycache> selectMycacheList(Mycache mycache);
/**
* 新增内存管理
*
* @param mycache 内存管理
* @return 结果
*/
public int insertMycache(Mycache mycache);
/**
* 修改内存管理
*
* @param mycache 内存管理
* @return 结果
*/
public int updateMycache(Mycache mycache);
/**
* 删除内存管理
*
* @param id 内存管理主键
* @return 结果
*/
public int deleteMycacheById(Long id);
/**
* 批量删除内存管理
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteMycacheByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Mycache;
/**
* 内存管理Service接口
*
* @author 徐天乐
* @date 2024-12-06
*/
public interface IMycacheService
{
/**
* 查询内存管理
*
* @param id 内存管理主键
* @return 内存管理
*/
public Mycache selectMycacheById(Long id);
/**
* 查询内存管理列表
*
* @param mycache 内存管理
* @return 内存管理集合
*/
public List<Mycache> selectMycacheList(Mycache mycache);
/**
* 新增内存管理
*
* @param mycache 内存管理
* @return 结果
*/
public int insertMycache(Mycache mycache);
/**
* 修改内存管理
*
* @param mycache 内存管理
* @return 结果
*/
public int updateMycache(Mycache mycache);
/**
* 批量删除内存管理
*
* @param ids 需要删除的内存管理主键集合
* @return 结果
*/
public int deleteMycacheByIds(Long[] ids);
/**
* 删除内存管理信息
*
* @param id 内存管理主键
* @return 结果
*/
public int deleteMycacheById(Long id);
}

View File

@ -0,0 +1,93 @@
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.MycacheMapper;
import com.ruoyi.system.domain.Mycache;
import com.ruoyi.system.service.IMycacheService;
/**
* 内存管理Service业务层处理
*
* @author 徐天乐
* @date 2024-12-06
*/
@Service
public class MycacheServiceImpl implements IMycacheService
{
@Autowired
private MycacheMapper mycacheMapper;
/**
* 查询内存管理
*
* @param id 内存管理主键
* @return 内存管理
*/
@Override
public Mycache selectMycacheById(Long id)
{
return mycacheMapper.selectMycacheById(id);
}
/**
* 查询内存管理列表
*
* @param mycache 内存管理
* @return 内存管理
*/
@Override
public List<Mycache> selectMycacheList(Mycache mycache)
{
return mycacheMapper.selectMycacheList(mycache);
}
/**
* 新增内存管理
*
* @param mycache 内存管理
* @return 结果
*/
@Override
public int insertMycache(Mycache mycache)
{
return mycacheMapper.insertMycache(mycache);
}
/**
* 修改内存管理
*
* @param mycache 内存管理
* @return 结果
*/
@Override
public int updateMycache(Mycache mycache)
{
return mycacheMapper.updateMycache(mycache);
}
/**
* 批量删除内存管理
*
* @param ids 需要删除的内存管理主键
* @return 结果
*/
@Override
public int deleteMycacheByIds(Long[] ids)
{
return mycacheMapper.deleteMycacheByIds(ids);
}
/**
* 删除内存管理信息
*
* @param id 内存管理主键
* @return 结果
*/
@Override
public int deleteMycacheById(Long id)
{
return mycacheMapper.deleteMycacheById(id);
}
}

View File

@ -0,0 +1,76 @@
<?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.MycacheMapper">
<resultMap type="Mycache" id="MycacheResult">
<result property="id" column="id" />
<result property="allcache" column="allcache" />
<result property="usecache" column="usecache" />
<result property="homecache" column="homecache" />
<result property="surpluscache" column="surpluscache" />
<result property="username" column="username" />
</resultMap>
<sql id="selectMycacheVo">
select id, allcache, usecache, homecache, surpluscache, username from mycache
</sql>
<select id="selectMycacheList" parameterType="Mycache" resultMap="MycacheResult">
<include refid="selectMycacheVo"/>
<where>
<if test="allcache != null and allcache != ''"> and allcache = #{allcache}</if>
<if test="usecache != null and usecache != ''"> and usecache = #{usecache}</if>
<if test="homecache != null and homecache != ''"> and homecache = #{homecache}</if>
<if test="surpluscache != null and surpluscache != ''"> and surpluscache = #{surpluscache}</if>
<if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
</where>
</select>
<select id="selectMycacheById" parameterType="Long" resultMap="MycacheResult">
<include refid="selectMycacheVo"/>
where id = #{id}
</select>
<insert id="insertMycache" parameterType="Mycache" useGeneratedKeys="true" keyProperty="id">
insert into mycache
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="allcache != null">allcache,</if>
<if test="usecache != null">usecache,</if>
<if test="homecache != null">homecache,</if>
<if test="surpluscache != null">surpluscache,</if>
<if test="username != null">username,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="allcache != null">#{allcache},</if>
<if test="usecache != null">#{usecache},</if>
<if test="homecache != null">#{homecache},</if>
<if test="surpluscache != null">#{surpluscache},</if>
<if test="username != null">#{username},</if>
</trim>
</insert>
<update id="updateMycache" parameterType="Mycache">
update mycache
<trim prefix="SET" suffixOverrides=",">
<if test="allcache != null">allcache = #{allcache},</if>
<if test="usecache != null">usecache = #{usecache},</if>
<if test="homecache != null">homecache = #{homecache},</if>
<if test="surpluscache != null">surpluscache = #{surpluscache},</if>
<if test="username != null">username = #{username},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMycacheById" parameterType="Long">
delete from mycache where id = #{id}
</delete>
<delete id="deleteMycacheByIds" parameterType="String">
delete from mycache where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>