master
parent
59e17ab5c2
commit
c134fefdf8
@ -0,0 +1,39 @@
|
||||
package com.zh.project0512.mapper;
|
||||
|
||||
import com.zh.project0512.model.QywxDepartmentGroupLink;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-06-24
|
||||
*/
|
||||
public interface QywxDepartmentGroupLinkMapper extends BaseMapper<QywxDepartmentGroupLink> {
|
||||
@Insert("<script> " +
|
||||
"insert into qywxDepartmentGroupLink (groupId,departmentId,creatAt) values\n"+
|
||||
" <foreach collection= 'departmentIdList' item= 'item' separator=','>\n" +
|
||||
"(#{groupId},#{item},#{creatAt})\n"+
|
||||
"</foreach> \n"+
|
||||
"</script>")
|
||||
void groupAddDepartment(Integer groupId, List<Integer> departmentIdList, LocalDateTime creatAt);
|
||||
List<Map> departmentList(Integer groupId);
|
||||
@Select("SELECT t1.departmentId\n" +
|
||||
"from qywxDepartmentGroupLink as t1\n" +
|
||||
"LEFT JOIN qywxDepartmentGroup as t2 on t1.groupId = t2.id\n" +
|
||||
"INNER JOIN qywxDepartment as t3 on t3.departmentId = t1.departmentId \n" +
|
||||
"where t2.id in \n" +
|
||||
"<foreach collection='groupIdList' index='index' item='item' open='(' separator=',' close=')'>" +
|
||||
"#{item}" +
|
||||
"</foreach>" +
|
||||
"GROUP BY departmentId")
|
||||
List<Integer> departmentIdList(List<Integer> groupIdList);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.zh.project0512.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zh.project0512.model.QywxDepartmentGroup;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-06-24
|
||||
*/
|
||||
public interface QywxDepartmentGroupMapper extends BaseMapper<QywxDepartmentGroup> {
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-06-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("qywxDepartmentGroup")
|
||||
public class QywxDepartmentGroup extends Model {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 部门级别名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
@TableField("creatAt")
|
||||
private LocalDateTime creatAt;
|
||||
|
||||
@TableField("updateAt")
|
||||
private LocalDateTime updateAt;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-06-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("qywxDepartmentGroupLink")
|
||||
public class QywxDepartmentGroupLink extends Model {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 部门分组id
|
||||
*/
|
||||
@TableField("groupId")
|
||||
private Integer groupId;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
@TableField("departmentId")
|
||||
private Integer departmentId;
|
||||
|
||||
@TableField("creatAt")
|
||||
private LocalDateTime creatAt;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.zh.project0512.service;
|
||||
|
||||
import com.zh.project0512.model.QywxDepartmentGroupLink;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-06-24
|
||||
*/
|
||||
public interface IQywxDepartmentGroupLinkService extends IService<QywxDepartmentGroupLink> {
|
||||
void groupAddDepartment(Integer groupId, List<Integer> departmentIdList, LocalDateTime creatAt);
|
||||
List<Map> departmentList(Integer groupId);
|
||||
List<Integer> departmentIdList(List<Integer> groupIdList);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.zh.project0512.service;
|
||||
|
||||
import com.zh.project0512.model.QywxDepartmentGroup;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-06-24
|
||||
*/
|
||||
public interface IQywxDepartmentGroupService extends IService<QywxDepartmentGroup> {
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.zh.project0512.serviceImpl;
|
||||
|
||||
import com.zh.project0512.mapper.QywxDepartmentGroupMapper;
|
||||
import com.zh.project0512.model.QywxDepartmentGroupLink;
|
||||
import com.zh.project0512.mapper.QywxDepartmentGroupLinkMapper;
|
||||
import com.zh.project0512.service.IQywxDepartmentGroupLinkService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-06-24
|
||||
*/
|
||||
@Service
|
||||
public class QywxDepartmentGroupLinkServiceImpl extends ServiceImpl<QywxDepartmentGroupLinkMapper, QywxDepartmentGroupLink> implements IQywxDepartmentGroupLinkService {
|
||||
@Autowired
|
||||
private QywxDepartmentGroupLinkMapper qywxDepartmentGroupLinkMapper;
|
||||
|
||||
public void groupAddDepartment(Integer groupId, List<Integer> departmentIdList, LocalDateTime creatAt) {
|
||||
qywxDepartmentGroupLinkMapper.groupAddDepartment(groupId, departmentIdList, creatAt);
|
||||
}
|
||||
public List<Map> departmentList(Integer groupId){
|
||||
return qywxDepartmentGroupLinkMapper.departmentList(groupId);
|
||||
}
|
||||
public List<Integer> departmentIdList(List<Integer> groupIdList){
|
||||
return qywxDepartmentGroupLinkMapper.departmentIdList(groupIdList);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.zh.project0512.serviceImpl;
|
||||
|
||||
import com.zh.project0512.model.QywxDepartmentGroup;
|
||||
import com.zh.project0512.mapper.QywxDepartmentGroupMapper;
|
||||
import com.zh.project0512.service.IQywxDepartmentGroupService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-06-24
|
||||
*/
|
||||
@Service
|
||||
public class QywxDepartmentGroupServiceImpl extends ServiceImpl<QywxDepartmentGroupMapper, QywxDepartmentGroup> implements IQywxDepartmentGroupService {
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?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.zh.project0512.mapper.QywxDepartmentGroupLinkMapper">
|
||||
|
||||
<resultMap id="departmentListMap" type="java.util.Map" autoMapping="false">
|
||||
<id property="departmentId" column="departmentId"/>
|
||||
<result column="departmentName" property="departmentName"/>
|
||||
<result column="creatAt" property="creatAt"/>
|
||||
<collection property="userList" ofType="java.util.Map" javaType="java.util.List" autoMapping="false">
|
||||
<id column="userId" property="userId"/>
|
||||
<result column="userName" property="userName"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="departmentList" resultMap="departmentListMap">
|
||||
SELECT t1.*,t2.name,t3.name as departmentName
|
||||
,t4.id as userId,t4.name as userName
|
||||
from qywxDepartmentGroupLink as t1
|
||||
LEFT JOIN qywxDepartmentGroup as t2 on t1.groupId = t2.id
|
||||
INNER JOIN qywxDepartment as t3 on t3.departmentId = t1.departmentId
|
||||
LEFT JOIN user as t4 on t4.main_department = t1.departmentId
|
||||
where t2.id = #{groupId}
|
||||
GROUP BY groupId, departmentId
|
||||
,userName
|
||||
ORDER BY creatAt DESC
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in new issue