新增接口

main
杜函宇 5 months ago
parent 1141ecf03a
commit 08b76690e0

@ -0,0 +1,109 @@
package com.ruoyi.tcZz.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tcZz.domain.TcZclb;
import com.ruoyi.tcZz.service.ITcZclbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* (tc_zclb)
* @author du
* @since 2024/8/5 13:16
*/
@RestController
@Api(tags = "资产列表")
@RequestMapping("/tcZz/networkSecurity/zclb")
public class TcZclbController extends BaseController {
@Autowired
private ITcZclbService tcZclbService;
/**
*
*/
@ApiOperation(value = "查询资产列表列表", response = TcZclb.class)
@GetMapping("/list")
public TableDataInfo list(TcZclb tc) {
startPage();
List<TcZclb> list = tcZclbService.page(tc);
return getDataTable(list);
}
/**
*
*/
@ApiOperation(value = " 导出资产列表列表")
@PostMapping("/export")
public void export(HttpServletResponse response, TcZclb tc) {
List<TcZclb> list = tcZclbService.page(tc);
ExcelUtil<TcZclb> util = new ExcelUtil<>(TcZclb.class);
util.exportExcel(response, list, "资产列表详情数据");
}
/**
*
*/
@ApiOperation(value = " 获取资产列表信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(tcZclbService.getById(id));
}
/**
*
*/
@ApiOperation(value = "新增资产列表")
@PostMapping
public AjaxResult add(@RequestBody TcZclb tc) {
return toAjax(tcZclbService.insert(tc));
}
/**
*
*/
@ApiOperation(value = "修改资产列表")
@PutMapping
public AjaxResult edit(@RequestBody TcZclb tc) {
return toAjax(tcZclbService.update(tc));
}
/**
*
*/
@ApiOperation(value = "删除资产列表")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(tcZclbService.deleteByIds(ids));
}
/**
*
*/
@ApiOperation("通用导入excel信息")
@PostMapping("/common/importExcel")
public AjaxResult importExcel(MultipartFile file) throws Exception {
ExcelUtil<TcZclb> util = new ExcelUtil<>(TcZclb.class);
List<TcZclb> tcZbxqList = util.importExcel(file.getInputStream());
tcZclbService.importUser(tcZbxqList);
return AjaxResult.success();
}
@ApiOperation("通用下载excel模板")
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) {
ExcelUtil<TcZclb> util = new ExcelUtil<>(TcZclb.class);
util.importTemplateExcel(response, "资产列表详情");
}
}

@ -0,0 +1,38 @@
package com.ruoyi.tcZz.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* (tc_zclb)
* @author du
* @since 2024/8/5 13:20
*/
@Data
@ApiModel("资产列表")
public class TcZclb extends BaseEntity {
/** $column.columnComment */
@ApiModelProperty(value = "id")
private Long id;
/** 所属单位 */
@Excel(name = "所属单位")
@ApiModelProperty(value = "所属单位")
private String unit;
/** 资产名称 */
@Excel(name = "资产名称")
@ApiModelProperty(value = "资产名称")
private String zcName;
/** 资产地址 */
@Excel(name = "资产地址")
@ApiModelProperty(value = "资产地址")
private String zcAddress;
}

@ -0,0 +1,62 @@
package com.ruoyi.tcZz.mapper;
import com.ruoyi.tcZz.domain.TcZclb;
import java.util.List;
/**
* (tc_zclds)
*
* @author ruoyi
* @date 2023-10-12
*/
public interface TcZclbMapper
{
/**
*
*
* @param id
* @return
*/
public TcZclb getById(Long id);
/**
*
*
* @param tcBmtb
* @return
*/
public List<TcZclb> page(TcZclb tcBmtb);
/**
*
*
* @param tcBmtb
* @return
*/
public int insert(TcZclb tcBmtb);
/**
*
*
* @param tcBmtb
* @return
*/
public int update(TcZclb tcBmtb);
/**
*
*
* @param id
* @return
*/
public int deleteById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteByIds(Long[] ids);
}

