| | |
| | | import com.moon.server.entity.all.ResponseMsg; |
| | | import com.moon.server.entity.sys.ResEntity; |
| | | import com.moon.server.entity.sys.UserEntity; |
| | | import com.moon.server.helper.StringHelper; |
| | | import com.moon.server.service.all.PermsService; |
| | | import com.moon.server.service.all.UploadAttachService; |
| | | import com.moon.server.service.sys.ResService; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 资源管理 |
| | | * @author WWW |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | @Api(tags = "运维管理\\资源管理") |
| | | @RestController |
| | | @RequestMapping("/res") |
| | |
| | | private final static String TAB_NAME = "lf.sys_res"; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", required = false, example = "") |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(String name) { |
| | | try { |
| | | int count = resService.selectCount(name); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", 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 = "/selectByPage") |
| | | public ResponseMsg<List<ResEntity>> selectByPage(String name, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "category", value = "服务类别", dataType = "Integer", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "type", value = "服务类型", dataType = "Integer", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "data", value = "数据类型", dataType = "Integer", 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<ResEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<ResEntity>> selectByPageAndCount(String name, Integer status, Integer category, Integer type, Integer data, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = resService.selectCount(name); |
| | | int count = resService.selectCount(name, status, category, type, data); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1)); |
| | | List<ResEntity> rs = resService.selectByPage(name, status, category, type, data, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询所有") |
| | | @GetMapping(value = "/selectAll") |
| | | public ResponseMsg<List<ResEntity>> selectAll() { |
| | | try { |
| | | List<ResEntity> list = resService.selectAll(); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1") |
| | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setCreateUser(ue.getId()); |
| | | entity.setDepid(ue.getDepcode()); |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = resService.insert(entity); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | if (ue != null) { |
| | | for (ResEntity entity : list) { |
| | | entity.setCreateUser(ue.getId()); |
| | | entity.setDepid(ue.getDepcode()); |
| | | } |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = resService.inserts(list); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @GetMapping(value = "/delete") |
| | | public ResponseMsg<Integer> delete(int id) { |
| | | try { |
| | | permsService.clearPermsCache(); |
| | | int count = resService.delete(id); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | return fail("id数组不能为空", -1); |
| | | } |
| | | |
| | | int count = resService.deletes(ids); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | permsService.clearPermsCache(); |
| | | String strs = StringHelper.join(ids, ","); |
| | | int count = resService.deletes(strs); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | entity.setDepid(ue.getDepcode()); |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = resService.update(entity); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | if (ue != null) { |
| | | for (ResEntity entity : list) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | entity.setDepid(ue.getDepcode()); |
| | | } |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = resService.updates(list); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |