防坠器
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.tower.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.tower.service.TowerFallService;
|
||||
import com.gxwebsoft.tower.entity.TowerFall;
|
||||
import com.gxwebsoft.tower.param.TowerFallParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 防坠器管理控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-06-05 22:40:55
|
||||
*/
|
||||
@Api(tags = "防坠器管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/tower/tower-fall")
|
||||
public class TowerFallController extends BaseController {
|
||||
@Resource
|
||||
private TowerFallService towerFallService;
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询防坠器管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TowerFall>> page(TowerFallParam param) {
|
||||
PageParam<TowerFall, TowerFallParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(towerFallService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(towerFallService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部防坠器管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TowerFall>> list(TowerFallParam param) {
|
||||
PageParam<TowerFall, TowerFallParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(towerFallService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(towerFallService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询防坠器管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TowerFall> get(@PathVariable("id") Integer id) {
|
||||
return success(towerFallService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(towerFallService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加防坠器管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TowerFall towerFall) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
towerFall.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (towerFallService.save(towerFall)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改防坠器管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TowerFall towerFall) {
|
||||
if (towerFallService.updateById(towerFall)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除防坠器管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (towerFallService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加防坠器管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TowerFall> list) {
|
||||
if (towerFallService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改防坠器管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TowerFall> batchParam) {
|
||||
if (batchParam.update(towerFallService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerFall:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除防坠器管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (towerFallService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
86
src/main/java/com/gxwebsoft/tower/entity/TowerFall.java
Normal file
86
src/main/java/com/gxwebsoft/tower/entity/TowerFall.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.gxwebsoft.tower.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 项目管理
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-06-05 22:40:54
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "TowerFall对象", description = "项目管理")
|
||||
public class TowerFall implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "防坠器编号")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "防坠器型号")
|
||||
private String model;
|
||||
|
||||
@ApiModelProperty(value = "制造厂家")
|
||||
private String factory;
|
||||
|
||||
@ApiModelProperty(value = "产权单位")
|
||||
private String companyId;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期")
|
||||
private Date factoryDate;
|
||||
|
||||
@ApiModelProperty(value = "报废日期")
|
||||
private Date discardDate;
|
||||
|
||||
@ApiModelProperty(value = "出厂检测报告")
|
||||
private String file1;
|
||||
|
||||
@ApiModelProperty(value = "合格证")
|
||||
private String file2;
|
||||
|
||||
@ApiModelProperty(value = "出厂铭牌")
|
||||
private String file3;
|
||||
|
||||
@ApiModelProperty(value = "发票")
|
||||
private String file4;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0待发布, 1已发布")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "排序号")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "所有人")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.tower.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.tower.entity.TowerFall;
|
||||
import com.gxwebsoft.tower.param.TowerFallParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目管理Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-06-05 22:40:54
|
||||
*/
|
||||
public interface TowerFallMapper extends BaseMapper<TowerFall> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<TowerFall>
|
||||
*/
|
||||
List<TowerFall> selectPageRel(@Param("page") IPage<TowerFall> page,
|
||||
@Param("param") TowerFallParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<TowerFall> selectListRel(@Param("param") TowerFallParam param);
|
||||
|
||||
}
|
||||
@@ -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.gxwebsoft.tower.mapper.TowerFallMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM tower_fall a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.code != null">
|
||||
AND a.code LIKE CONCAT('%', #{param.code}, '%')
|
||||
</if>
|
||||
<if test="param.model != null">
|
||||
AND a.model LIKE CONCAT('%', #{param.model}, '%')
|
||||
</if>
|
||||
<if test="param.factory != null">
|
||||
AND a.factory LIKE CONCAT('%', #{param.factory}, '%')
|
||||
</if>
|
||||
<if test="param.companyId != null">
|
||||
AND a.company_id LIKE CONCAT('%', #{param.companyId}, '%')
|
||||
</if>
|
||||
<if test="param.factoryDate != null">
|
||||
AND a.factory_date LIKE CONCAT('%', #{param.factoryDate}, '%')
|
||||
</if>
|
||||
<if test="param.discardDate != null">
|
||||
AND a.discard_date LIKE CONCAT('%', #{param.discardDate}, '%')
|
||||
</if>
|
||||
<if test="param.file1 != null">
|
||||
AND a.file1 LIKE CONCAT('%', #{param.file1}, '%')
|
||||
</if>
|
||||
<if test="param.file2 != null">
|
||||
AND a.file2 LIKE CONCAT('%', #{param.file2}, '%')
|
||||
</if>
|
||||
<if test="param.file3 != null">
|
||||
AND a.file3 LIKE CONCAT('%', #{param.file3}, '%')
|
||||
</if>
|
||||
<if test="param.file4 != null">
|
||||
AND a.file4 LIKE CONCAT('%', #{param.file4}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.tower.entity.TowerFall">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.tower.entity.TowerFall">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
78
src/main/java/com/gxwebsoft/tower/param/TowerFallParam.java
Normal file
78
src/main/java/com/gxwebsoft/tower/param/TowerFallParam.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.gxwebsoft.tower.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 项目管理查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-06-05 22:40:54
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "TowerFallParam对象", description = "项目管理查询参数")
|
||||
public class TowerFallParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "防坠器编号")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "防坠器型号")
|
||||
private String model;
|
||||
|
||||
@ApiModelProperty(value = "制造厂家")
|
||||
private String factory;
|
||||
|
||||
@ApiModelProperty(value = "产权单位")
|
||||
private String companyId;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期")
|
||||
private String factoryDate;
|
||||
|
||||
@ApiModelProperty(value = "报废日期")
|
||||
private String discardDate;
|
||||
|
||||
@ApiModelProperty(value = "出厂检测报告")
|
||||
private String file1;
|
||||
|
||||
@ApiModelProperty(value = "合格证")
|
||||
private String file2;
|
||||
|
||||
@ApiModelProperty(value = "出厂铭牌")
|
||||
private String file3;
|
||||
|
||||
@ApiModelProperty(value = "发票")
|
||||
private String file4;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0待发布, 1已发布")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "排序号")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "所有人")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.tower.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.tower.entity.TowerFall;
|
||||
import com.gxwebsoft.tower.param.TowerFallParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目管理Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-06-05 22:40:55
|
||||
*/
|
||||
public interface TowerFallService extends IService<TowerFall> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<TowerFall>
|
||||
*/
|
||||
PageResult<TowerFall> pageRel(TowerFallParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<TowerFall>
|
||||
*/
|
||||
List<TowerFall> listRel(TowerFallParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id 自增ID
|
||||
* @return TowerFall
|
||||
*/
|
||||
TowerFall getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.tower.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.tower.mapper.TowerFallMapper;
|
||||
import com.gxwebsoft.tower.service.TowerFallService;
|
||||
import com.gxwebsoft.tower.entity.TowerFall;
|
||||
import com.gxwebsoft.tower.param.TowerFallParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目管理Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-06-05 22:40:55
|
||||
*/
|
||||
@Service
|
||||
public class TowerFallServiceImpl extends ServiceImpl<TowerFallMapper, TowerFall> implements TowerFallService {
|
||||
|
||||
@Override
|
||||
public PageResult<TowerFall> pageRel(TowerFallParam param) {
|
||||
PageParam<TowerFall, TowerFallParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<TowerFall> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TowerFall> listRel(TowerFallParam param) {
|
||||
List<TowerFall> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<TowerFall, TowerFallParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TowerFall getByIdRel(Integer id) {
|
||||
TowerFallParam param = new TowerFallParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user