package com.nuvole.four.mapper; import com.nuvole.four.domain.SysOrg; import com.nuvole.four.domain.dto.ChannelOrgConfigDetailDto; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import java.util.List; import java.util.Map; public interface SysOrgMapper { int deleteByPrimaryKey(Long id); int insert(SysOrg record); int insertSelective(SysOrg record); SysOrg selectByPrimaryKey(Long id); int updateByPrimaryKeySelective(SysOrg record); int updateByPrimaryKey(SysOrg record); /** * @Author : liu.q [916000612@qq.com] * @Date : 2019-04-04 14:15 * @Description :查询全部 */ List selectAll(Map map); /** * @Author : liu.q [916000612@qq.com] * @Date : 2019-04-07 19:21 * @Description :查询全部 */ List selectAllOfMap(Map map); /** * 根据机构编号查询机构信息 * * @author zxc * @Date 2019/6/4 11:35 **/ SysOrg getOrgByCode(String code); @Select("select org.*,org2.org_Code pOrgCode from sys_org org left join sys_org org2 on org.pid = org2.id where org.org_code=#{code}") Map getOrgByCode2(String code); List getBranchByOrgCode(@Param("code") String code, @Param("keyText") String keyText, @Param("userType") Short userType); /** * 查询机构byCode * * @Author: lc * @Date: 2019/6/12 16:20 */ SysOrg selectOrgByCode(String code); /** * 批量执行导入 * * @author zxc * @Date 2019/6/11 18:59 **/ int batchImportOrg(List list); /** * 查询全部机构 * * @Author: lc * @Date: 2019/6/13 9:39 */ @Select("select * from sys_org ") List getOrgList(); /** * 查询父机构useCode 以及 子机构maxCode * * @author zxc * @Date 2019/7/13 18:49 **/ @Select("select max(a.org_code) maxCode,a.pid,(select b.org_code from sys_org b where b.id = a.pid) pCode from sys_org a group by a.pid") List selectUseCodeForImport(); /** * 查询本级最大code * * @Author: lc * @Date: 2019/6/13 13:40 */ @Select("select max(org_code) from sys_org where pid=#{pid} ") String getMaxCode(@Param("pid") Long pid); /** * 根据机构编号获取机构 * * @param orgCode * @return */ @Select("select * from sys_org where user_org_code = #{orgCode}") SysOrg selectByOrgCode(@Param("orgCode") String orgCode); /** * 角色管理人员配置机构树 * * @author zxc * @Date 2019/6/13 17:19 **/ List getListForRoleUser(Map map); /** * Createed by PKZ * Date 2019/6/17 16:11 * Description:根据userOrgCode查询机构信息 **/ @Select("select a.org_code zj_org_code,a.id zj_id,a.name zj_name,b.id xq_id,b.name xq_name,c.id sj_id,c.name sj_name from sys_org a,sys_org b,sys_org c where a.user_org_code = #{orgCode} and b.id=a.pid and c.id=b.pid") Map getOrgByUserCode(@Param("orgCode") String code); List getOrgForSelector(@Param("pid") Long pid, @Param("rootId") Long rootId); @Select("select pid from sys_org where id = #{id}") Long queryPidById(@Param("id") Long id); @Select("select lv from sys_org where id = #{id}") Integer queryLvById(@Param("id") Long id); Integer getByOrgCode(SysOrg sysOrg); @Select("select id,name,org_code,user_org_code,pid from sys_org where state=1 and lv<2") List getOrgEndS(); @Select("select id, name from sys_org where pid = #{orgId}") List getOrgMapByLogin(Long orgId); @Select("select id, name from sys_org where id = #{orgId} and lv = 3") List getOrgMapByLoginLv(Long orgId); @Select("select lv from sys_org where org_code = #{orgCode}") Integer getOrgLvByOrgCode(String orgCode); /** * 查询所有支局 */ @Select("select id, name from sys_org where lv = 3") List getWdIdOrName(); /** * 查询所有支局 */ @Select("select * from sys_org where lv = 0 limit 1") SysOrg getSjOrgInfo(); @Select("select * from sys_org where pid=(select id from sys_org where org_code = #{orgCode} ) or org_code = #{orgCode}") List selectOrgByOrgCode(String orgCode); @Select("select name as orgName ,org_code as orgCode from sys_org group by org_code ") List getOrgCodeCache(); @Select("select a.name,c.org_code orgCode from sys_area a left join sys_org_area b on b.area_id = a.id left join sys_org c on c.id = b.org_id where a.lv = 2") List getSjOrgCodeAreaNameRef(); /** * 禁用机构 * * @param orgCode * @return CONCAT(' % ', # { 0 }, ' % ') */ @Update("update sys_org set state=#{state} where org_code like CONCAT('%',#{orgCode},'%')") int updateState(@Param("orgCode") String orgCode, @Param("state") Integer state); /** * 方法描述: 根据orgId查询机构名称、父级机构名称 * * @date 2024-04-11 20:30 **/ @Select("select a.id,a.name orgName,a.pid pId,a.lv,(select b.name from sys_org b where b.id = a.pid) parentOrgName from sys_org a where a.id = #{orgId}") ChannelOrgConfigDetailDto queryNameAndParentName(@Param("orgId") Long orgId); }