新增地区受攻击表

dongdingding
董丁丁 2 years ago
parent 320ffee9af
commit a48bea1b37

@ -0,0 +1,106 @@
package com.ruoyi.zongzhi.controller;
import java.util.List;
import io.swagger.annotations.Api;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zongzhi.domain.TcAttack;
import com.ruoyi.zongzhi.service.ITcAttackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* Controller
*
* @author ruoyi
* @date 2023-08-21
*/
@RestController
@RequestMapping("/zongzhi/attack")
@Api(tags = " 地区受攻击")
public class TcAttackController extends BaseController
{
@Autowired
private ITcAttackService tcAttackService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:attack:list')")
@GetMapping("/list")
public TableDataInfo list(TcAttack tcAttack)
{
startPage();
List<TcAttack> list = tcAttackService.selectTcAttackList(tcAttack);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:attack:export')")
@Log(title = "地区受攻击", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TcAttack tcAttack)
{
List<TcAttack> list = tcAttackService.selectTcAttackList(tcAttack);
ExcelUtil<TcAttack> util = new ExcelUtil<TcAttack>(TcAttack.class);
util.exportExcel(response, list, "地区受攻击数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:attack:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(tcAttackService.selectTcAttackById(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:attack:add')")
@Log(title = "地区受攻击", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TcAttack tcAttack)
{
return toAjax(tcAttackService.insertTcAttack(tcAttack));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:attack:edit')")
@Log(title = "地区受攻击", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TcAttack tcAttack)
{
return toAjax(tcAttackService.updateTcAttack(tcAttack));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:attack:remove')")
@Log(title = "地区受攻击", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(tcAttackService.deleteTcAttackByIds(ids));
}
}

@ -0,0 +1,39 @@
package com.ruoyi.zongzhi.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* tc_attack
*
* @author ruoyi
* @date 2023-08-21
*/
@Data
public class TcAttack extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
*
*/
@Excel(name = "地区名称")
@ApiModelProperty(value = "地区名称")
private String name;
/**
*
*/
@Excel(name = "攻击次数")
@ApiModelProperty(value = "攻击次数")
private Long attackCount;
}

@ -0,0 +1,61 @@
package com.ruoyi.zongzhi.mapper;
import java.util.List;
import com.ruoyi.zongzhi.domain.TcAttack;
/**
* Mapper
*
* @author ruoyi
* @date 2023-08-21
*/
public interface TcAttackMapper
{
/**
*
*
* @param id
* @return
*/
public TcAttack selectTcAttackById(Long id);
/**
*
*
* @param tcAttack
* @return
*/
public List<TcAttack> selectTcAttackList(TcAttack tcAttack);
/**
*
*
* @param tcAttack
* @return
*/
public int insertTcAttack(TcAttack tcAttack);
/**
*
*
* @param tcAttack
* @return
*/
public int updateTcAttack(TcAttack tcAttack);
/**
*
*
* @param id
* @return
*/
public int deleteTcAttackById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteTcAttackByIds(Long[] ids);
}

@ -0,0 +1,61 @@
package com.ruoyi.zongzhi.service;
import java.util.List;
import com.ruoyi.zongzhi.domain.TcAttack;
/**
* Service
*
* @author ruoyi
* @date 2023-08-21
*/
public interface ITcAttackService
{
/**
*
*
* @param id
* @return
*/
public TcAttack selectTcAttackById(Long id);
/**
*
*
* @param tcAttack
* @return
*/
public List<TcAttack> selectTcAttackList(TcAttack tcAttack);
/**
*
*
* @param tcAttack
* @return
*/
public int insertTcAttack(TcAttack tcAttack);
/**
*
*
* @param tcAttack
* @return
*/
public int updateTcAttack(TcAttack tcAttack);
/**
*
*
* @param ids
* @return
*/
public int deleteTcAttackByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteTcAttackById(Long id);
}

@ -0,0 +1,93 @@
package com.ruoyi.zongzhi.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.zongzhi.mapper.TcAttackMapper;
import com.ruoyi.zongzhi.domain.TcAttack;
import com.ruoyi.zongzhi.service.ITcAttackService;
/**
* Service
*
* @author ruoyi
* @date 2023-08-21
*/
@Service
public class TcAttackServiceImpl implements ITcAttackService
{
@Autowired
private TcAttackMapper tcAttackMapper;
/**
*
*
* @param id
* @return
*/
@Override
public TcAttack selectTcAttackById(Long id)
{
return tcAttackMapper.selectTcAttackById(id);
}
/**
*
*
* @param tcAttack
* @return
*/
@Override
public List<TcAttack> selectTcAttackList(TcAttack tcAttack)
{
return tcAttackMapper.selectTcAttackList(tcAttack);
}
/**
*
*
* @param tcAttack
* @return
*/
@Override
public int insertTcAttack(TcAttack tcAttack)
{
return tcAttackMapper.insertTcAttack(tcAttack);
}
/**
*
*
* @param tcAttack
* @return
*/
@Override
public int updateTcAttack(TcAttack tcAttack)
{
return tcAttackMapper.updateTcAttack(tcAttack);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteTcAttackByIds(Long[] ids)
{
return tcAttackMapper.deleteTcAttackByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteTcAttackById(Long id)
{
return tcAttackMapper.deleteTcAttackById(id);
}
}

@ -0,0 +1,63 @@
<?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.zongzhi.mapper.TcAttackMapper">
<resultMap type="TcAttack" id="TcAttackResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="attackCount" column="attack_count" />
</resultMap>
<sql id="selectTcAttackVo">
select id, name, attack_count from tc_attack
</sql>
<select id="selectTcAttackList" parameterType="TcAttack" resultMap="TcAttackResult">
<include refid="selectTcAttackVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="attackCount != null "> and attack_count = #{attackCount}</if>
</where>
</select>
<select id="selectTcAttackById" parameterType="Long" resultMap="TcAttackResult">
<include refid="selectTcAttackVo"/>
where id = #{id}
</select>
<insert id="insertTcAttack" parameterType="TcAttack">
insert into tc_attack
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null">name,</if>
<if test="attackCount != null">attack_count,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null">#{name},</if>
<if test="attackCount != null">#{attackCount},</if>
</trim>
</insert>
<update id="updateTcAttack" parameterType="TcAttack">
update tc_attack
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="attackCount != null">attack_count = #{attackCount},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTcAttackById" parameterType="Long">
delete from tc_attack where id = #{id}
</delete>
<delete id="deleteTcAttackByIds" parameterType="String">
delete from tc_attack where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save