| | |
| | | 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.service.all.PermsService; |
| | | import com.moon.server.service.all.UploadAttachService; |
| | | import com.moon.server.service.data.DownloadService; |
| | | import com.moon.server.service.sys.ResService; |
| | | import com.moon.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 资源表 |
| | | * @author SWS |
| | | * @date 2022-09.28 |
| | | * 资源管理 |
| | | * @author WWW |
| | | */ |
| | | @Api(tags = "运维管理\\资源管理") |
| | | @RestController |
| | |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | PermsService permsService; |
| | | |
| | | @Autowired |
| | | DownloadService downloadService; |
| | | |
| | | @Autowired |
| | | UploadAttachService uploadAttachService; |
| | | |
| | | private final static String TAB_NAME = "lf.sys_res"; |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", required = false, example = "sys_res") |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", required = false, example = "") |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(String name) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "sys_res"), |
| | | @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") |
| | | }) |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "sys_res"), |
| | | @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") |
| | | }) |
| | |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectById") |
| | | public ResponseMsg<ResEntity> selectById(int id) { |
| | | try { |
| | | ResEntity entity = resService.selectById(id); |
| | | |
| | | return success(entity); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "ResEntity", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "ResEntity", paramType = "body") |
| | | }) |
| | | @PostMapping(value = "/insertRes", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertRes(@RequestBody ResEntity entity, HttpServletRequest req) { |
| | | @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insert(@RequestBody ResEntity entity, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setCreateUser(ue.getId()); |
| | | } |
| | | |
| | | int count = resService.insertRes(entity); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | int count = resService.insert(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入多条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "List<ResEntity>", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "ResEntity", paramType = "body") |
| | | }) |
| | | @PostMapping(value = "/insertRess", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertRess(@RequestBody List<ResEntity> list, HttpServletRequest req) { |
| | | @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> inserts(@RequestBody List<ResEntity> list, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | int count = resService.insertRess(list); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | int count = resService.inserts(list); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/deleteRes") |
| | | public ResponseMsg<Integer> deleteRes(int id) { |
| | | @GetMapping(value = "/delete") |
| | | public ResponseMsg<Integer> delete(int id) { |
| | | try { |
| | | int count = resService.deleteRes(id); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | int count = resService.delete(id); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "删除多条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "List<Integer>", paramType = "query", example = "1,2") |
| | | @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", example = "1,2") |
| | | }) |
| | | @GetMapping(value = "/deleteRess") |
| | | public ResponseMsg<Integer> deleteRess(@RequestParam List<Integer> ids) { |
| | | @GetMapping(value = "/deletes") |
| | | public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) { |
| | | try { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return fail("id数组不能为空", -1); |
| | | } |
| | | |
| | | int count = resService.deleteRess(ids); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | int count = resService.deletes(ids); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "更新一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "ResEntity", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "ResEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/updateRes", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updateRes(@RequestBody ResEntity entity, HttpServletRequest req) { |
| | | @PostMapping(value = "/update", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> update(@RequestBody ResEntity entity, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | |
| | | int count = resService.updateRes(entity); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | int count = resService.update(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询") |
| | | @ApiOperation(value = "更新多条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "ResEntity", paramType = "body") |
| | | }) |
| | | @GetMapping(value = "/selectRes") |
| | | public ResponseMsg<ResEntity> selectRes(int id) { |
| | | @ResponseBody |
| | | @PostMapping(value = "/updates", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updates(@RequestBody List<ResEntity> list, HttpServletRequest req) { |
| | | try { |
| | | ResEntity resEntity = resService.selectRes(id); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | for (ResEntity entity : list) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | } |
| | | |
| | | return success(resEntity); |
| | | int count = resService.updates(list); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询所有") |
| | | @GetMapping(value = "/selectResAll") |
| | | public ResponseMsg<List<ResEntity>> selectResAll() { |
| | | try { |
| | | List<ResEntity> list = resService.selectResAll(); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.moon.server.entity.sys; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | import java.sql.Timestamp; |
| | | |
| | | /** |
| | | * @author user |
| | | * 资源 |
| | | * @author WWW |
| | | */ |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class ResEntity implements Serializable { |
| | | private static final long serialVersionUID = 9047079519693255710L; |
| | | private static final long serialVersionUID = -286579305905187168L; |
| | | |
| | | private int id; |
| | | |
| | | private String name; |
| | | |
| | | private String server; |
| | | private int type; |
| | | |
| | | private String source; |
| | | private int status; |
| | | |
| | | private int depid; |
| | | private String manufacturer; |
| | | |
| | | private String depName; |
| | | private String url; |
| | | |
| | | private int dirid; |
| | | private String test; |
| | | |
| | | private String dirName; |
| | | |
| | | private String code; |
| | | private String proxy; |
| | | |
| | | private String descr; |
| | | |
| | | private String depid; |
| | | |
| | | private String dirid; |
| | | |
| | | private String img; |
| | | |
| | | private int createUser; |
| | | private String guid; |
| | | |
| | | private String createName; |
| | | private int createUser; |
| | | |
| | | private Timestamp createTime; |
| | | |
| | | private int updateUser; |
| | | |
| | | private String updateName; |
| | | |
| | | private Timestamp updateTime; |
| | | |
| | | private String bak; |
| | | |
| | | private String createName; |
| | | |
| | | private String updateName; |
| | | |
| | | private String fileGuid; |
| | | public ResEntity() { |
| | | } |
| | | |
| | | public int getId() { |
| | | return id; |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getServer() { |
| | | return server; |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setServer(String server) { |
| | | this.server = server; |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getSource() { |
| | | return source; |
| | | public int getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public void setSource(String source) { |
| | | this.source = source; |
| | | public void setStatus(int status) { |
| | | this.status = status; |
| | | } |
| | | |
| | | public int getDepid() { |
| | | return depid; |
| | | public String getManufacturer() { |
| | | return manufacturer; |
| | | } |
| | | |
| | | public void setDepid(int depid) { |
| | | this.depid = depid; |
| | | public void setManufacturer(String manufacturer) { |
| | | this.manufacturer = manufacturer; |
| | | } |
| | | |
| | | public String getDepName() { |
| | | return depName; |
| | | public String getUrl() { |
| | | return url; |
| | | } |
| | | |
| | | public void setDepName(String depName) { |
| | | this.depName = depName; |
| | | public void setUrl(String url) { |
| | | this.url = url; |
| | | } |
| | | |
| | | public int getDirid() { |
| | | return dirid; |
| | | public String getTest() { |
| | | return test; |
| | | } |
| | | |
| | | public void setDirid(int dirid) { |
| | | this.dirid = dirid; |
| | | public void setTest(String test) { |
| | | this.test = test; |
| | | } |
| | | |
| | | public String getDirName() { |
| | | return dirName; |
| | | public String getProxy() { |
| | | return proxy; |
| | | } |
| | | |
| | | public void setDirName(String dirName) { |
| | | this.dirName = dirName; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | public void setProxy(String proxy) { |
| | | this.proxy = proxy; |
| | | } |
| | | |
| | | public String getDescr() { |
| | |
| | | this.descr = descr; |
| | | } |
| | | |
| | | public String getDepid() { |
| | | return depid; |
| | | } |
| | | |
| | | public void setDepid(String depid) { |
| | | this.depid = depid; |
| | | } |
| | | |
| | | public String getDirid() { |
| | | return dirid; |
| | | } |
| | | |
| | | public void setDirid(String dirid) { |
| | | this.dirid = dirid; |
| | | } |
| | | |
| | | public String getImg() { |
| | | return img; |
| | | } |
| | |
| | | this.img = img; |
| | | } |
| | | |
| | | public String getGuid() { |
| | | return guid; |
| | | } |
| | | |
| | | public void setGuid(String guid) { |
| | | this.guid = guid; |
| | | } |
| | | |
| | | public int getCreateUser() { |
| | | return createUser; |
| | | } |
| | | |
| | | public void setCreateUser(int createUser) { |
| | | this.createUser = createUser; |
| | | } |
| | | |
| | | public String getCreateName() { |
| | | return createName; |
| | | } |
| | | |
| | | public void setCreateName(String createName) { |
| | | this.createName = createName; |
| | | } |
| | | |
| | | public Timestamp getCreateTime() { |
| | |
| | | this.updateUser = updateUser; |
| | | } |
| | | |
| | | public String getUpdateName() { |
| | | return updateName; |
| | | } |
| | | |
| | | public void setUpdateName(String updateName) { |
| | | this.updateName = updateName; |
| | | } |
| | | |
| | | public Timestamp getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | |
| | | this.bak = bak; |
| | | } |
| | | |
| | | public String getFileGuid() { |
| | | return fileGuid; |
| | | public String getCreateName() { |
| | | return createName; |
| | | } |
| | | |
| | | public void setFileGuid(String fileGuid) { |
| | | this.fileGuid = fileGuid; |
| | | public void setCreateName(String createName) { |
| | | this.createName = createName; |
| | | } |
| | | |
| | | public String getUpdateName() { |
| | | return updateName; |
| | | } |
| | | |
| | | public void setUpdateName(String updateName) { |
| | | this.updateName = updateName; |
| | | } |
| | | } |
| | |
| | | |
| | | private static final Log log = LogFactory.getLog(AuthInterceptor.class); |
| | | |
| | | private static final String NO_TOKEN = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.TOKEN_ERROR, "找不到令牌")); |
| | | public static final String NO_TOKEN = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.TOKEN_ERROR, "找不到令牌")); |
| | | |
| | | private static final String NO_LOGIN = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NO_LOGIN_ERROR, "用户未登录")); |
| | | public static final String NO_LOGIN = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NO_LOGIN_ERROR, "用户未登录")); |
| | | |
| | | private static final String USER_LOCK = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.USER_LOCK_ERROR, "用户ID已禁用")); |
| | | public static final String USER_LOCK = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.USER_LOCK_ERROR, "用户ID已禁用")); |
| | | |
| | | private static final String NO_AUTH = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NO_AUTH_ERROR, "无权限访问")); |
| | | public static final String NO_AUTH = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NO_AUTH_ERROR, "无权限访问")); |
| | | |
| | | private static final String IP_NULL = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.UNAUTHORIZED, "IP地址为空")); |
| | | public static final String IP_NULL = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.UNAUTHORIZED, "IP地址为空")); |
| | | |
| | | private static final String BLACK_LIST = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.UNAUTHORIZED, "该IP入黑名单")); |
| | | public static final String BLACK_LIST = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.UNAUTHORIZED, "该IP入黑名单")); |
| | | |
| | | private static final String ILLEGAL_TOKEN = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.UNAUTHORIZED, "令牌来源非法")); |
| | | public static final String ILLEGAL_TOKEN = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.UNAUTHORIZED, "令牌来源非法")); |
| | | |
| | | public AuthInterceptor(SysService sysService) { |
| | | this.sysService = sysService; |
| | |
| | | return WebHelper.writeStr2Page(response, NO_TOKEN); |
| | | } |
| | | |
| | | // 3.获取用户令牌 |
| | | // 3.获取用户 |
| | | UserEntity ue = sysService.tokenService.getCurrentUser(request); |
| | | if (ue == null) { |
| | | return WebHelper.writeStr2Page(response, NO_LOGIN); |
| | |
| | | package com.moon.server.interceptor; |
| | | |
| | | import com.moon.server.entity.all.StaticData; |
| | | import com.moon.server.entity.sys.TokenEntity; |
| | | import com.moon.server.entity.sys.UserEntity; |
| | | import com.moon.server.helper.StringHelper; |
| | | import com.moon.server.helper.WebHelper; |
| | | import com.moon.server.service.all.SysService; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.*; |
| | | import javax.servlet.annotation.WebFilter; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 代理过滤器 |
| | |
| | | */ |
| | | @WebFilter(urlPatterns = {"/proxy/*"}) |
| | | public class ProxyFilter implements Filter { |
| | | @Resource |
| | | private SysService sysService; |
| | | |
| | | @Override |
| | | public void init(FilterConfig filterConfig) { |
| | | } |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) { |
| | | // |
| | | HttpServletRequest req = (HttpServletRequest) request; |
| | | HttpServletResponse res = (HttpServletResponse) response; |
| | | if (!check(req, res)) { |
| | | return; |
| | | } |
| | | |
| | | int i = 0; |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | } |
| | | |
| | | private boolean check(HttpServletRequest req, HttpServletResponse res) { |
| | | // 2.获取令牌 |
| | | String token = WebHelper.getToken(req); |
| | | if (StringHelper.isNull(token)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.NO_TOKEN); |
| | | } |
| | | |
| | | // 3.获取用户 |
| | | UserEntity ue = sysService.tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.NO_LOGIN); |
| | | } |
| | | |
| | | // 4.获取IP |
| | | String ip = WebHelper.getIpAddress(req); |
| | | if (StringHelper.isEmpty(ip)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.IP_NULL); |
| | | } |
| | | |
| | | // 5.检查黑名单 |
| | | if (!checkBlackList(ip, req)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.BLACK_LIST); |
| | | } |
| | | |
| | | // 6.admin跳过权限检测 |
| | | if (StaticData.ADMIN.equals(ue.getUid())) { |
| | | return true; |
| | | } |
| | | |
| | | // 7.检查白名单 |
| | | if (!checkWhiteList(ip, req)) { |
| | | // 检查IP一致性 |
| | | if (!checkIpSource(ip, token)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.ILLEGAL_TOKEN); |
| | | } |
| | | } |
| | | |
| | | // 8.检查用户ID是否禁用 |
| | | if (sysService.tokenService.isUidDisable(ue)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.USER_LOCK); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 检查黑名单 |
| | | */ |
| | | private boolean checkBlackList(String ip, HttpServletRequest request) { |
| | | List<String> blackList = sysService.blacklistService.selectIpList(1); |
| | | if (blackList == null || blackList.isEmpty()) { |
| | | return true; |
| | | } |
| | | if (blackList.contains(ip)) { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 检查白名单 |
| | | */ |
| | | private boolean checkWhiteList(String ip, HttpServletRequest request) { |
| | | List<String> whiteList = sysService.blacklistService.selectIpList(2); |
| | | if (whiteList == null || whiteList.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | return whiteList.contains(ip); |
| | | } |
| | | |
| | | /** |
| | | * 检查IP一致性 |
| | | */ |
| | | private boolean checkIpSource(String ip, String token) { |
| | | TokenEntity te = sysService.tokenService.getEntityByToken(token); |
| | | |
| | | return te.getIp().equals(ip); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.moon.server.entity.sys.ResEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 资源表 |
| | | * @author sws |
| | | * @date 2022-09-28 |
| | | * 资源 |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @ResponseBody |
| | | @Repository |
| | | public interface ResMapper { |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param name 表名 |
| | | * @param name 名称 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String name); |
| | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param name 表名 |
| | | * @param name 名称 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<ResEntity> selectByPage(String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<ResEntity> selectAll(); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public ResEntity selectById(int id); |
| | | |
| | | /** |
| | | * 根据角色查询记录数 |
| | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param resEntity |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer insertRes(ResEntity resEntity); |
| | | public Integer insert(ResEntity entity); |
| | | |
| | | /** |
| | | * 插入多条 |
| | |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer insertRess(List<ResEntity> list); |
| | | public Integer inserts(List<ResEntity> list); |
| | | |
| | | /** |
| | | * 删除一条 |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public Integer deleteRes(int id); |
| | | public Integer delete(int id); |
| | | |
| | | /** |
| | | * 删除多条 |
| | |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public Integer deleteRess(List<Integer> ids); |
| | | public Integer deletes(List<Integer> ids); |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param resEntity |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer updateRes(ResEntity resEntity); |
| | | public Integer update(ResEntity entity); |
| | | |
| | | /** |
| | | * 查询单条数据 |
| | | * 更新多条 |
| | | * |
| | | * @param id |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public ResEntity selectRes(int id); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<ResEntity> selectResAll(); |
| | | |
| | | |
| | | |
| | | public Integer updates(List<ResEntity> list); |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 令牌表 |
| | | * @author sws |
| | | * @date 2022-09-28 |
| | | * 资源 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | public class ResService implements ResMapper { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ResEntity> selectAll() { |
| | | return resMapper.selectAll(); |
| | | } |
| | | |
| | | @Override |
| | | public ResEntity selectById(int id) { |
| | | return resMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectCountForRole(Integer roleid) { |
| | | return resMapper.selectCountForRole(roleid); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer insertRes(ResEntity resEntity) { |
| | | return resMapper.insertRes(resEntity); |
| | | public Integer insert(ResEntity entity) { |
| | | return resMapper.insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public Integer insertRess(List<ResEntity> resEntity) { |
| | | return resMapper.insertRess(resEntity); |
| | | public Integer inserts(List<ResEntity> list) { |
| | | return resMapper.inserts(list); |
| | | } |
| | | |
| | | @Override |
| | | public Integer deleteRes(int id) { |
| | | return resMapper.deleteRes(id); |
| | | public Integer delete(int id) { |
| | | return resMapper.delete(id); |
| | | } |
| | | |
| | | @Override |
| | | public Integer deleteRess(List<Integer> ids) { |
| | | return resMapper.deleteRess(ids); |
| | | public Integer deletes(List<Integer> ids) { |
| | | return resMapper.deletes(ids); |
| | | } |
| | | |
| | | @Override |
| | | public Integer updateRes(ResEntity resEntity) { |
| | | return resMapper.updateRes(resEntity); |
| | | public Integer update(ResEntity entity) { |
| | | return resMapper.update(entity); |
| | | } |
| | | |
| | | @Override |
| | | public ResEntity selectRes(int id) { |
| | | return resMapper.selectRes(id); |
| | | public Integer updates(List<ResEntity> list) { |
| | | return resMapper.updates(list); |
| | | } |
| | | |
| | | @Override |
| | | public List<ResEntity> selectResAll() { |
| | | return resMapper.selectResAll(); |
| | | } |
| | | |
| | | } |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moon.server.mapper.sys.ResMapper"> |
| | | <select id="selectCount" resultType="java.lang.Integer"> |
| | | select count(*) from lf.sys_res |
| | |
| | | </select> |
| | | |
| | | <select id="selectByPage" resultType="com.moon.server.entity.sys.ResEntity"> |
| | | select a.*,fn_rec_query(a.depid, 'dep') depName,fn_rec_query(a.dirid, 'dir') dirName,fn_uname(a.create_user) createName,fn_uname(a.update_user) updateName from lf.sys_res a |
| | | select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName from lf.sys_res a |
| | | <where> |
| | | <if test="name != null"> |
| | | upper(a.name) like #{name} |
| | |
| | | </where> |
| | | order by a.id desc |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectAll" resultType="com.moon.server.entity.sys.ResEntity"> |
| | | select * from lf.sys_res order by id desc; |
| | | </select> |
| | | |
| | | <select id="selectById" resultType="com.moon.server.entity.sys.ResEntity"> |
| | | select * from lf.sys_res where id = #{id} |
| | | </select> |
| | | |
| | | <select id="selectCountForRole" resultType="java.lang.Integer"> |
| | |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectResAll" resultType="com.moon.server.entity.sys.ResEntity"> |
| | | select * from lf.sys_res order by id desc |
| | | </select> |
| | | |
| | | <select id="selectRes" resultType="com.moon.server.entity.sys.ResEntity"> |
| | | select * from lf.sys_res where id = #{id} |
| | | </select> |
| | | |
| | | <insert id="insertRes" parameterType="com.moon.server.entity.data.DictEntity"> |
| | | insert into lf.sys_res |
| | | (name,server,source,depid,dirid,code,descr,img,create_user,create_time,bak) |
| | | values |
| | | (#{name},#{server},#{source},#{depid},#{dirid},#{code},#{descr},#{img},#{createUser},now(),#{bak}); |
| | | <insert id="insert" parameterType="com.moon.server.entity.sys.ResEntity"> |
| | | insert into lf.sys_res |
| | | (name,type,status,manufacturer,url,test,proxy,descr,depid,dirid,img,guid,create_user,create_time,bak) |
| | | values |
| | | (#{name},#{type},#{status},#{manufacturer},#{url},#{test},#{proxy},#{descr},#{depid},#{dirid},#{img},#{guid},#{createUser},now(),#{bak}) |
| | | </insert> |
| | | |
| | | <insert id="insertRess"> |
| | | insert into lf.sys_res |
| | | (name,server,source,depid,dirid,code,descr,img,create_user,create_time,bak) |
| | | values |
| | | <insert id="inserts"> |
| | | insert into lf.sys_res |
| | | (name,type,status,manufacturer,url,test,proxy,descr,depid,dirid,img,guid,create_user,create_time,bak) |
| | | values |
| | | <foreach collection="list" item="item" index="index" separator=","> |
| | | #{item.name},#{item.server},#{item.source},#{item.depid},#{item.dirid},#{item.code},#{item.descr},#{item.img},#{item.createUser},now(),#{item.bak}) |
| | | (#{item.name},#{item.type},#{item.status},#{item.manufacturer},#{item.url},#{item.test},#{item.proxy},#{item.descr},#{item.depid},#{item.dirid},#{item.img},#{item.guid},#{item.createUser},now(),#{item.bak}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <delete id="deleteRes"> |
| | | delete from lf.sys_role_res where resid = #{id}; |
| | | delete from lf.sys_res where id = #{id}; |
| | | <delete id="delete"> |
| | | delete from lf.sys_res where id = #{id} |
| | | </delete> |
| | | |
| | | <delete id="deleteRess"> |
| | | delete from lf.sys_role_res where resid in |
| | | <foreach item="id" collection="ids" index="index" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach>; |
| | | <delete id="deletes"> |
| | | delete from lf.sys_res where id in |
| | | <foreach item="id" collection="ids" index="index" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach>; |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <update id="updateRes"> |
| | | update lf.sys_res set name=#{name},server=#{server},source=#{source},depid=#{depid},dirid=#{dirid},code=#{code},descr=#{descr},img=#{img}, |
| | | update_user=#{updateUser},update_time=now(),bak=#{bak} where id=#{id} |
| | | <update id="update"> |
| | | update lf.sys_res |
| | | set name=#{name},type=#{type},status=#{status},manufacturer=#{manufacturer},url=#{url},test=#{test},proxy=#{proxy},descr=#{descr},depid=#{depid},dirid=#{dirid},img=#{img},guid=#{guid},update_user=#{updateUser},update_time=now(),bak=#{bak} |
| | | where id=#{id} |
| | | </update> |
| | | |
| | | <update id="updates"> |
| | | <foreach collection="list" item="item" index="index" separator=";"> |
| | | update lf.sys_res |
| | | set name=#{item.name},type=#{item.type},status=#{item.status},manufacturer=#{item.manufacturer},url=#{item.url},test=#{item.test},proxy=#{item.proxy},descr=#{item.descr},depid=#{item.depid},dirid=#{item.dirid},img=#{item.img},guid=#{item.guid},update_user=#{item.updateUser},update_time=now(),bak=#{item.bak} |
| | | where id = #{item.id} |
| | | </foreach> |
| | | </update> |
| | | </mapper> |