17 changed files with 369 additions and 24 deletions
@ -0,0 +1,20 @@ |
|||||
|
package com.yxt.anrui.portal.api.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 13:29 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SysOrgPathList implements Vo { |
||||
|
private static final long serialVersionUID = 2356384382464107570L; |
||||
|
|
||||
|
@ApiModelProperty("组织机构全路径sid") |
||||
|
private String orgSidPath; |
||||
|
@ApiModelProperty("组织机构全路径名称") |
||||
|
private String orgNamePath; |
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package com.yxt.anrui.portal.api.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.common.core.domain.BaseEntity; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 11:23 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SysUserDefaultOrg extends BaseEntity { |
||||
|
private static final long serialVersionUID = 3567627566535174850L; |
||||
|
|
||||
|
@ApiModelProperty("人员sid") |
||||
|
private String staffSid; |
||||
|
@ApiModelProperty("默认的组织机构sid") |
||||
|
private String orgSidPath; |
||||
|
@ApiModelProperty("默认的组织机构名称") |
||||
|
private String orgNamePath; |
||||
|
|
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.yxt.anrui.portal.api.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 14:18 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SysUserDefaultOrgDto implements Dto { |
||||
|
private static final long serialVersionUID = 3069749900524077996L; |
||||
|
|
||||
|
@ApiModelProperty("用户sid") |
||||
|
private String userSid; |
||||
|
@ApiModelProperty("设置的默认组织全路径sid") |
||||
|
private String orgSidPath; |
||||
|
@ApiModelProperty("设置的默认组织全路径名称") |
||||
|
private String orgNamePath; |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package com.yxt.anrui.portal.api.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 11:24 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Api(tags = "用户默认的组织机构表") |
||||
|
@FeignClient( |
||||
|
contextId = "anrui-portal-SysUserDefaultOrg", |
||||
|
name = "anrui-portal", |
||||
|
path = "v1/sysuserdefaultorg", |
||||
|
fallback = SysUserDefaultOrgFeignFallback.class) |
||||
|
public interface SysUserDefaultOrgFeign { |
||||
|
|
||||
|
@ApiOperation("获取用户的默认机构") |
||||
|
@GetMapping("/getList") |
||||
|
@ResponseBody |
||||
|
ResultBean<SysUserDefaultOrgVo> getList(@RequestParam("userSid") String userSid); |
||||
|
|
||||
|
@ApiOperation("设置默认组织机构") |
||||
|
@PostMapping("/saveOrUpdate") |
||||
|
@ResponseBody |
||||
|
ResultBean saveOrUpdate(@RequestBody SysUserDefaultOrgDto dto); |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.yxt.anrui.portal.api.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 11:26 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Component |
||||
|
public class SysUserDefaultOrgFeignFallback implements SysUserDefaultOrgFeign{ |
||||
|
@Override |
||||
|
public ResultBean<SysUserDefaultOrgVo> getList(String userSid) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean saveOrUpdate(SysUserDefaultOrgDto dto) { |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.yxt.anrui.portal.api.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 11:52 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SysUserDefaultOrgQuery implements Query { |
||||
|
private static final long serialVersionUID = 549888513841147615L; |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.yxt.anrui.portal.api.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 11:52 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SysUserDefaultOrgVo implements Vo { |
||||
|
private static final long serialVersionUID = -4852902800844447195L; |
||||
|
|
||||
|
@ApiModelProperty("设置的默认的组织机构名称") |
||||
|
private String orgNamePath; |
||||
|
@ApiModelProperty("设置的默认的组织机构sid") |
||||
|
private String orgSidPath; |
||||
|
@ApiModelProperty("当前用户所有的组织机构list") |
||||
|
private List<SysOrgPathList> list; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.yxt.anrui.portal.biz.sysuserdefaultorg; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.yxt.anrui.portal.api.sysuserdefaultorg.SysUserDefaultOrg; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 11:27 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface SysUserDefaultOrgMapper extends BaseMapper<SysUserDefaultOrg> { |
||||
|
SysUserDefaultOrg selectByUserSid(String userSid); |
||||
|
|
||||
|
int deleteByUserSid(String userSid); |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
<?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.yxt.anrui.portal.biz.sysuserdefaultorg.SysUserDefaultOrgMapper"> |
||||
|
<select id="selectByUserSid" resultType="com.yxt.anrui.portal.api.sysuserdefaultorg.SysUserDefaultOrg"> |
||||
|
select * |
||||
|
from sys_user_default_org |
||||
|
where createBySid = #{userSid} |
||||
|
order by id desc |
||||
|
limit 1 |
||||
|
</select> |
||||
|
|
||||
|
<delete id="deleteByUserSid"> |
||||
|
delete |
||||
|
from sys_user_default_org |
||||
|
where createBySid = #{userSid} |
||||
|
</delete> |
||||
|
</mapper> |
@ -0,0 +1,34 @@ |
|||||
|
package com.yxt.anrui.portal.biz.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.anrui.portal.api.sysuserdefaultorg.SysUserDefaultOrgDto; |
||||
|
import com.yxt.anrui.portal.api.sysuserdefaultorg.SysUserDefaultOrgFeign; |
||||
|
import com.yxt.anrui.portal.api.sysuserdefaultorg.SysUserDefaultOrgVo; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 11:26 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Api(tags = "用户默认的组织机构") |
||||
|
@RestController |
||||
|
@RequestMapping("v1/sysuserdefaultorg") |
||||
|
public class SysUserDefaultOrgRest implements SysUserDefaultOrgFeign { |
||||
|
|
||||
|
@Autowired |
||||
|
private SysUserDefaultOrgService sysUserDefaultOrgService; |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<SysUserDefaultOrgVo> getList(String userSid) { |
||||
|
return sysUserDefaultOrgService.getList(userSid); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean saveOrUpdate(SysUserDefaultOrgDto dto) { |
||||
|
return sysUserDefaultOrgService.saveDefaultOrg(dto); |
||||
|
} |
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
package com.yxt.anrui.portal.biz.sysuserdefaultorg; |
||||
|
|
||||
|
import com.yxt.anrui.portal.api.sysuser.SysUser; |
||||
|
import com.yxt.anrui.portal.api.sysuserdefaultorg.*; |
||||
|
import com.yxt.anrui.portal.biz.sysstafforg.SysStaffOrgService; |
||||
|
import com.yxt.anrui.portal.biz.sysuser.SysUserService; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.base.utils.StringUtils; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Collections; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/11 11:27 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Service |
||||
|
public class SysUserDefaultOrgService extends MybatisBaseService<SysUserDefaultOrgMapper, SysUserDefaultOrg> { |
||||
|
|
||||
|
@Autowired |
||||
|
private SysStaffOrgService sysStaffOrgService; |
||||
|
@Autowired |
||||
|
private SysUserService sysUserService; |
||||
|
|
||||
|
public ResultBean<SysUserDefaultOrgVo> getList(String userSid) { |
||||
|
ResultBean<SysUserDefaultOrgVo> rb = ResultBean.fireFail(); |
||||
|
SysUserDefaultOrgVo sysUserDefaultOrgVo = new SysUserDefaultOrgVo(); |
||||
|
//根据用户sid查询staffSid
|
||||
|
SysUser sysUser = sysUserService.fetchBySid(userSid); |
||||
|
List<SysOrgPathList> list = sysStaffOrgService.getList(sysUser.getStaffSid()); |
||||
|
list.removeAll(Collections.singleton(null)); |
||||
|
sysUserDefaultOrgVo.setList(list); |
||||
|
//根据该用户名称查询是否设置了默认组织机构
|
||||
|
SysUserDefaultOrg sysUserDefaultOrg = baseMapper.selectByUserSid(userSid); |
||||
|
if (sysUserDefaultOrg != null) { |
||||
|
sysUserDefaultOrgVo.setOrgSidPath(sysUserDefaultOrg.getOrgSidPath()); |
||||
|
sysUserDefaultOrgVo.setOrgNamePath(sysUserDefaultOrg.getOrgNamePath()); |
||||
|
} |
||||
|
return rb.success().setData(sysUserDefaultOrgVo); |
||||
|
} |
||||
|
|
||||
|
public SysUserDefaultOrg selectByUserSid(String userSid) { |
||||
|
return baseMapper.selectByUserSid(userSid); |
||||
|
} |
||||
|
|
||||
|
public ResultBean saveDefaultOrg(SysUserDefaultOrgDto dto) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
String userSid = dto.getUserSid(); |
||||
|
if (StringUtils.isBlank(userSid)) { |
||||
|
return rb.setMsg("参数错误:userSid是必传项"); |
||||
|
} |
||||
|
String orgSidPath = dto.getOrgSidPath(); |
||||
|
if (StringUtils.isNotBlank(orgSidPath)) { |
||||
|
//删除设置的默认组织机构
|
||||
|
baseMapper.deleteByUserSid(userSid); |
||||
|
SysUserDefaultOrg sysUserDefaultOrg = new SysUserDefaultOrg(); |
||||
|
String orgNamePath = dto.getOrgNamePath(); |
||||
|
if (StringUtils.isBlank(orgNamePath)) { |
||||
|
return rb.setMsg("参数错误:orgNamePath是必传项"); |
||||
|
} |
||||
|
SysUser sysUser = sysUserService.fetchBySid(userSid); |
||||
|
sysUserDefaultOrg.setOrgSidPath(orgSidPath); |
||||
|
sysUserDefaultOrg.setOrgNamePath(orgNamePath); |
||||
|
sysUserDefaultOrg.setCreateBySid(userSid); |
||||
|
sysUserDefaultOrg.setStaffSid(sysUser.getStaffSid()); |
||||
|
baseMapper.insert(sysUserDefaultOrg); |
||||
|
} else { |
||||
|
//删除设置的默认组织机构
|
||||
|
baseMapper.deleteByUserSid(userSid); |
||||
|
} |
||||
|
return rb.success(); |
||||
|
} |
||||
|
|
||||
|
public int deleteByUserSid(String sid) { |
||||
|
return baseMapper.deleteByUserSid(sid); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue