123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- package com.tianhu.system.controller;
- import com.tianhu.common.core.constant.SalaryConstants;
- import com.tianhu.common.core.utils.CommonUtil;
- import com.tianhu.common.core.utils.StringUtils;
- import com.tianhu.common.core.utils.poi.ExcelUtil;
- import com.tianhu.common.core.web.controller.BaseController;
- import com.tianhu.common.core.web.domain.AjaxResult;
- import com.tianhu.common.core.web.page.TableDataInfo;
- import com.tianhu.common.log.annotation.Log;
- import com.tianhu.common.log.enums.BusinessType;
- import com.tianhu.common.security.annotation.PreAuthorize;
- import com.tianhu.common.security.service.TokenService;
- import com.tianhu.system.api.domain.SysUser;
- import com.tianhu.system.api.model.LoginUser;
- import com.tianhu.system.domain.OwnSysUser;
- import com.tianhu.system.service.*;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * 用户信息
- *
- * @author tianhu
- */
- @RestController
- @RequestMapping("/ownUser")
- public class OwnSysUserController extends BaseController
- {
- @Autowired
- private IOwnSysUserService ownSysUserService;
- @Autowired
- private ISysUserService iSysUserService;
- @Autowired
- private TokenService tokenService;
- /**
- * 获取用户列表
- */
- @PreAuthorize(hasPermi = "system:ownUser:list")
- @GetMapping("/list")
- public TableDataInfo list(OwnSysUser ownSysUser)
- {
- startPage();
- //获取用户信息
- LoginUser userInfo = tokenService.getLoginUser();
- SysUser users = userInfo.getSysUser();
- String companyId = users.getCompanyId();
- if(ownSysUser.getParams() != null ){
- ownSysUser.setBeginTime(CommonUtil.objToString(ownSysUser.getParams().get("beginTime")));
- ownSysUser.setEndTime(CommonUtil.objToString(ownSysUser.getParams().get("endTime")));
- }
- //判断是否为运维管理员 000000:代表运维管理员
- if(!SalaryConstants.OPEX.equals(companyId)){
- ownSysUser.setCompanyId(companyId);
- }else{
- //未选择其他一级部门则只显示自己企业人员
- if(ownSysUser.getDeptId() == null){
- ownSysUser.setCompanyId(companyId);
- }
- }
- List<OwnSysUser> list = ownSysUserService.selectUserList(ownSysUser);
- return getDataTable(list);
- }
- /**
- * 导出用户列表
- */
- @PreAuthorize(hasPermi = "system:ownUser:export")
- @Log(title = "用户", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response,
- @RequestParam(required=false) String deptId,
- @RequestParam(required=false) String userName,
- @RequestParam(required=false) String nickName,
- @RequestParam(required=false) String phonenumber,
- @RequestParam(required=false) String status,
- @RequestParam (required = false) Map dateRange) throws IOException
- {
- OwnSysUser ownSysUser = new OwnSysUser();
- if(!CommonUtil.isEmpty(userName)){
- ownSysUser.setUserName(userName);
- }
- if(!CommonUtil.isEmpty(nickName)){
- ownSysUser.setNickName(nickName);
- }
- if(!CommonUtil.isEmpty(status)){
- ownSysUser.setStatus(status);
- }
- if(!CommonUtil.isEmpty(deptId)){
- ownSysUser.setDeptId(Long.valueOf(deptId));
- }
- ownSysUser.setBeginTime(CommonUtil.objToString(dateRange.get("0")));
- ownSysUser.setEndTime(CommonUtil.objToString(dateRange.get("1")));
- //获取用户信息
- LoginUser userInfo = tokenService.getLoginUser();
- SysUser users = userInfo.getSysUser();
- String companyId = users.getCompanyId();
- //判断是否为运维管理员 000000:代表运维管理员
- if(!SalaryConstants.OPEX.equals(companyId)){
- ownSysUser.setCompanyId(companyId);
- }
- List<OwnSysUser> list = ownSysUserService.selectUserList(ownSysUser);
- ExcelUtil<OwnSysUser> util = new ExcelUtil<OwnSysUser>(OwnSysUser.class);
- util.exportExcel(response, list, "inf");
- }
- @GetMapping("/listUser/{userId}")
- public AjaxResult listUser(@PathVariable(value = "userId", required = false) Long userId){
- //查询当前操作员
- LoginUser userInfo = tokenService.getLoginUser();
- SysUser use = userInfo.getSysUser();
- SysUser user =null;
- if("000000".equals(userId)){
- user = iSysUserService.selectUserById(userId);
- }
- //获取企业
- String ssCompanyId = use.getCompanyId();
- Map map = new HashMap();
- if(!SalaryConstants.OPEX.equals(ssCompanyId)) {
- map.put("ssCompanyId",ssCompanyId);
- }
- if(StringUtils.isNotNull(user)){
- map.put("staffId",user.getStaffCode());
- }
- List<Map> list = ownSysUserService.selectUser(map);
- return AjaxResult.success(list);
- }
- }
|