数据相关功能备份
parent
bdc5773f44
commit
5001f9a8dc
@ -0,0 +1,107 @@
|
||||
package com.glxp.api.admin.controller.auth;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.admin.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.admin.annotation.Log;
|
||||
import com.glxp.api.admin.constant.BusinessType;
|
||||
import com.glxp.api.admin.controller.BaseController;
|
||||
import com.glxp.api.admin.entity.auth.SysHisStatusEntity;
|
||||
import com.glxp.api.admin.req.auth.FilterSysHisStatusRequest;
|
||||
import com.glxp.api.admin.req.inout.DeleteRequest;
|
||||
import com.glxp.api.admin.res.PageSimpleResponse;
|
||||
import com.glxp.api.admin.service.auth.ISysHisStatusService;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class SysHisStatusController extends BaseController {
|
||||
|
||||
@Resource
|
||||
ISysHisStatusService sysHisStatusService;
|
||||
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/sys/his/stauts/filter")
|
||||
public BaseResponse filterList(FilterSysHisStatusRequest filterSysHisStatusRequest) {
|
||||
List<SysHisStatusEntity> selectList = sysHisStatusService.selectList(filterSysHisStatusRequest);
|
||||
PageInfo<SysHisStatusEntity> pageInfo = new PageInfo<>(selectList);
|
||||
PageSimpleResponse<SysHisStatusEntity> deptEntityPageSimpleResponse = new PageSimpleResponse<>();
|
||||
deptEntityPageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||
deptEntityPageSimpleResponse.setList(selectList);
|
||||
return ResultVOUtils.success(deptEntityPageSimpleResponse);
|
||||
}
|
||||
|
||||
//获取数据权限列表树形列表
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/sys/his/stauts/tree")
|
||||
public BaseResponse treeList(FilterSysHisStatusRequest filterSysHisStatusRequest) {
|
||||
List<SysHisStatusEntity> selectList = sysHisStatusService.selectList(filterSysHisStatusRequest);
|
||||
return ResultVOUtils.success(sysHisStatusService.buildStatusTreeSelect(selectList));
|
||||
}
|
||||
|
||||
//获取数据权限包含已经选中树形列表
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/sys/his/stauts/treeSelect")
|
||||
public BaseResponse treeSelectedList(FilterSysHisStatusRequest filterSysHisStatusRequest) {
|
||||
List<SysHisStatusEntity> menus = sysHisStatusService.selectList(filterSysHisStatusRequest);
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("checkedKeys", sysHisStatusService.selectListByDeptId(filterSysHisStatusRequest.getDeptId()));
|
||||
ajax.put("menus", sysHisStatusService.buildStatusTreeSelect(menus));
|
||||
return ResultVOUtils.success(ajax);
|
||||
}
|
||||
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@Log(title = "数据状态", businessType = BusinessType.INSERT)
|
||||
@PostMapping("sys/his/stauts/add")
|
||||
public BaseResponse addStatus(@RequestBody SysHisStatusEntity sysHisStatusEntity) {
|
||||
sysHisStatusEntity.setUpdateTime(new Date());
|
||||
boolean b = sysHisStatusService.insert(sysHisStatusEntity);
|
||||
if (b)
|
||||
return ResultVOUtils.success("添加成功");
|
||||
else {
|
||||
return ResultVOUtils.error(500, "添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Log(title = "数据状态", businessType = BusinessType.UPDATE)
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("sys/his/stauts/update")
|
||||
public BaseResponse updateStatus(@RequestBody SysHisStatusEntity sysHisStatusEntity) {
|
||||
sysHisStatusEntity.setUpdateTime(new Date());
|
||||
boolean b = sysHisStatusService.update(sysHisStatusEntity);
|
||||
if (b)
|
||||
return ResultVOUtils.success("更新成功!");
|
||||
else {
|
||||
return ResultVOUtils.error(500, "更新失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "数据状态", businessType = BusinessType.DELETE)
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("sys/his/stauts/delete")
|
||||
public BaseResponse deleteStatus(@RequestBody DeleteRequest deleteRequest) {
|
||||
// if (deptService.filterSubDepts(Integer.parseInt(deleteRequest.getId())).size() > 0) {
|
||||
// return ResultVOUtils.error(500, "删除失败,存在子级部门,请先移除!");
|
||||
// }
|
||||
boolean b = sysHisStatusService.deleteById(Integer.parseInt(deleteRequest.getId()));
|
||||
if (b)
|
||||
return ResultVOUtils.success("删除成功");
|
||||
else {
|
||||
return ResultVOUtils.error(500, "删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.glxp.api.admin.dao.auth;
|
||||
|
||||
import com.glxp.api.admin.entity.auth.DeptHisStatusEntity;
|
||||
import com.glxp.api.admin.req.auth.SysRoleMenuRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeptHisStatusDao {
|
||||
|
||||
|
||||
List<DeptHisStatusEntity> selectDeptHisStatus(SysRoleMenuRequest sysRoleMenu);
|
||||
|
||||
int deleteById(Integer id);
|
||||
|
||||
|
||||
int deleteByList(@Param("ids") List<Integer> ids);
|
||||
|
||||
int insertBatch(List<DeptHisStatusEntity> list);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.glxp.api.admin.dao.auth;
|
||||
|
||||
import com.glxp.api.admin.entity.auth.SysHisStatusEntity;
|
||||
import com.glxp.api.admin.req.auth.FilterSysHisStatusRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysHisStatusDao {
|
||||
|
||||
List<SysHisStatusEntity> selectList(FilterSysHisStatusRequest filterSysHisStatusRequest);
|
||||
|
||||
boolean insert(SysHisStatusEntity sysHisStatusEntity);
|
||||
|
||||
boolean deleteById(Integer id);
|
||||
|
||||
boolean update(SysHisStatusEntity sysHisStatusEntity);
|
||||
|
||||
List<Integer> selectListByDeptId(@Param("deptId") Integer deptId);
|
||||
}
|
@ -1,16 +1,22 @@
|
||||
package com.glxp.api.admin.entity.auth;
|
||||
|
||||
import com.glxp.api.admin.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DeptEntity {
|
||||
public class DeptEntity extends BaseEntity {
|
||||
private String code;
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String parentId;
|
||||
private Integer parentId;
|
||||
private String remark;
|
||||
private Integer flag;
|
||||
private Date updateTime;
|
||||
private List<T> children = new ArrayList<>();
|
||||
List<Integer> statusIds;
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.glxp.api.admin.entity.auth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeptHisStatusEntity {
|
||||
|
||||
private Integer deptId;
|
||||
private Integer statusId;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.glxp.api.admin.entity.auth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysHisStatusEntity {
|
||||
|
||||
private Integer id;
|
||||
private String type;
|
||||
private String typeName;
|
||||
private Integer parentId;
|
||||
private Integer status;
|
||||
private String remark;
|
||||
private Date updateTime;
|
||||
private String parentName;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.glxp.api.admin.req.auth;
|
||||
|
||||
import com.glxp.api.admin.req.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeptHisStatusRequest extends ListPageRequest {
|
||||
|
||||
private Integer deptId;
|
||||
private Integer statusId;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.glxp.api.admin.req.auth;
|
||||
|
||||
import com.glxp.api.admin.req.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FilterSysHisStatusRequest extends ListPageRequest {
|
||||
|
||||
private Integer id;
|
||||
private String type;
|
||||
private String typeName;
|
||||
private Integer parentId;
|
||||
private Integer status;
|
||||
|
||||
|
||||
private Integer deptId;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.glxp.api.admin.service.auth;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.glxp.api.admin.entity.auth.SysHisStatusEntity;
|
||||
import com.glxp.api.admin.req.auth.FilterSysHisStatusRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysHisStatusService {
|
||||
|
||||
|
||||
List<SysHisStatusEntity> selectList(FilterSysHisStatusRequest filterSysHisStatusRequest);
|
||||
|
||||
boolean insert(SysHisStatusEntity sysHisStatusEntity);
|
||||
|
||||
boolean deleteById(Integer id);
|
||||
|
||||
boolean update(SysHisStatusEntity sysHisStatusEntity);
|
||||
|
||||
List<Integer> selectListByDeptId(Integer deptId);
|
||||
|
||||
List<Tree<Integer>> buildStatusTreeSelect(List<SysHisStatusEntity> sysHisStatusEntities);
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.glxp.api.admin.service.auth.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.admin.dao.auth.SysHisStatusDao;
|
||||
import com.glxp.api.admin.entity.auth.SysHisStatusEntity;
|
||||
import com.glxp.api.admin.req.auth.FilterSysHisStatusRequest;
|
||||
import com.glxp.api.admin.service.auth.ISysHisStatusService;
|
||||
import com.glxp.api.admin.util.TreeBuildUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ISysHisStatusServiceImpl implements ISysHisStatusService {
|
||||
|
||||
@Resource
|
||||
SysHisStatusDao sysHisStatusDao;
|
||||
|
||||
@Override
|
||||
public List<SysHisStatusEntity> selectList(FilterSysHisStatusRequest filterSysHisStatusRequest) {
|
||||
|
||||
if (filterSysHisStatusRequest.getPage() != null) {
|
||||
int offset = (filterSysHisStatusRequest.getPage() - 1) * filterSysHisStatusRequest.getLimit();
|
||||
PageHelper.offsetPage(offset, filterSysHisStatusRequest.getLimit());
|
||||
}
|
||||
return sysHisStatusDao.selectList(filterSysHisStatusRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insert(SysHisStatusEntity sysHisStatusEntity) {
|
||||
return sysHisStatusDao.insert(sysHisStatusEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteById(Integer id) {
|
||||
return sysHisStatusDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(SysHisStatusEntity sysHisStatusEntity) {
|
||||
return sysHisStatusDao.update(sysHisStatusEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> selectListByDeptId(Integer roleId) {
|
||||
return sysHisStatusDao.selectListByDeptId(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tree<Integer>> buildStatusTreeSelect(List<SysHisStatusEntity> sysHisStatusEntities) {
|
||||
if (CollUtil.isEmpty(sysHisStatusEntities)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
return TreeBuildUtils.build(sysHisStatusEntities, (menu, tree) ->
|
||||
tree.setId(menu.getId())
|
||||
.setParentId(menu.getParentId())
|
||||
.setName(menu.getTypeName())
|
||||
.setWeight(menu.getId()));
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?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.glxp.api.admin.dao.auth.DeptHisStatusDao">
|
||||
|
||||
|
||||
<select id="selectDeptHisStatus" parameterType="com.glxp.api.admin.req.auth.SysRoleMenuRequest"
|
||||
resultType="com.glxp.api.admin.entity.auth.DeptHisStatusEntity">>
|
||||
SELECT *
|
||||
FROM auth_dept_status
|
||||
<where>
|
||||
<if test="deptId != null ">
|
||||
and deptId = #{deptId}
|
||||
</if>
|
||||
<if test="statusId != null ">
|
||||
and statusId = #{statusId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Integer">
|
||||
delete
|
||||
from auth_dept_status
|
||||
where deptId = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByList" parameterType="java.util.List"
|
||||
>
|
||||
delete
|
||||
from auth_dept_status
|
||||
where deptId in
|
||||
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
||||
</delete>
|
||||
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" parameterType="java.util.List">
|
||||
insert INTO auth_dept_status
|
||||
(
|
||||
deptId,statusId
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index"
|
||||
separator=",">
|
||||
(
|
||||
#{item.deptId},
|
||||
#{item.statusId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,68 @@
|
||||
<?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.glxp.api.admin.dao.auth.SysHisStatusDao">
|
||||
|
||||
<select id="selectList" parameterType="com.glxp.api.admin.req.auth.FilterSysHisStatusRequest"
|
||||
resultType="com.glxp.api.admin.entity.auth.SysHisStatusEntity">
|
||||
select A.*,B.typeName parentName from sys_his_status A left JOIN sys_his_status B on A.parentId = B.id
|
||||
<where>
|
||||
<if test="id != null ">
|
||||
and A.id = #{id}
|
||||
</if>
|
||||
<if test=" parentId != null">
|
||||
and A.parentId = #{parentId}
|
||||
</if>
|
||||
<if test="typeName != null and '' != typeName">
|
||||
AND A.`typeName` LIKE CONCAT('%',#{typeName},'%')
|
||||
</if>
|
||||
<if test="type != null and '' != type">
|
||||
AND A.`type` LIKE CONCAT('%',#{type},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insert" keyProperty="id" parameterType="com.glxp.api.admin.entity.auth.DeptEntity">
|
||||
INSERT INTO sys_his_status(`type`, `typeName`, `parentId`, status, remark, updateTime)
|
||||
values (#{type},
|
||||
#{typeName},
|
||||
#{parentId}, #{status}, #{remark}, #{updateTime})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.glxp.api.admin.entity.auth.DeptEntity">
|
||||
UPDATE sys_his_status
|
||||
<trim prefix="set" suffixOverrides=",">
|
||||
<if test="type != null">`type`=#{type},</if>
|
||||
<if test="typeName != null">`typeName`=#{typeName},</if>
|
||||
<if test="parentId != null">parentId=#{parentId},</if>
|
||||
<if test="status != null">status=#{status},</if>
|
||||
<if test="updateTime != null">updateTime=#{updateTime},</if>
|
||||
<if test="remark != null">remark=#{remark},</if>
|
||||
</trim>
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Integer">
|
||||
delete
|
||||
from sys_his_status
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="selectListByDeptId" resultType="java.lang.Integer">
|
||||
select id
|
||||
from sys_his_status
|
||||
left join auth_dept_status on sys_his_status.id = auth_dept_status.statusId
|
||||
where auth_dept_status.deptId = #{deptId}
|
||||
and sys_his_status.id not in
|
||||
(select parentId
|
||||
from sys_his_status
|
||||
INNER JOIN auth_dept_status
|
||||
on sys_his_status.id = auth_dept_status.statusId
|
||||
and auth_dept_status.deptId = #{deptId})
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue