package com.moon.server.controller.all;
|
|
import com.moon.server.annotation.SysLog;
|
import com.moon.server.entity.all.ResponseMsg;
|
import com.moon.server.entity.data.DirEntity;
|
import com.moon.server.entity.sys.RoleEntity;
|
import com.moon.server.entity.sys.UserEntity;
|
import com.moon.server.helper.StringHelper;
|
import com.moon.server.service.data.DirService;
|
import com.moon.server.service.sys.RoleService;
|
import com.moon.server.service.sys.TokenService;
|
import com.moon.server.service.sys.UserService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
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 javax.servlet.http.HttpServletRequest;
|
import java.util.List;
|
|
/**
|
* FME接口控制器
|
* @author WWW
|
*/
|
@Api(tags = "系统对接\\FME")
|
@RestController
|
@RequestMapping("/fmeIt")
|
public class FmeItController extends BaseController {
|
@Autowired
|
UserService userService;
|
|
@Autowired
|
RoleService roleService;
|
|
@Autowired
|
TokenService tokenService;
|
|
@Autowired
|
DirService dirService;
|
|
@SysLog()
|
@ApiOperation(value = "查询是/否为管理员")
|
@GetMapping(value = "/selectForIsAdmin")
|
public ResponseMsg<Boolean> selectForIsAdmin(HttpServletRequest req) {
|
try {
|
UserEntity ue = tokenService.getCurrentUser(req);
|
if (ue == null) {
|
return fail("用户未登录", false);
|
}
|
|
Integer rows = userService.selectForIsAdmin(ue.getId());
|
|
return success("成功", rows > 0);
|
} catch (Exception ex) {
|
return fail(ex, false);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "根据ID查询")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectUser")
|
public ResponseMsg<UserEntity> selectUser(int id) {
|
try {
|
UserEntity userEntity = userService.selectUser(id);
|
|
return success(userEntity);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "根据用户ID查询")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "uid", value = "用户ID", dataType = "String", paramType = "query", example = "admin")
|
})
|
@GetMapping(value = "/selectByUid")
|
public ResponseMsg<UserEntity> selectByUid(String uid) {
|
try {
|
if (StringHelper.isEmpty(uid)) {
|
fail("用户ID不能为空", null);
|
}
|
|
UserEntity userEntity = userService.selectByUid(uid);
|
|
return success(userEntity);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "分页查询用户并返回记录数")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "室"),
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
|
@ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectByPageForUser")
|
public ResponseMsg<List<UserEntity>> selectByPageForUser(String uname, Integer pageSize, Integer pageIndex) {
|
try {
|
if (pageSize < 1 || pageIndex < 1) {
|
return fail("每页页数或分页数小于1", null);
|
}
|
int count = userService.selectCount(uname, null);
|
if (count == 0) {
|
return success(0, null);
|
}
|
List<UserEntity> rs = userService.selectByPage(uname, null, pageSize, pageSize * (pageIndex - 1));
|
|
return success(count, rs);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询是/否为管理员")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id", value = "用户ID", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectIsAdmin")
|
public ResponseMsg<Boolean> selectIsAdmin(Integer id) {
|
try {
|
UserEntity ue = userService.selectUser(id);
|
if (ue == null) {
|
return fail("用户不存在", false);
|
}
|
|
Integer rows = userService.selectForIsAdmin(ue.getId());
|
|
return success("成功", rows > 0);
|
} catch (Exception ex) {
|
return fail(ex, false);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询管理员用户")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "type", value = "管理员类别", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectAdminUsers")
|
public ResponseMsg<Object> selectAdminUsers(Integer type) {
|
try {
|
if (null == type || type < 1) {
|
return fail("管理员类别不能为空或小于1", false);
|
}
|
|
List<UserEntity> rs = userService.selectAdminUsers(type);
|
|
return success(rs);
|
} catch (Exception ex) {
|
return fail(ex, false);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "根据用户ID查询角色")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id", value = "用户ID", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectRoleByUserId")
|
public ResponseMsg<Object> selectRoleByUserId(Integer id) {
|
try {
|
if (null == id || id < 1) {
|
return fail("用户ID不能为空或小于1", false);
|
}
|
|
List<RoleEntity> rs = userService.selectRoleByUserId(id);
|
|
return success(rs);
|
} catch (Exception ex) {
|
return fail(ex, false);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "根据角色查询用户")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id", value = "角色ID", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectUserByRoleId")
|
public ResponseMsg<Object> selectUserByRoleId(Integer id) {
|
try {
|
if (null == id || id < 1) {
|
return fail("用户ID不能为空或小于1", false);
|
}
|
|
List<UserEntity> rs = userService.selectUserByRoleId(id);
|
|
return success(rs);
|
} catch (Exception ex) {
|
return fail(ex, false);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "根据ID查询")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectRole")
|
public ResponseMsg<RoleEntity> selectRole(int id) {
|
try {
|
RoleEntity roleEntity = roleService.selectRole(id);
|
|
return success(roleEntity);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "分页查询角色并返回记录数")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "Admin"),
|
@ApiImplicitParam(name = "depid", value = "单位ID", dataType = "Integer", paramType = "query", example = "1"),
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
|
@ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectByPageForRole")
|
public ResponseMsg<List<RoleEntity>> selectByPageForRole(String name, Integer depid, Integer pageSize, Integer pageIndex) {
|
try {
|
if (pageSize < 1 || pageIndex < 1) {
|
return fail("每页页数或分页数小于1", null);
|
}
|
|
int count = roleService.selectCount(name, depid);
|
if (count == 0) {
|
return success(0, null);
|
}
|
|
List<RoleEntity> rs = roleService.selectByPage(name, depid, pageSize, pageSize * (pageIndex - 1));
|
|
return success(count, rs);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询根目录")
|
@GetMapping(value = "/selectDirRoot")
|
public ResponseMsg<List<DirEntity>> selectDirRoot() {
|
try {
|
List<DirEntity> list = dirService.selectDirRoot();
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询项目")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "西")
|
})
|
@GetMapping(value = "/selectProject")
|
public ResponseMsg<List<DirEntity>> selectProject(String name) {
|
try {
|
List<DirEntity> list = dirService.selectProject(name);
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询项目目录树")
|
@GetMapping(value = "/selectDirsForPrj")
|
public ResponseMsg<List<DirEntity>> selectDirsForPrj() {
|
try {
|
List<DirEntity> list = dirService.selectDirsForPrj();
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
}
|