| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.yuanchu.mom.annotation.ValueAuth; |
| | | import com.yuanchu.mom.pojo.AuthApi; |
| | | import com.yuanchu.mom.annotation.ValueClassify; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.dto.PersonDto; |
| | | import com.yuanchu.mom.exception.ErrorException; |
| | | import com.yuanchu.mom.mapper.PowerMapper; |
| | | import com.yuanchu.mom.mapper.UserMapper; |
| | | import com.yuanchu.mom.pojo.Company; |
| | | import com.yuanchu.mom.pojo.Person; |
| | | import com.yuanchu.mom.pojo.Power; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import com.yuanchu.mom.service.UserService; |
| | | import com.yuanchu.mom.util.HeaderToken; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.Authorization; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/companies") |
| | | @Api("组织模块") |
| | | @Api(tags="用户模块") |
| | | public class CompaniesController { |
| | | |
| | | @Autowired |
| | | private HeaderToken headerToken; |
| | | |
| | | @ValueAuth |
| | | @ApiOperation(value = "获取组织列表") |
| | | @GetMapping(value = "/selectCompaniesList") |
| | | public Result<List<Company>> selectcompaniesList(){ |
| | | return Result.success(headerToken.companyUrl()); |
| | | private UserService userService; |
| | | |
| | | UserMapper userMapper; |
| | | |
| | | PowerMapper powerMapper; |
| | | |
| | | private GetLook getLook; |
| | | |
| | | @ValueClassify("用户管理") |
| | | @PostMapping("/getSampleUser") |
| | | @ApiOperation(value = "查看指定部门的人事系统组织架构") |
| | | public Result<?> getSampleUser(){ |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ValueClassify("用户管理") |
| | | @ApiOperation(value = "查看人事系统组织架构") |
| | | @GetMapping(value = "/selectCompaniesList") |
| | | public Result<List<Company>> selectCompaniesList() { |
| | | //判断是否有直接获取第三方部门的权限 |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | User user = userMapper.selectById(userId); |
| | | Integer roleId = user.getRoleId(); |
| | | Power power = powerMapper.selectOne(Wrappers.<Power>lambdaQuery().eq(Power::getRoleId, roleId).eq(Power::getMenuMethod, "getSampleUser")); |
| | | if (ObjectUtils.isNotEmpty(power)){ |
| | | List<Company> companies = new ArrayList<>(); |
| | | Company company = new Company(); |
| | | if (ObjectUtils.isEmpty(user.getCompany())){ |
| | | throw new ErrorException("该用户没有所属单位!"); |
| | | } |
| | | company.setCompanyId(user.getCompany()); |
| | | companies.add(company); |
| | | return Result.success(companies); |
| | | }else { |
| | | return Result.success(headerToken.companyUrl()); |
| | | } |
| | | } |
| | | |
| | | @ValueAuth |
| | | @ApiOperation("获取人事系统组织下的人员") |
| | | @PostMapping(value = "/selectSimpleList") |
| | | public Result<?> selectSimpleList(String companyId) { |
| | | return Result.success(headerToken.userUrl(companyId)); |
| | | } |
| | | |
| | | @ValueAuth |
| | | @ApiOperation("将人事系统勾选的内容转移到本系统") |
| | | @PostMapping(value = "/addPersonUser") |
| | | public Result<?> addPersonUser(@RequestBody PersonDto personDto) { |
| | | return Result.success(userService.addPersonUser(personDto)); |
| | | } |
| | | |
| | | @ValueAuth |
| | | @ApiOperation("通过员工号获取员工") |
| | | @PostMapping(value = "/selectPersonUser") |
| | | public Result<?> selectPersonUser(String code) { |
| | | Person person = headerToken.selectPersonUser(code); |
| | | return Result.success(person); |
| | | } |
| | | |
| | | } |