14 changed files with 766 additions and 24 deletions
@ -0,0 +1,76 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dto; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户部门关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-07-29 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SysUserDeptDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private Long userId; |
||||
|
|
||||
|
/** |
||||
|
* 部门ID |
||||
|
*/ |
||||
|
private Long deptId; |
||||
|
|
||||
|
/** |
||||
|
* 删除标识 0:未删除 1:删除 |
||||
|
*/ |
||||
|
private Integer delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 创建者 |
||||
|
*/ |
||||
|
private Long creator; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createDate; |
||||
|
|
||||
|
/** |
||||
|
* 更新者 |
||||
|
*/ |
||||
|
private Long updater; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updateDate; |
||||
|
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.elink.esua.epdc.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2020/7/29 18:48 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SysUserDeptInfoDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 关联部门ID |
||||
|
*/ |
||||
|
private Long relationDeptId; |
||||
|
|
||||
|
/** |
||||
|
* 关联部门名称 |
||||
|
*/ |
||||
|
private String relationDeptName; |
||||
|
} |
@ -0,0 +1,94 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.elink.esua.epdc.dto.SysUserDeptDTO; |
||||
|
import com.elink.esua.epdc.excel.SysUserDeptExcel; |
||||
|
import com.elink.esua.epdc.service.SysUserDeptService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户部门关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-07-29 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("sysuserdept") |
||||
|
public class SysUserDeptController { |
||||
|
|
||||
|
@Autowired |
||||
|
private SysUserDeptService sysUserDeptService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<SysUserDeptDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<SysUserDeptDTO> page = sysUserDeptService.page(params); |
||||
|
return new Result<PageData<SysUserDeptDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<SysUserDeptDTO> get(@PathVariable("id") String id){ |
||||
|
SysUserDeptDTO data = sysUserDeptService.get(id); |
||||
|
return new Result<SysUserDeptDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody SysUserDeptDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
sysUserDeptService.save(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody SysUserDeptDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
sysUserDeptService.update(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids){ |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
sysUserDeptService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("export") |
||||
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
||||
|
List<SysUserDeptDTO> list = sysUserDeptService.list(params); |
||||
|
ExcelUtils.exportExcelToTarget(response, null, list, SysUserDeptExcel.class); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,46 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dao; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import com.elink.esua.epdc.dto.SysUserDeptInfoDTO; |
||||
|
import com.elink.esua.epdc.entity.SysUserDeptEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
/** |
||||
|
* 用户部门关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-07-29 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface SysUserDeptDao extends BaseDao<SysUserDeptEntity> { |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 根据用户ID获取用户关联部门信息 |
||||
|
* |
||||
|
* @param userId |
||||
|
* @return com.elink.esua.epdc.entity.SysUserDeptEntity |
||||
|
* @author liuchuang |
||||
|
* @since 2020/7/29 18:43 |
||||
|
*/ |
||||
|
SysUserDeptInfoDTO selectUserDeptInfoByUserId(@Param("userId") Long userId); |
||||
|
|
||||
|
} |
@ -0,0 +1,73 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.entity.BaseEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 用户部门关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-07-29 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("sys_user_dept") |
||||
|
public class SysUserDeptEntity extends BaseEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private Long userId; |
||||
|
|
||||
|
/** |
||||
|
* 部门ID |
||||
|
*/ |
||||
|
private Long deptId; |
||||
|
|
||||
|
/** |
||||
|
* 删除标识 0:未删除 1:删除 |
||||
|
*/ |
||||
|
@TableLogic |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private Integer delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 更新者 |
||||
|
*/ |
||||
|
@TableField(fill = FieldFill.INSERT_UPDATE) |
||||
|
private Long updater; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
@TableField(fill = FieldFill.INSERT_UPDATE) |
||||
|
private Date updateDate; |
||||
|
|
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.excel; |
||||
|
|
||||
|
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 用户部门关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-07-29 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SysUserDeptExcel { |
||||
|
|
||||
|
@Excel(name = "id") |
||||
|
private String id; |
||||
|
|
||||
|
@Excel(name = "用户ID") |
||||
|
private Long userId; |
||||
|
|
||||
|
@Excel(name = "部门ID") |
||||
|
private Long deptId; |
||||
|
|
||||
|
@Excel(name = "删除标识 0:未删除 1:删除") |
||||
|
private Integer delFlag; |
||||
|
|
||||
|
@Excel(name = "创建者") |
||||
|
private Long creator; |
||||
|
|
||||
|
@Excel(name = "创建时间") |
||||
|
private Date createDate; |
||||
|
|
||||
|
@Excel(name = "更新者") |
||||
|
private Long updater; |
||||
|
|
||||
|
@Excel(name = "更新时间") |
||||
|
private Date updateDate; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.redis; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 用户部门关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-07-29 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class SysUserDeptRedis { |
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
public void delete(Object[] ids) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void set(){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public String get(String id){ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,119 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.dto.SysUserDeptDTO; |
||||
|
import com.elink.esua.epdc.dto.SysUserDeptInfoDTO; |
||||
|
import com.elink.esua.epdc.entity.SysUserDeptEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户部门关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-07-29 |
||||
|
*/ |
||||
|
public interface SysUserDeptService extends BaseService<SysUserDeptEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<SysUserDeptDTO> |
||||
|
* @author generator |
||||
|
* @date 2020-07-29 |
||||
|
*/ |
||||
|
PageData<SysUserDeptDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<SysUserDeptDTO> |
||||
|
* @author generator |
||||
|
* @date 2020-07-29 |
||||
|
*/ |
||||
|
List<SysUserDeptDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return SysUserDeptDTO |
||||
|
* @author generator |
||||
|
* @date 2020-07-29 |
||||
|
*/ |
||||
|
SysUserDeptDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-07-29 |
||||
|
*/ |
||||
|
void save(SysUserDeptDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-07-29 |
||||
|
*/ |
||||
|
void update(SysUserDeptDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-07-29 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 保存/更新用户关联部门信息 |
||||
|
* |
||||
|
* @param userId |
||||
|
* @param deptId |
||||
|
* @return void |
||||
|
* @author liuchuang |
||||
|
* @since 2020/7/29 15:56 |
||||
|
*/ |
||||
|
void saveOrUpdateUserDeptInfo(Long userId, Long deptId); |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 根据用户ID获取用户关联部门信息 |
||||
|
* |
||||
|
* @param userId |
||||
|
* @return com.elink.esua.epdc.dto.SysUserDeptInfoDTO |
||||
|
* @author liuchuang |
||||
|
* @since 2020/7/29 16:19 |
||||
|
*/ |
||||
|
SysUserDeptInfoDTO getUserDeptInfoByUserId(Long userId); |
||||
|
} |
@ -0,0 +1,134 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.elink.esua.epdc.commons.mybatis.enums.DelFlagEnum; |
||||
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
||||
|
import com.elink.esua.epdc.dao.SysUserDeptDao; |
||||
|
import com.elink.esua.epdc.dto.SysUserDeptDTO; |
||||
|
import com.elink.esua.epdc.dto.SysUserDeptInfoDTO; |
||||
|
import com.elink.esua.epdc.entity.SysUserDeptEntity; |
||||
|
import com.elink.esua.epdc.entity.SysUserEntity; |
||||
|
import com.elink.esua.epdc.redis.SysUserDeptRedis; |
||||
|
import com.elink.esua.epdc.service.SysUserDeptService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户部门关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-07-29 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class SysUserDeptServiceImpl extends BaseServiceImpl<SysUserDeptDao, SysUserDeptEntity> implements SysUserDeptService { |
||||
|
|
||||
|
@Autowired |
||||
|
private SysUserDeptRedis sysUserDeptRedis; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<SysUserDeptDTO> page(Map<String, Object> params) { |
||||
|
IPage<SysUserDeptEntity> page = baseDao.selectPage( |
||||
|
getPage(params, FieldConstant.CREATED_TIME, false), |
||||
|
getWrapper(params) |
||||
|
); |
||||
|
return getPageData(page, SysUserDeptDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<SysUserDeptDTO> list(Map<String, Object> params) { |
||||
|
List<SysUserDeptEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, SysUserDeptDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<SysUserDeptEntity> getWrapper(Map<String, Object> params){ |
||||
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
||||
|
|
||||
|
QueryWrapper<SysUserDeptEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public SysUserDeptDTO get(String id) { |
||||
|
SysUserDeptEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, SysUserDeptDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(SysUserDeptDTO dto) { |
||||
|
SysUserDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysUserDeptEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(SysUserDeptDTO dto) { |
||||
|
SysUserDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysUserDeptEntity.class); |
||||
|
updateById(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void saveOrUpdateUserDeptInfo(Long userId, Long deptId) { |
||||
|
if (null != userId && null != deptId) { |
||||
|
QueryWrapper<SysUserDeptEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(FieldConstant.USER_ID, userId) |
||||
|
.eq(FieldConstant.DEL_FLAG, DelFlagEnum.NORMAL.value()); |
||||
|
SysUserDeptEntity userDeptEntity = baseDao.selectOne(wrapper); |
||||
|
|
||||
|
if (null != userDeptEntity) { |
||||
|
userDeptEntity.setUserId(userId); |
||||
|
userDeptEntity.setDeptId(deptId); |
||||
|
updateById(userDeptEntity); |
||||
|
} else { |
||||
|
SysUserDeptEntity entity = new SysUserDeptEntity(); |
||||
|
entity.setUserId(userId); |
||||
|
entity.setDeptId(deptId); |
||||
|
insert(entity); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public SysUserDeptInfoDTO getUserDeptInfoByUserId(Long userId) { |
||||
|
return baseDao.selectUserDeptInfoByUserId(userId); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
<?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.elink.esua.epdc.dao.SysUserDeptDao"> |
||||
|
|
||||
|
<resultMap type="com.elink.esua.epdc.entity.SysUserDeptEntity" id="sysUserDeptMap"> |
||||
|
<result property="id" column="id"/> |
||||
|
<result property="userId" column="user_id"/> |
||||
|
<result property="deptId" column="dept_id"/> |
||||
|
<result property="delFlag" column="del_flag"/> |
||||
|
<result property="creator" column="creator"/> |
||||
|
<result property="createDate" column="create_date"/> |
||||
|
<result property="updater" column="updater"/> |
||||
|
<result property="updateDate" column="update_date"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<select id="selectUserDeptInfoByUserId" resultType="com.elink.esua.epdc.dto.SysUserDeptInfoDTO"> |
||||
|
SELECT |
||||
|
d.id relationDeptId, |
||||
|
d.`name` relationDeptName |
||||
|
FROM |
||||
|
sys_user_dept ud |
||||
|
LEFT JOIN sys_dept d ON d.id = ud.dept_id |
||||
|
AND d.del_flag = 0 |
||||
|
WHERE |
||||
|
ud.del_flag = 0 |
||||
|
AND ud.user_id = #{userId} |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue