¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.lf.server.controller.all; |
| | | |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.sys.RoleEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.service.sys.RoleService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import com.lf.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; |
| | | |
| | | @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.getMessage(), 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.getMessage(), 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.getMessage(), 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 = "/selectByPageAndCount") |
| | | public ResponseMsg<List<UserEntity>> selectByPageAndCount(String uname, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | int count = userService.selectCount(uname); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | List<UserEntity> rs = userService.selectByPage(uname, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), 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.getMessage(), 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.getMessage(), 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.getMessage(), 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.getMessage(), 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.getMessage(), 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 = "/selectByPageAndCount") |
| | | public ResponseMsg<List<RoleEntity>> selectByPageAndCount(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.getMessage(), null); |
| | | } |
| | | } |
| | | } |