linhw 2024-05-08 17:02:13 +08:00
parent 551080115a
commit d5db372eae
6 changed files with 465 additions and 0 deletions

View File

@ -0,0 +1,114 @@
package com.ruoyi.app.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
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.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.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.app.domain.AppKeyword;
import com.ruoyi.app.service.IAppKeywordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author wyh
* @date 2024-05-08
*/
@RestController
@RequestMapping("/keyword")
@Api(tags = "敏感词" , description = "敏感词")
public class AppKeywordController extends BaseController
{
@Autowired
private IAppKeywordService appKeywordService;
/**
*
*/
@RequiresPermissions("app:keyword:list")
@GetMapping("/list")
@ApiOperation(value = "查询敏感词", notes = "查询敏感词", httpMethod = "GET")
public TableDataInfo list(AppKeyword appKeyword)
{
startPage();
List<AppKeyword> list = appKeywordService.selectAppKeywordList(appKeyword);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("app:keyword:export")
@Log(title = "敏感词", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AppKeyword appKeyword)
{
List<AppKeyword> list = appKeywordService.selectAppKeywordList(appKeyword);
ExcelUtil<AppKeyword> util = new ExcelUtil<AppKeyword>(AppKeyword.class);
util.exportExcel(response, list, "敏感词数据");
}
/**
*
*/
@RequiresPermissions("app:keyword:query")
@GetMapping(value = "/{id}")
@ApiOperation(value = "获取敏感词详细信息", notes = "获取敏感词详细信息", httpMethod = "GET")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(appKeywordService.selectAppKeywordById(id));
}
/**
*
*/
@RequiresPermissions("app:keyword:add")
@ApiOperation(value = "新增敏感词", notes = "新增敏感词", httpMethod = "POST")
@Log(title = "敏感词", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult add(@RequestBody AppKeyword appKeyword)
{
return toAjax(appKeywordService.insertAppKeyword(appKeyword));
}
/**
*
*/
@RequiresPermissions("app:keyword:edit")
@ApiOperation(value = "修改敏感词", notes = "修改敏感词", httpMethod = "PUT")
@Log(title = "敏感词", businessType = BusinessType.UPDATE)
@PutMapping("/edit")
public AjaxResult edit(@RequestBody AppKeyword appKeyword)
{
return toAjax(appKeywordService.updateAppKeyword(appKeyword));
}
/**
*
*/
@RequiresPermissions("app:keyword:remove")
@Log(title = "敏感词", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(appKeywordService.deleteAppKeywordByIds(ids));
}
}

View File

@ -0,0 +1,56 @@
package com.ruoyi.app.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* app_keyword
*
* @author wyh
* @date 2024-05-08
*/
public class AppKeyword extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 敏感词 */
@Excel(name = "敏感词")
private String content;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("content", getContent())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("remark", getRemark())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.app.mapper;
import java.util.List;
import com.ruoyi.app.domain.AppKeyword;
/**
* Mapper
*
* @author wyh
* @date 2024-05-08
*/
public interface AppKeywordMapper
{
/**
*
*
* @param id
* @return
*/
public AppKeyword selectAppKeywordById(Long id);
/**
*
*
* @param appKeyword
* @return
*/
public List<AppKeyword> selectAppKeywordList(AppKeyword appKeyword);
/**
*
*
* @param appKeyword
* @return
*/
public int insertAppKeyword(AppKeyword appKeyword);
/**
*
*
* @param appKeyword
* @return
*/
public int updateAppKeyword(AppKeyword appKeyword);
/**
*
*
* @param id
* @return
*/
public int deleteAppKeywordById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteAppKeywordByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.app.service;
import java.util.List;
import com.ruoyi.app.domain.AppKeyword;
/**
* Service
*
* @author wyh
* @date 2024-05-08
*/
public interface IAppKeywordService
{
/**
*
*
* @param id
* @return
*/
public AppKeyword selectAppKeywordById(Long id);
/**
*
*
* @param appKeyword
* @return
*/
public List<AppKeyword> selectAppKeywordList(AppKeyword appKeyword);
/**
*
*
* @param appKeyword
* @return
*/
public int insertAppKeyword(AppKeyword appKeyword);
/**
*
*
* @param appKeyword
* @return
*/
public int updateAppKeyword(AppKeyword appKeyword);
/**
*
*
* @param ids
* @return
*/
public int deleteAppKeywordByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteAppKeywordById(Long id);
}

View File

@ -0,0 +1,96 @@
package com.ruoyi.app.service.impl;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.app.mapper.AppKeywordMapper;
import com.ruoyi.app.domain.AppKeyword;
import com.ruoyi.app.service.IAppKeywordService;
/**
* Service
*
* @author wyh
* @date 2024-05-08
*/
@Service
public class AppKeywordServiceImpl implements IAppKeywordService
{
@Autowired
private AppKeywordMapper appKeywordMapper;
/**
*
*
* @param id
* @return
*/
@Override
public AppKeyword selectAppKeywordById(Long id)
{
return appKeywordMapper.selectAppKeywordById(id);
}
/**
*
*
* @param appKeyword
* @return
*/
@Override
public List<AppKeyword> selectAppKeywordList(AppKeyword appKeyword)
{
return appKeywordMapper.selectAppKeywordList(appKeyword);
}
/**
*
*
* @param appKeyword
* @return
*/
@Override
public int insertAppKeyword(AppKeyword appKeyword)
{
appKeyword.setCreateTime(DateUtils.getNowDate());
return appKeywordMapper.insertAppKeyword(appKeyword);
}
/**
*
*
* @param appKeyword
* @return
*/
@Override
public int updateAppKeyword(AppKeyword appKeyword)
{
appKeyword.setUpdateTime(DateUtils.getNowDate());
return appKeywordMapper.updateAppKeyword(appKeyword);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteAppKeywordByIds(Long[] ids)
{
return appKeywordMapper.deleteAppKeywordByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteAppKeywordById(Long id)
{
return appKeywordMapper.deleteAppKeywordById(id);
}
}

View File

@ -0,0 +1,77 @@
<?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.ruoyi.app.mapper.AppKeywordMapper">
<resultMap type="AppKeyword" id="AppKeywordResult">
<result property="id" column="id" />
<result property="content" column="content" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="updateBy" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectAppKeywordVo">
select id, content, create_time, update_time, create_by, updateBy, remark from app_keyword
</sql>
<select id="selectAppKeywordList" parameterType="AppKeyword" resultMap="AppKeywordResult">
<include refid="selectAppKeywordVo"/>
<where>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="updateBy != null and updateBy != ''"> and updateBy = #{updateBy}</if>
</where>
</select>
<select id="selectAppKeywordById" parameterType="Long" resultMap="AppKeywordResult">
<include refid="selectAppKeywordVo"/>
where id = #{id}
</select>
<insert id="insertAppKeyword" parameterType="AppKeyword" useGeneratedKeys="true" keyProperty="id">
insert into app_keyword
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="content != null">content,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">updateBy,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="content != null">#{content},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateAppKeyword" parameterType="AppKeyword">
update app_keyword
<trim prefix="SET" suffixOverrides=",">
<if test="content != null">content = #{content},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">updateBy = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAppKeywordById" parameterType="Long">
delete from app_keyword where id = #{id}
</delete>
<delete id="deleteAppKeywordByIds" parameterType="String">
delete from app_keyword where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>