文件管理
This commit is contained in:
@ -3,6 +3,8 @@ package com.ruoyi.project.benyi.controller;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.project.common.SchoolCommon;
|
||||
import com.ruoyi.project.system.domain.SysRole;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -33,14 +35,37 @@ import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
public class ByFilesController extends BaseController {
|
||||
@Autowired
|
||||
private IByFilesService byFilesService;
|
||||
@Autowired
|
||||
private SchoolCommon schoolCommon;
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('benyi:files:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ByFiles byFiles) {
|
||||
startPage();
|
||||
List<ByFiles> list = byFilesService.selectByFilesList(byFiles);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('benyi:files:list')")
|
||||
@Log(title = "查询文件", businessType = BusinessType.QUERY)
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ByFiles byFiles) {
|
||||
@GetMapping("/listbyrole")
|
||||
public TableDataInfo listbyrole(ByFiles byFiles) {
|
||||
|
||||
String strRoles = "";
|
||||
List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
|
||||
System.out.println(roles.size());
|
||||
if (roles != null && roles.size() > 0) {
|
||||
for (int i = 0; i < roles.size(); i++) {
|
||||
strRoles = strRoles + roles.get(i).getRoleId() + ";";
|
||||
}
|
||||
}
|
||||
byFiles.setRoles(strRoles);
|
||||
startPage();
|
||||
List<ByFiles> list = byFilesService.selectByFilesList(byFiles);
|
||||
return getDataTable(list);
|
||||
@ -64,7 +89,15 @@ public class ByFilesController extends BaseController {
|
||||
@PreAuthorize("@ss.hasPermi('benyi:files:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(byFilesService.selectByFilesById(id));
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ByFiles byFiles = byFilesService.selectByFilesById(id);
|
||||
ajax.put(AjaxResult.DATA_TAG, byFiles);
|
||||
if (!schoolCommon.isStringEmpty(byFiles.getRoles())) {
|
||||
ajax.put("roles", byFiles.getRoles().split(";"));
|
||||
} else {
|
||||
ajax.put("roles", null);
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,6 +49,22 @@ public class ByFiles extends BaseEntity {
|
||||
@Excel(name = "创建人")
|
||||
private Long createuserid;
|
||||
|
||||
/**
|
||||
* 适用角色
|
||||
*/
|
||||
@Excel(name = "适用角色")
|
||||
private String roles;
|
||||
|
||||
public String[] getRoleArr() {
|
||||
return roleArr;
|
||||
}
|
||||
|
||||
public void setRoleArr(String[] roleArr) {
|
||||
this.roleArr = roleArr;
|
||||
}
|
||||
|
||||
private String[] roleArr;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@ -97,6 +113,14 @@ public class ByFiles extends BaseEntity {
|
||||
return createuserid;
|
||||
}
|
||||
|
||||
public void setRoles(String roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public String getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
@ -107,6 +131,8 @@ public class ByFiles extends BaseEntity {
|
||||
.append("fileurl", getFileurl())
|
||||
.append("createuserid", getCreateuserid())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("roles", getRoles())
|
||||
.append("roleArr", getRoleArr())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,13 @@ public class ByFilesServiceImpl implements IByFilesService {
|
||||
*/
|
||||
@Override
|
||||
public List<ByFiles> selectByFilesList(ByFiles byFiles) {
|
||||
if (byFiles.getRoles() == null || "".equals(byFiles.getRoles())) {
|
||||
|
||||
} else {
|
||||
String strArr = byFiles.getRoles();
|
||||
byFiles.setRoleArr(strArr.split(";"));
|
||||
}
|
||||
|
||||
return byFilesMapper.selectByFilesList(byFiles);
|
||||
}
|
||||
|
||||
|
@ -12,20 +12,29 @@
|
||||
<result property="fileurl" column="fileurl"/>
|
||||
<result property="createuserid" column="createuserid"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="roles" column="roles"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectByFilesVo">
|
||||
select id, name, filetype, type, fileurl, createuserid, create_time from by_files
|
||||
select id, name, filetype, type, fileurl, createuserid, create_time, roles from by_files
|
||||
</sql>
|
||||
|
||||
<select id="selectByFilesList" parameterType="ByFiles" resultMap="ByFilesResult">
|
||||
<include refid="selectByFilesVo"/>
|
||||
<where>
|
||||
and 1=1
|
||||
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
|
||||
<if test="filetype != null and filetype != ''">and filetype = #{filetype}</if>
|
||||
<if test="type != null and type != ''">and type = #{type}</if>
|
||||
<if test="fileurl != null and fileurl != ''">and fileurl = #{fileurl}</if>
|
||||
<if test="createuserid != null ">and createuserid = #{createuserid}</if>
|
||||
<if test="roles != null and roles != ''">
|
||||
and (
|
||||
<foreach collection="roleArr" item="item" index="index" separator=" or ">
|
||||
roles like concat('%', #{item}, '%')
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by type
|
||||
</select>
|
||||
@ -44,6 +53,7 @@
|
||||
<if test="fileurl != null and fileurl != ''">fileurl,</if>
|
||||
<if test="createuserid != null ">createuserid,</if>
|
||||
<if test="createTime != null ">create_time,</if>
|
||||
<if test="roles != null and roles != ''">roles,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
@ -52,6 +62,7 @@
|
||||
<if test="fileurl != null and fileurl != ''">#{fileurl},</if>
|
||||
<if test="createuserid != null ">#{createuserid},</if>
|
||||
<if test="createTime != null ">#{createTime},</if>
|
||||
<if test="roles != null and roles != ''">#{roles},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -64,6 +75,7 @@
|
||||
<if test="fileurl != null and fileurl != ''">fileurl = #{fileurl},</if>
|
||||
<if test="createuserid != null ">createuserid = #{createuserid},</if>
|
||||
<if test="createTime != null ">create_time = #{createTime},</if>
|
||||
<if test="roles != null and roles != ''">roles = #{roles},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
Reference in New Issue
Block a user