diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/InterTableController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/InterTableController.java new file mode 100644 index 0000000..509c005 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/InterTableController.java @@ -0,0 +1,182 @@ +package com.hchyun.generator.controller; + +import java.io.Serializable; +import java.util.List; +import java.util.regex.Pattern; + + +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.core.controller.HcyBaseController; +import com.hchyun.common.utils.ServerResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.hchyun.common.annotation.Log; +import com.hchyun.common.core.entity.AjaxResult; +import com.hchyun.common.enums.BusinessType; +import com.hchyun.generator.entity.InterTable; +import com.hchyun.generator.service.InterTableService; +import com.hchyun.common.utils.poi.ExcelUtil; +import com.hchyun.common.core.page.TableDataInfo; + +/** + * 接口信息Controller + * + * @author hchyun + * @date 2021-01-25 + */ +@Api(value = "接口信息管理",tags = "接口信息管理") +@RestController +@RequestMapping("/generator/intertable") +public class InterTableController extends HcyBaseController { + protected final Logger logger = LoggerFactory.getLogger(InterTableController.class); + + @Autowired + private InterTableService interTableService; + + /** + * 查询接口信息列表 + */ + @ApiOperation("查询接口信息列表") + @PreAuthorize("@ss.hasPermi('generator:intertable:list')") + @GetMapping("/list") + public Serializable list(InterTable interTable) { + try { + startPage(); + ServerResult> serverResult = interTableService.selectInterTableList(interTable); + if (serverResult.isStart()) { + return getDataTable(serverResult.getData()); + } else { + return AjaxResult.info(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 导出接口信息列表 + */ + @ApiOperation("导出接口信息列表") + @PreAuthorize("@ss.hasPermi('generator:intertable:export')") + @Log(title = "接口信息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(InterTable interTable) { + try { + ServerResult> serverResult = interTableService.selectInterTableList(interTable); + ExcelUtil util = new ExcelUtil(InterTable. class); + if (serverResult.isStart()) { + return util.exportExcel(serverResult.getData(), "intertable"); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 获取接口信息详细信息 + */ + @ApiOperation("获取接口信息详细信息") + @ApiImplicitParam(name = "id" , value = "接口信息id" , required = true, dataType = "Long" , paramType = "path") + @PreAuthorize("@ss.hasPermi('generator:intertable:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + try { + ServerResult serverResult = interTableService.selectInterTableById(id); + if (serverResult.isStart()) { + return AjaxResult.success(serverResult.getData()); + } else { + return AjaxResult.info(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 新增接口信息 + */ + @ApiOperation("新增接口信息") + @ApiImplicitParam(name = "interTable" , value = "新增接口信息信息" , dataType = "InterTable") + @PreAuthorize("@ss.hasPermi('generator:intertable:add')") + @Log(title = "接口信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody InterTable interTable) { + try { + ServerResult serverResult = interTableService.insertInterTable(interTable); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 修改接口信息 + */ + @ApiOperation("修改接口信息") + @ApiImplicitParam(name = "interTable" , value = "修改接口信息信息" , dataType = "InterTable") + @PreAuthorize("@ss.hasPermi('generator:intertable:edit')") + @Log(title = "接口信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody InterTable interTable) { + try { + + ServerResult serverResult = interTableService.updateInterTable(interTable); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 删除接口信息 + */ + @ApiOperation("删除接口信息") + @ApiImplicitParam(name = "ids" , value = "接口信息ids" , required = true, dataType = "Long" , paramType = "path") + @PreAuthorize("@ss.hasPermi('generator:intertable:remove')") + @Log(title = "接口信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + try { + if (ids.length<0){ + return AjaxResult.error("id不能为空!"); + } + ServerResult serverResult = interTableService.deleteInterTableByIds(ids); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } +} \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/InterTableDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/InterTableDao.java new file mode 100644 index 0000000..c59e48e --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/InterTableDao.java @@ -0,0 +1,61 @@ +package com.hchyun.generator.dao; + +import java.util.List; +import com.hchyun.generator.entity.InterTable; + +/** + * 接口信息Mapper接口 + * + * @author hchyun + * @date 2021-01-25 + */ +public interface InterTableDao +{ + /** + * 查询接口信息 + * + * @param id 接口信息ID + * @return 接口信息 + */ + InterTable selectInterTableById(Long id); + + /** + * 查询接口信息列表 + * + * @param interTable 接口信息 + * @return 接口信息集合 + */ + List selectInterTableList(InterTable interTable); + + /** + * 新增接口信息 + * + * @param interTable 接口信息 + * @return 结果 + */ + int insertInterTable(InterTable interTable); + + /** + * 修改接口信息 + * + * @param interTable 接口信息 + * @return 结果 + */ + int updateInterTable(InterTable interTable); + + /** + * 删除接口信息 + * + * @param id 接口信息ID + * @return 结果 + */ + int deleteInterTableById(Long id); + + /** + * 批量删除接口信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteInterTableByIds(Long[] ids); +} \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/InterTable.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/InterTable.java new file mode 100644 index 0000000..c17acbd --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/InterTable.java @@ -0,0 +1,150 @@ +package com.hchyun.generator.entity; + +import com.hchyun.common.annotation.Excel; +import com.hchyun.common.core.entity.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 接口信息对象 sys_inter_table + * + * @author hchyun + * @date 2021-01-25 + */ +@ApiModel("接口信息") +public class InterTable extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + @ApiModelProperty("id") + private Long id; + + /** 模块id */ + @Excel(name = "模块id") + @ApiModelProperty("模块id") + private Long mId; + + /** 类id */ + @Excel(name = "类id") + @ApiModelProperty("类id") + private Long cId; + + /** 描述 */ + @Excel(name = "描述") + @ApiModelProperty("描述") + private String itDescribe; + + /** 是否设置许可 */ + @Excel(name = "是否设置许可") + @ApiModelProperty("是否设置许可") + private Integer isPermission; + + /** 请求路径 */ + @Excel(name = "请求路径") + @ApiModelProperty("请求路径") + private String requrl; + + /** 请求方式 */ + @Excel(name = "请求方式") + @ApiModelProperty("请求方式") + private String method; + + /** 是否生成 */ + @Excel(name = "是否生成") + @ApiModelProperty("是否生成") + private Integer isGenerate; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setmId(Long mId) + { + this.mId = mId; + } + + public Long getmId() + { + return mId; + } + public void setcId(Long cId) + { + this.cId = cId; + } + + public Long getcId() + { + return cId; + } + public void setItDescribe(String itDescribe) + { + this.itDescribe = itDescribe; + } + + public String getItDescribe() + { + return itDescribe; + } + public void setIsPermission(Integer isPermission) + { + this.isPermission = isPermission; + } + + public Integer getIsPermission() + { + return isPermission; + } + public void setRequrl(String requrl) + { + this.requrl = requrl; + } + + public String getRequrl() + { + return requrl; + } + public void setMethod(String method) + { + this.method = method; + } + + public String getMethod() + { + return method; + } + public void setIsGenerate(Integer isGenerate) + { + this.isGenerate = isGenerate; + } + + public Integer getIsGenerate() + { + return isGenerate; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("mId", getmId()) + .append("cId", getcId()) + .append("itDescribe", getItDescribe()) + .append("isPermission", getIsPermission()) + .append("requrl", getRequrl()) + .append("method", getMethod()) + .append("isGenerate", getIsGenerate()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("updateTime", getUpdateTime()) + .append("updateBy", getUpdateBy()) + .toString(); + } +} \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/InterTableService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/InterTableService.java new file mode 100644 index 0000000..6db7efd --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/InterTableService.java @@ -0,0 +1,63 @@ +package com.hchyun.generator.service; + +import java.util.List; + +import com.hchyun.common.utils.ServerResult; +import com.hchyun.generator.entity.InterTable; + +/** + * 接口信息Service接口 + * + * @author hchyun + * @date 2021-01-25 + */ +public interface InterTableService +{ + /** + * 查询接口信息 + * + * @param id 接口信息ID + * @return 接口信息 + */ + ServerResult selectInterTableById(Long id); + + /** + * 查询接口信息列表 + * + * @param interTable 接口信息 + * @return 接口信息集合 + */ + ServerResult> selectInterTableList(InterTable interTable); + + /** + * 新增接口信息 + * + * @param interTable 接口信息 + * @return 结果 + */ + ServerResult insertInterTable(InterTable interTable); + + /** + * 修改接口信息 + * + * @param interTable 接口信息 + * @return 结果 + */ + ServerResult updateInterTable(InterTable interTable); + + /** + * 批量删除接口信息 + * + * @param ids 需要删除的接口信息ID + * @return 结果 + */ + ServerResult deleteInterTableByIds(Long[] ids); + + /** + * 删除接口信息信息 + * + * @param id 接口信息ID + * @return 结果 + */ + ServerResult deleteInterTableById(Long id); +} \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/InterTableServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/InterTableServiceImpl.java new file mode 100644 index 0000000..b5e8416 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/InterTableServiceImpl.java @@ -0,0 +1,156 @@ +package com.hchyun.generator.service.impl; + +import java.util.List; + +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.utils.SecurityUtils; +import com.hchyun.common.utils.ServerResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.hchyun.generator.dao.InterTableDao; +import com.hchyun.generator.entity.InterTable; +import com.hchyun.generator.service.InterTableService; + +/** + * 接口信息Service业务层处理 + * + * @author hchyun + * @date 2021-01-25 + */ +@Service +public class InterTableServiceImpl implements InterTableService { + private Logger logger = LoggerFactory.getLogger(InterTableServiceImpl.class); + + @Autowired + private InterTableDao interTableDao; + + /** + * 查询接口信息 + * + * @param id 接口信息ID + * @return 接口信息 + */ + @Override + public ServerResult selectInterTableById(Long id) { + try { + InterTable interTable = interTableDao.selectInterTableById(id); + if (interTable != null){ + return new ServerResult(true,interTable); + }else { + return new ServerResult(false, ReturnConstants.RESULT_EMPTY); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 查询接口信息列表 + * + * @param interTable 接口信息 + * @return 接口信息 + */ + @Override + public ServerResult> selectInterTableList(InterTable interTable) { + try { + List interTableList = interTableDao.selectInterTableList(interTable); + if (interTableList.size()>0){ + return new ServerResult>(true,interTableList); + }else { + return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult>(false,ReturnConstants.DB_EX); + } + } + + /** + * 新增接口信息 + * + * @param interTable 接口信息 + * @return 结果 + */ + @Override + public ServerResult insertInterTable(InterTable interTable) { + try { + interTable.setCreateBy(SecurityUtils.getUserId()); + Integer renewal = interTableDao.insertInterTable(interTable); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 修改接口信息 + * + * @param interTable 接口信息 + * @return 结果 + */ + @Override + public ServerResult updateInterTable(InterTable interTable) { + try { + interTable.setUpdateBy(SecurityUtils.getUserId()); + Integer renewal = interTableDao.updateInterTable(interTable); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 批量删除接口信息 + * + * @param ids 需要删除的接口信息ID + * @return 结果 + */ + @Override + public ServerResult deleteInterTableByIds(Long[] ids) { + try { + Integer renewal = interTableDao.deleteInterTableByIds(ids); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 删除接口信息信息 + * + * @param id 接口信息ID + * @return 结果 + */ + @Override + public ServerResult deleteInterTableById(Long id) { + try { + Integer renewal = interTableDao.deleteInterTableById(id); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } +} \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/resources/mapper/generator/InterTableMapper.xml b/hchyun/hchyun-generator/src/main/resources/mapper/generator/InterTableMapper.xml new file mode 100644 index 0000000..98454e0 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/resources/mapper/generator/InterTableMapper.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + select id, m_id, c_id, it_describe, is_permission, requrl, method, is_generate, create_time, create_by, update_time, update_by from sys_inter_table + + + + + + + + insert into sys_inter_table + + m_id, + c_id, + it_describe, + is_permission, + requrl, + method, + is_generate, + create_by, + update_by, + + + #{mId}, + #{cId}, + #{itDescribe}, + #{isPermission}, + #{requrl}, + #{method}, + #{isGenerate}, + #{createBy}, + #{updateBy}, + + + + + update sys_inter_table + + m_id = #{mId}, + c_id = #{cId}, + it_describe = #{itDescribe}, + is_permission = #{isPermission}, + requrl = #{requrl}, + method = #{method}, + is_generate = #{isGenerate}, + create_by = #{createBy}, + update_by = #{updateBy}, + + where id = #{id} + + + + delete from sys_inter_table where id = #{id} + + + + delete from sys_inter_table where id in + + #{id} + + + \ No newline at end of file