@ -0,0 +1,64 @@
package com.ruoyi.tcZz.service;
import com.ruoyi.tcZz.domain.TcZclb;
import com.ruoyi.tcZz.domain.TcZczccg;
import java.util.List;
/**
* (tc_zclb)
*
* @author ruoyi
* @date 2023-10-13
*/
public interface ITcZclbService {
/**
*
*
* @param id
* @return
*/
TcZclb getById(Long id);
/**
*
*
* @param tc
* @return
*/
List<TcZclb> page(TcZclb tc);
/**
*
*
* @param tc
* @return
*/
int insert(TcZclb tc);
/**
*
*
* @param tc
* @return
*/
int update(TcZclb tc);
/**
*
*
* @param ids
* @return
*/
int deleteByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
int deleteById(Long id);
String importUser(List<TcZclb> tcZbxqList);
}

@ -0,0 +1,100 @@
package com.ruoyi.tcZz.service.impl;
import com.ruoyi.tcZz.domain.TcZclb;
import com.ruoyi.tcZz.mapper.TcZclbMapper;
import com.ruoyi.tcZz.service.ITcZclbService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* (tc_zclb)
*
* @author ruoyi
* @date 2023-10-13
*/
@Service
public class TcZclbServiceImpl implements ITcZclbService
{
@Resource
private TcZclbMapper tcZclbMapper;
/**
*
*
* @param id
* @return
*/
@Override
public TcZclb getById(Long id) {
return tcZclbMapper.getById(id);
}
/**
*
*
* @param tc
* @return
*/
@Override
public List<TcZclb> page(TcZclb tc) {
return tcZclbMapper.page(tc);
}
/**
*
*
* @param tc
* @return
*/
@Override
public int insert(TcZclb tc) {
return tcZclbMapper.insert(tc);
}
/**
*
*
* @param tc
* @return
*/
@Override
public int update(TcZclb tc) {
return tcZclbMapper.update(tc);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteByIds(Long[] ids) {
return tcZclbMapper.deleteByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteById(Long id) {
return tcZclbMapper.deleteById(id);
}
@Override
public String importUser(List<TcZclb> tcZbxqList) {
StringBuilder successMsg = new StringBuilder();
if (!tcZbxqList.isEmpty()) {
for (TcZclb items : tcZbxqList) {
tcZclbMapper.insert(items);
}
successMsg.append("导入成功");
}
return successMsg.toString();
}
}

@ -0,0 +1,80 @@
<?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.tcZz.mapper.TcZclbMapper">
<resultMap type="TcZclb" id="TcResult">
<result property="id" column="id" />
<result property="unit" column="unit" />
<result property="zcName" column="zc_name" />
<result property="zcAddress" column="zc_address" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectVo">
select id,unit,zc_name,zc_address,create_by,create_time,update_by,update_time,remark from tc_zclb
</sql>
<insert id="insert" parameterType="TcZclds" useGeneratedKeys="true" keyProperty="id">
insert into tc_zclb
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unit != null">unit,</if>
<if test="zcName != null">zc_name,</if>
<if test="zcAddress != null">zc_address,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</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="unit != null">#{unit},</if>
<if test="zcName != null">#{zcName},</if>
<if test="zcAddress != null">#{zcAddress},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="update" parameterType="TcZclds">
update tc_zclb
<trim prefix="SET" suffixOverrides=",">
<if test="unit != null">unit = #{unit},</if>
<if test="zcName != null">zc_name = #{zcName},</if>
<if test="zcAddress != null">zc_address = #{zcAddress},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</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="deleteById">
delete from tc_zclb where id = #{id}
</delete>
<delete id="deleteByIds">
delete from tc_zclb where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getById" resultType="com.ruoyi.tcZz.domain.TcZclb" resultMap="TcResult">
<include refid="selectVo"/>
where id = #{id}
</select>
<select id="page" resultType="com.ruoyi.tcZz.domain.TcZclb" resultMap="TcResult">
<include refid="selectVo"/>
<where>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="zcName != null and zcName != ''"> and zc_name = #{zcName}</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save