档案目录查询按权限、新增添加校验等

master
hansha 2 years ago
parent 817c6dce4e
commit 30076b98d2

@ -1,11 +1,13 @@
package com.da.common.core.domain; package com.da.common.core.domain;
import com.da.common.core.domain.entity.DaCatalog;
import com.da.common.core.domain.entity.SysDept;
import com.da.common.core.domain.entity.SysMenu;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.da.common.core.domain.entity.SysDept;
import com.da.common.core.domain.entity.SysMenu;
/** /**
* Treeselect * Treeselect
@ -45,6 +47,13 @@ public class TreeSelect implements Serializable
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
} }
public TreeSelect(DaCatalog catalog)
{
this.id = catalog.getId();
this.label = catalog.getMuName();
this.children = catalog.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public Long getId() public Long getId()
{ {
return id; return id;

@ -1,9 +1,12 @@
package com.da.dangan.domain; package com.da.common.core.domain.entity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.da.common.annotation.Excel; import com.da.common.annotation.Excel;
import com.da.common.core.domain.BaseEntity; import com.da.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.ArrayList;
import java.util.List;
/** /**
* da_catalog * da_catalog
@ -41,13 +44,22 @@ public class DaCatalog extends BaseEntity
/** 菜单状态0正常 1停用 */ /** 菜单状态0正常 1停用 */
@Excel(name = "菜单状态", readConverterExp = "0=正常,1=停用") @Excel(name = "菜单状态", readConverterExp = "0=正常,1=停用")
private String status; private String status;
/** 子目录 */
private List<DaCatalog> children = new ArrayList<DaCatalog>();
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
} }
public Long getId() public List<DaCatalog> getChildren() {
return children;
}
public void setChildren(List<DaCatalog> children) {
this.children = children;
}
public Long getId()
{ {
return id; return id;
} }

@ -3,9 +3,9 @@ package com.da.dangan.controller;
import com.da.common.annotation.Log; import com.da.common.annotation.Log;
import com.da.common.core.controller.BaseController; import com.da.common.core.controller.BaseController;
import com.da.common.core.domain.AjaxResult; import com.da.common.core.domain.AjaxResult;
import com.da.common.core.domain.entity.DaCatalog;
import com.da.common.enums.BusinessType; import com.da.common.enums.BusinessType;
import com.da.common.utils.poi.ExcelUtil; import com.da.common.utils.poi.ExcelUtil;
import com.da.dangan.domain.DaCatalog;
import com.da.dangan.service.IDaCatalogService; import com.da.dangan.service.IDaCatalogService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -38,6 +38,29 @@ public class DaCatalogController extends BaseController
return success(catalogs); return success(catalogs);
} }
/**
*
*/
@GetMapping("/treeselect")
public AjaxResult treeselect(DaCatalog daCatalog)
{
List<DaCatalog> daCatalogs = daCatalogService.selectAllDaCatalogList(daCatalog, getUserId());
return success(daCatalogService.buildCatalogTreeSelect(daCatalogs));
}
/**
*
*/
@GetMapping(value = "/userMenuTreeselect/{userId}")
public AjaxResult roleMenuTreeselect(@PathVariable("userId") Long userId)
{
List<DaCatalog> catalogs = daCatalogService.selectCatalogList(getUserId());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", daCatalogService.selectCatalogListByUserId(userId));
ajax.put("catalogs", daCatalogService.buildCatalogTreeSelect(catalogs));
return ajax;
}
/** /**
* *
*/ */

@ -1,6 +1,7 @@
package com.da.dangan.mapper; package com.da.dangan.mapper;
import com.da.dangan.domain.DaCatalog; import com.da.common.core.domain.entity.DaCatalog;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -60,7 +61,9 @@ public interface DaCatalogMapper
*/ */
public int deleteDaCatalogByIds(Long[] ids); public int deleteDaCatalogByIds(Long[] ids);
DaCatalog checkDaCatalogNameUnique(String muName, Long pid); DaCatalog checkDaCatalogNameUnique(@Param("muName") String muName, @Param("pid") Long pid);
List<DaCatalog> selectDaCatalogListByUserId(DaCatalog daCatalog); List<DaCatalog> selectDaCatalogListByUserId(DaCatalog daCatalog);
List<Long> selectCatalogListByUserId(Long userId);
} }

@ -1,6 +1,7 @@
package com.da.dangan.service; package com.da.dangan.service;
import com.da.dangan.domain.DaCatalog; import com.da.common.core.domain.TreeSelect;
import com.da.common.core.domain.entity.DaCatalog;
import java.util.List; import java.util.List;
@ -69,4 +70,25 @@ public interface IDaCatalogService
public int deleteDaCatalogById(Long id); public int deleteDaCatalogById(Long id);
boolean checkDaCatalogNameUnique(DaCatalog daCatalog); boolean checkDaCatalogNameUnique(DaCatalog daCatalog);
List<DaCatalog> selectCatalogList(Long userId);
/**
*
*
* @param daCatalogs
* @return
*/
List<DaCatalog> buildCatalogTree(List<DaCatalog> daCatalogs);
/**
*
*
* @param catalogs
* @return
*/
List<TreeSelect> buildCatalogTreeSelect(List<DaCatalog> catalogs);
List<Long> selectCatalogListByUserId(Long userId);
} }

@ -49,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select distinct c.* select distinct c.*
from da_catalog c from da_catalog c
left join da_user_catalog uc on c.id = uc.mu_id left join da_user_catalog uc on c.id = uc.mu_id
where ur.user_id = #{params.userId} where uc.user_id = #{params.userId}
<if test="muName != null and muName != ''"> <if test="muName != null and muName != ''">
AND c.mu_name like concat('%', #{muName}, '%') AND c.mu_name like concat('%', #{muName}, '%')
</if> </if>
@ -58,6 +58,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
order by c.pid, c.order_num order by c.pid, c.order_num
</select> </select>
<select id="selectCatalogListByUserId" resultType="Long">
select c.id
from da_catalog c
left join da_user_catalog uc on c.id = uc.mu_id
where uc.user_id = #{userId}
order by c.pid, c.order_num
</select>
<insert id="insertDaCatalog" parameterType="DaCatalog" useGeneratedKeys="true" keyProperty="id"> <insert id="insertDaCatalog" parameterType="DaCatalog" useGeneratedKeys="true" keyProperty="id">
insert into da_catalog insert into da_catalog

Loading…
Cancel
Save