部门关联用户
parent
c067a3ed17
commit
7349a95508
@ -0,0 +1,35 @@
|
||||
package com.glxp.api.admin.controller.auth;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.admin.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.admin.req.auth.DeptUserReqeust;
|
||||
import com.glxp.api.admin.res.PageSimpleResponse;
|
||||
import com.glxp.api.admin.res.auth.DeptUserResponse;
|
||||
import com.glxp.api.admin.service.auth.DeptUserService;
|
||||
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.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class DeptUserController {
|
||||
|
||||
|
||||
@Resource
|
||||
DeptUserService deptUserService;
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("udi/auth/dept/user/filter")
|
||||
public BaseResponse filterList(DeptUserReqeust deptUserReqeust) {
|
||||
List<DeptUserResponse> deptEntityList = deptUserService.selectJoinDeptUser(deptUserReqeust);
|
||||
PageInfo<DeptUserResponse> pageInfo = new PageInfo<>(deptEntityList);
|
||||
PageSimpleResponse<DeptUserResponse> deptEntityPageSimpleResponse = new PageSimpleResponse<>();
|
||||
deptEntityPageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||
deptEntityPageSimpleResponse.setList(deptEntityList);
|
||||
return ResultVOUtils.success(deptEntityPageSimpleResponse);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.glxp.api.admin.dao.auth;
|
||||
|
||||
import com.glxp.api.admin.entity.auth.DeptUserEntity;
|
||||
import com.glxp.api.admin.req.auth.DeptUserReqeust;
|
||||
import com.glxp.api.admin.res.auth.DeptUserResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeptUserDao {
|
||||
|
||||
|
||||
List<DeptUserEntity> selectDeptUser(DeptUserReqeust deptUserReqeust);
|
||||
|
||||
List<DeptUserResponse> selectJoinDeptUser(DeptUserReqeust deptUserReqeust);
|
||||
|
||||
int deleteById(Integer id);
|
||||
|
||||
int deleteByList(@Param("ids") List<Integer> ids);
|
||||
|
||||
int insertBatch(List<DeptUserEntity> list);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.glxp.api.admin.entity.auth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeptUserEntity {
|
||||
private Integer deptId;
|
||||
private Integer userId;
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.glxp.api.admin.req.auth;
|
||||
|
||||
import com.glxp.api.admin.req.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeptUserReqeust extends ListPageRequest {
|
||||
private Integer deptId;
|
||||
private Integer userId;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.glxp.api.admin.res.auth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeptUserResponse {
|
||||
|
||||
private Integer deptId;
|
||||
private Integer userId;
|
||||
private String userName;
|
||||
private String employeeName;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.glxp.api.admin.service.auth;
|
||||
|
||||
import com.glxp.api.admin.entity.auth.DeptUserEntity;
|
||||
import com.glxp.api.admin.req.auth.DeptUserReqeust;
|
||||
import com.glxp.api.admin.res.auth.DeptUserResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DeptUserService {
|
||||
|
||||
|
||||
List<DeptUserEntity> selectDeptUser(DeptUserReqeust deptUserReqeust);
|
||||
|
||||
List<DeptUserResponse> selectJoinDeptUser(DeptUserReqeust deptUserReqeust);
|
||||
|
||||
int deleteById(Integer id);
|
||||
|
||||
int deleteByList(List<Integer> ids);
|
||||
|
||||
int insertBatch(List<DeptUserEntity> list);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.glxp.api.admin.service.auth.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.admin.dao.auth.DeptUserDao;
|
||||
import com.glxp.api.admin.entity.auth.DeptUserEntity;
|
||||
import com.glxp.api.admin.req.auth.DeptUserReqeust;
|
||||
import com.glxp.api.admin.res.auth.DeptUserResponse;
|
||||
import com.glxp.api.admin.service.auth.DeptUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeptUserServiceImpl implements DeptUserService {
|
||||
|
||||
@Resource
|
||||
DeptUserDao deptUserDao;
|
||||
|
||||
|
||||
@Override
|
||||
public List<DeptUserEntity> selectDeptUser(DeptUserReqeust deptUserReqeust) {
|
||||
if (deptUserReqeust.getPage() != null) {
|
||||
int offset = (deptUserReqeust.getPage() - 1) * deptUserReqeust.getLimit();
|
||||
PageHelper.offsetPage(offset, deptUserReqeust.getLimit());
|
||||
}
|
||||
return deptUserDao.selectDeptUser(deptUserReqeust);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptUserResponse> selectJoinDeptUser(DeptUserReqeust deptUserReqeust) {
|
||||
if (deptUserReqeust.getPage() != null) {
|
||||
int offset = (deptUserReqeust.getPage() - 1) * deptUserReqeust.getLimit();
|
||||
PageHelper.offsetPage(offset, deptUserReqeust.getLimit());
|
||||
}
|
||||
return deptUserDao.selectJoinDeptUser(deptUserReqeust);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Integer id) {
|
||||
return deptUserDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByList(List<Integer> ids) {
|
||||
return deptUserDao.deleteByList(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertBatch(List<DeptUserEntity> list) {
|
||||
if (CollUtil.isNotEmpty(list))
|
||||
return deptUserDao.insertBatch(list);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
<?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.DeptUserDao">
|
||||
|
||||
|
||||
<select id="selectDeptUser" parameterType="com.glxp.api.admin.req.auth.DeptUserReqeust"
|
||||
resultType="com.glxp.api.admin.entity.auth.DeptUserEntity">>
|
||||
SELECT *
|
||||
FROM auth_dept_user
|
||||
<where>
|
||||
<if test="deptId != null ">
|
||||
and deptId = #{deptId}
|
||||
</if>
|
||||
<if test="userId != null ">
|
||||
and userId = #{userId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectJoinDeptUser" parameterType="com.glxp.api.admin.req.auth.DeptUserReqeust"
|
||||
resultType="com.glxp.api.admin.entity.auth.DeptUserEntity">>
|
||||
SELECT auth_dept_user.*,auth_user.userName,auth_user.employeeName
|
||||
FROM auth_dept_user INNER JOIN auth_user
|
||||
on auth_dept_user.userId = auth_user.id
|
||||
<where>
|
||||
<if test="deptId != null ">
|
||||
and deptId = #{deptId}
|
||||
</if>
|
||||
<if test="userId != null ">
|
||||
and userId = #{userId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Integer">
|
||||
delete
|
||||
from auth_dept_user
|
||||
where deptId = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByList" parameterType="java.util.List"
|
||||
>
|
||||
delete
|
||||
from auth_dept_user
|
||||
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_user
|
||||
(
|
||||
deptId,userId
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index"
|
||||
separator=",">
|
||||
(
|
||||
#{item.deptId},
|
||||
#{item.userId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue