This commit is contained in:
20932067@zju.edu.cn 2021-01-25 23:45:44 +08:00
parent 48b5c50f85
commit b5cc83b651
6 changed files with 708 additions and 0 deletions

View File

@ -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<List<InterTable>> 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<List<InterTable>> serverResult = interTableService.selectInterTableList(interTable);
ExcelUtil<InterTable> util = new ExcelUtil<InterTable>(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<InterTable> 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<Integer> 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<Integer> 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<Integer> 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);
}
}
}

View File

@ -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<InterTable> 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);
}

View File

@ -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();
}
}

View File

@ -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<InterTable> selectInterTableById(Long id);
/**
* 查询接口信息列表
*
* @param interTable 接口信息
* @return 接口信息集合
*/
ServerResult<List<InterTable>> selectInterTableList(InterTable interTable);
/**
* 新增接口信息
*
* @param interTable 接口信息
* @return 结果
*/
ServerResult<Integer> insertInterTable(InterTable interTable);
/**
* 修改接口信息
*
* @param interTable 接口信息
* @return 结果
*/
ServerResult<Integer> updateInterTable(InterTable interTable);
/**
* 批量删除接口信息
*
* @param ids 需要删除的接口信息ID
* @return 结果
*/
ServerResult<Integer> deleteInterTableByIds(Long[] ids);
/**
* 删除接口信息信息
*
* @param id 接口信息ID
* @return 结果
*/
ServerResult<Integer> deleteInterTableById(Long id);
}

View File

@ -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<InterTable> selectInterTableById(Long id) {
try {
InterTable interTable = interTableDao.selectInterTableById(id);
if (interTable != null){
return new ServerResult<InterTable>(true,interTable);
}else {
return new ServerResult<InterTable>(false, ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<InterTable>(false,ReturnConstants.DB_EX);
}
}
/**
* 查询接口信息列表
*
* @param interTable 接口信息
* @return 接口信息
*/
@Override
public ServerResult<List<InterTable>> selectInterTableList(InterTable interTable) {
try {
List<InterTable> interTableList = interTableDao.selectInterTableList(interTable);
if (interTableList.size()>0){
return new ServerResult<List<InterTable>>(true,interTableList);
}else {
return new ServerResult<List<InterTable>>(false,ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<List<InterTable>>(false,ReturnConstants.DB_EX);
}
}
/**
* 新增接口信息
*
* @param interTable 接口信息
* @return 结果
*/
@Override
public ServerResult<Integer> insertInterTable(InterTable interTable) {
try {
interTable.setCreateBy(SecurityUtils.getUserId());
Integer renewal = interTableDao.insertInterTable(interTable);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
}
}
/**
* 修改接口信息
*
* @param interTable 接口信息
* @return 结果
*/
@Override
public ServerResult<Integer> updateInterTable(InterTable interTable) {
try {
interTable.setUpdateBy(SecurityUtils.getUserId());
Integer renewal = interTableDao.updateInterTable(interTable);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
}
}
/**
* 批量删除接口信息
*
* @param ids 需要删除的接口信息ID
* @return 结果
*/
@Override
public ServerResult<Integer> deleteInterTableByIds(Long[] ids) {
try {
Integer renewal = interTableDao.deleteInterTableByIds(ids);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
}
}
/**
* 删除接口信息信息
*
* @param id 接口信息ID
* @return 结果
*/
@Override
public ServerResult<Integer> deleteInterTableById(Long id) {
try {
Integer renewal = interTableDao.deleteInterTableById(id);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
}
}
}

View File

@ -0,0 +1,96 @@
<?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">
<mapper namespace="com.hchyun.generator.dao.InterTableDao">
<resultMap type="InterTable" id="InterTableResult">
<result property="id" column="id" />
<result property="mId" column="m_id" />
<result property="cId" column="c_id" />
<result property="itDescribe" column="it_describe" />
<result property="isPermission" column="is_permission" />
<result property="requrl" column="requrl" />
<result property="method" column="method" />
<result property="isGenerate" column="is_generate" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectInterTableVo">
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
</sql>
<select id="selectInterTableList" parameterType="InterTable" resultMap="InterTableResult">
<include refid="selectInterTableVo"/>
<where>
<if test="mId != null "> and m_id = #{mId}</if>
<if test="cId != null "> and c_id = #{cId}</if>
<if test="itDescribe != null and itDescribe != ''"> and it_describe = #{itDescribe}</if>
<if test="isPermission != null "> and is_permission = #{isPermission}</if>
<if test="requrl != null and requrl != ''"> and requrl = #{requrl}</if>
<if test="method != null and method != ''"> and method = #{method}</if>
<if test="isGenerate != null "> and is_generate = #{isGenerate}</if>
</where>
</select>
<select id="selectInterTableById" parameterType="Long" resultMap="InterTableResult">
<include refid="selectInterTableVo"/>
where id = #{id}
</select>
<insert id="insertInterTable" parameterType="InterTable" useGeneratedKeys="true" keyProperty="id">
insert into sys_inter_table
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mId != null">m_id,</if>
<if test="cId != null">c_id,</if>
<if test="itDescribe != null">it_describe,</if>
<if test="isPermission != null">is_permission,</if>
<if test="requrl != null">requrl,</if>
<if test="method != null">method,</if>
<if test="isGenerate != null">is_generate,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mId != null">#{mId},</if>
<if test="cId != null">#{cId},</if>
<if test="itDescribe != null">#{itDescribe},</if>
<if test="isPermission != null">#{isPermission},</if>
<if test="requrl != null">#{requrl},</if>
<if test="method != null">#{method},</if>
<if test="isGenerate != null">#{isGenerate},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateInterTable" parameterType="InterTable">
update sys_inter_table
<trim prefix="SET" suffixOverrides=",">
<if test="mId != null">m_id = #{mId},</if>
<if test="cId != null">c_id = #{cId},</if>
<if test="itDescribe != null">it_describe = #{itDescribe},</if>
<if test="isPermission != null">is_permission = #{isPermission},</if>
<if test="requrl != null">requrl = #{requrl},</if>
<if test="method != null">method = #{method},</if>
<if test="isGenerate != null">is_generate = #{isGenerate},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteInterTableById" parameterType="Long">
delete from sys_inter_table where id = #{id}
</delete>
<delete id="deleteInterTableByIds" parameterType="String">
delete from sys_inter_table where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>