安全隐患统计模块添加

main
dongdingding 2 years ago
parent 11b4c850ef
commit b122b06488

@ -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.TcSafetyCounty;
import com.ruoyi.zongzhi.service.ITcSafetyCountyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* Controller
*
* @author ruoyi
* @date 2023-09-20
*/
@RestController
@RequestMapping("/zongzhi/county")
@Api(tags = " 安全隐患统计")
public class TcSafetyCountyController extends BaseController
{
@Autowired
private ITcSafetyCountyService tcSafetyCountyService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:county:list')")
@GetMapping("/list")
public TableDataInfo list(TcSafetyCounty tcSafetyCounty)
{
startPage();
List<TcSafetyCounty> list = tcSafetyCountyService.selectTcSafetyCountyList(tcSafetyCounty);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:county:export')")
@Log(title = "安全隐患统计", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TcSafetyCounty tcSafetyCounty)
{
List<TcSafetyCounty> list = tcSafetyCountyService.selectTcSafetyCountyList(tcSafetyCounty);
ExcelUtil<TcSafetyCounty> util = new ExcelUtil<TcSafetyCounty>(TcSafetyCounty.class);
util.exportExcel(response, list, "安全隐患统计数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:county:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(tcSafetyCountyService.selectTcSafetyCountyById(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:county:add')")
@Log(title = "安全隐患统计", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TcSafetyCounty tcSafetyCounty)
{
return toAjax(tcSafetyCountyService.insertTcSafetyCounty(tcSafetyCounty));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:county:edit')")
@Log(title = "安全隐患统计", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TcSafetyCounty tcSafetyCounty)
{
return toAjax(tcSafetyCountyService.updateTcSafetyCounty(tcSafetyCounty));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('zongzhi:county:remove')")
@Log(title = "安全隐患统计", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(tcSafetyCountyService.deleteTcSafetyCountyByIds(ids));
}
}

@ -0,0 +1,61 @@
package com.ruoyi.zongzhi.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* tc_safety_county
*
* @author ruoyi
* @date 2023-09-20
*/
@Data
public class TcSafetyCounty extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* id
*/
@Excel(name = "区域id")
@ApiModelProperty(value = "区域id")
private Long areaId;
/**
*
*/
@Excel(name = "类型名称")
@ApiModelProperty(value = "类型名称")
private String typeName;
/**
*
*/
@Excel(name = "数量")
@ApiModelProperty(value = "数量")
private Long totalNum;
/**
* id
*/
@Excel(name = "创建人id")
@ApiModelProperty(value = "创建人id")
private Long createId;
/**
* id
*/
@Excel(name = "修改人id")
@ApiModelProperty(value = "修改人id")
private Long updateId;
}

@ -0,0 +1,61 @@
package com.ruoyi.zongzhi.mapper;
import java.util.List;
import com.ruoyi.zongzhi.domain.TcSafetyCounty;
/**
* Mapper
*
* @author ruoyi
* @date 2023-09-20
*/
public interface TcSafetyCountyMapper
{
/**
*
*
* @param id
* @return
*/
public TcSafetyCounty selectTcSafetyCountyById(Long id);
/**
*
*
* @param tcSafetyCounty
* @return
*/
public List<TcSafetyCounty> selectTcSafetyCountyList(TcSafetyCounty tcSafetyCounty);
/**
*
*
* @param tcSafetyCounty
* @return
*/
public int insertTcSafetyCounty(TcSafetyCounty tcSafetyCounty);
/**
*
*
* @param tcSafetyCounty
* @return
*/
public int updateTcSafetyCounty(TcSafetyCounty tcSafetyCounty);
/**
*
*
* @param id
* @return
*/
public int deleteTcSafetyCountyById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteTcSafetyCountyByIds(Long[] ids);
}

@ -0,0 +1,61 @@
package com.ruoyi.zongzhi.service;
import java.util.List;
import com.ruoyi.zongzhi.domain.TcSafetyCounty;
/**
* Service
*
* @author ruoyi
* @date 2023-09-20
*/
public interface ITcSafetyCountyService
{
/**
*
*
* @param id
* @return
*/
public TcSafetyCounty selectTcSafetyCountyById(Long id);
/**
*
*
* @param tcSafetyCounty
* @return
*/
public List<TcSafetyCounty> selectTcSafetyCountyList(TcSafetyCounty tcSafetyCounty);
/**
*
*
* @param tcSafetyCounty
* @return
*/
public int insertTcSafetyCounty(TcSafetyCounty tcSafetyCounty);
/**
*
*
* @param tcSafetyCounty
* @return
*/
public int updateTcSafetyCounty(TcSafetyCounty tcSafetyCounty);
/**
*
*
* @param ids
* @return
*/
public int deleteTcSafetyCountyByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteTcSafetyCountyById(Long id);
}

@ -0,0 +1,96 @@
package com.ruoyi.zongzhi.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.zongzhi.mapper.TcSafetyCountyMapper;
import com.ruoyi.zongzhi.domain.TcSafetyCounty;
import com.ruoyi.zongzhi.service.ITcSafetyCountyService;
/**
* Service
*
* @author ruoyi
* @date 2023-09-20
*/
@Service
public class TcSafetyCountyServiceImpl implements ITcSafetyCountyService
{
@Autowired
private TcSafetyCountyMapper tcSafetyCountyMapper;
/**
*
*
* @param id
* @return
*/
@Override
public TcSafetyCounty selectTcSafetyCountyById(Long id)
{
return tcSafetyCountyMapper.selectTcSafetyCountyById(id);
}
/**
*
*
* @param tcSafetyCounty
* @return
*/
@Override
public List<TcSafetyCounty> selectTcSafetyCountyList(TcSafetyCounty tcSafetyCounty)
{
return tcSafetyCountyMapper.selectTcSafetyCountyList(tcSafetyCounty);
}
/**
*
*
* @param tcSafetyCounty
* @return
*/
@Override
public int insertTcSafetyCounty(TcSafetyCounty tcSafetyCounty)
{
tcSafetyCounty.setCreateTime(DateUtils.getNowDate());
return tcSafetyCountyMapper.insertTcSafetyCounty(tcSafetyCounty);
}
/**
*
*
* @param tcSafetyCounty
* @return
*/
@Override
public int updateTcSafetyCounty(TcSafetyCounty tcSafetyCounty)
{
tcSafetyCounty.setUpdateTime(DateUtils.getNowDate());
return tcSafetyCountyMapper.updateTcSafetyCounty(tcSafetyCounty);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteTcSafetyCountyByIds(Long[] ids)
{
return tcSafetyCountyMapper.deleteTcSafetyCountyByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteTcSafetyCountyById(Long id)
{
return tcSafetyCountyMapper.deleteTcSafetyCountyById(id);
}
}

@ -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.ruoyi.zongzhi.mapper.TcSafetyCountyMapper">
<resultMap type="TcSafetyCounty" id="TcSafetyCountyResult">
<result property="id" column="id" />
<result property="areaId" column="area_id" />
<result property="typeName" column="type_name" />
<result property="totalNum" column="total_num" />
<result property="createId" column="create_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateId" column="update_id" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectTcSafetyCountyVo">
select id, area_id, type_name, total_num, create_id, create_by, create_time, update_id, update_by, update_time, remark from tc_safety_county
</sql>
<select id="selectTcSafetyCountyList" parameterType="TcSafetyCounty" resultMap="TcSafetyCountyResult">
<include refid="selectTcSafetyCountyVo"/>
<where>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="typeName != null and typeName != ''"> and type_name like concat('%', #{typeName}, '%')</if>
<if test="totalNum != null "> and total_num = #{totalNum}</if>
<if test="createId != null "> and create_id = #{createId}</if>
<if test="updateId != null "> and update_id = #{updateId}</if>
</where>
</select>
<select id="selectTcSafetyCountyById" parameterType="Long" resultMap="TcSafetyCountyResult">
<include refid="selectTcSafetyCountyVo"/>
where id = #{id}
</select>
<insert id="insertTcSafetyCounty" parameterType="TcSafetyCounty" useGeneratedKeys="true" keyProperty="id">
insert into tc_safety_county
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaId != null">area_id,</if>
<if test="typeName != null">type_name,</if>
<if test="totalNum != null">total_num,</if>
<if test="createId != null">create_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateId != null">update_id,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="areaId != null">#{areaId},</if>
<if test="typeName != null">#{typeName},</if>
<if test="totalNum != null">#{totalNum},</if>
<if test="createId != null">#{createId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateId != null">#{updateId},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateTcSafetyCounty" parameterType="TcSafetyCounty">
update tc_safety_county
<trim prefix="SET" suffixOverrides=",">
<if test="areaId != null">area_id = #{areaId},</if>
<if test="typeName != null">type_name = #{typeName},</if>
<if test="totalNum != null">total_num = #{totalNum},</if>
<if test="createId != null">create_id = #{createId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateId != null">update_id = #{updateId},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTcSafetyCountyById" parameterType="Long">
delete from tc_safety_county where id = #{id}
</delete>
<delete id="deleteTcSafetyCountyByIds" parameterType="String">
delete from tc_safety_county where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save