
15 changed files with 595 additions and 9 deletions
@ -0,0 +1,136 @@ |
|||
package com.gxwebsoft.tower.controller; |
|||
|
|||
import com.gxwebsoft.common.core.web.BaseController; |
|||
import com.gxwebsoft.common.system.entity.User; |
|||
import com.gxwebsoft.tower.service.TowerSecurityPlantService; |
|||
import com.gxwebsoft.tower.entity.TowerSecurityPlant; |
|||
import com.gxwebsoft.tower.param.TowerSecurityPlantParam; |
|||
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 2024-02-25 19:03:48 |
|||
*/ |
|||
@Api(tags = "保养记录管理") |
|||
@RestController |
|||
@RequestMapping("/api/tower/tower-security-plant") |
|||
public class TowerSecurityPlantController extends BaseController { |
|||
@Resource |
|||
private TowerSecurityPlantService towerSecurityPlantService; |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:list')") |
|||
@OperationLog |
|||
@ApiOperation("分页查询保养记录") |
|||
@GetMapping("/page") |
|||
public ApiResult<PageResult<TowerSecurityPlant>> page(TowerSecurityPlantParam param) { |
|||
// 使用关联查询
|
|||
return success(towerSecurityPlantService.pageRel(param)); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:list')") |
|||
@OperationLog |
|||
@ApiOperation("查询全部保养记录") |
|||
@GetMapping() |
|||
public ApiResult<List<TowerSecurityPlant>> list(TowerSecurityPlantParam param) { |
|||
PageParam<TowerSecurityPlant, TowerSecurityPlantParam> page = new PageParam<>(param); |
|||
page.setDefaultOrder("create_time desc"); |
|||
return success(towerSecurityPlantService.list(page.getOrderWrapper())); |
|||
// 使用关联查询
|
|||
//return success(towerSecurityPlantService.listRel(param));
|
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:list')") |
|||
@OperationLog |
|||
@ApiOperation("根据id查询保养记录") |
|||
@GetMapping("/{id}") |
|||
public ApiResult<TowerSecurityPlant> get(@PathVariable("id") Integer id) { |
|||
return success(towerSecurityPlantService.getById(id)); |
|||
// 使用关联查询
|
|||
//return success(towerSecurityPlantService.getByIdRel(id));
|
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:save')") |
|||
@OperationLog |
|||
@ApiOperation("添加保养记录") |
|||
@PostMapping() |
|||
public ApiResult<?> save(@RequestBody TowerSecurityPlant towerSecurityPlant) { |
|||
// 记录当前登录用户id
|
|||
User loginUser = getLoginUser(); |
|||
if (loginUser != null) { |
|||
towerSecurityPlant.setUserId(loginUser.getUserId()); |
|||
} |
|||
if (towerSecurityPlantService.save(towerSecurityPlant)) { |
|||
return success("添加成功"); |
|||
} |
|||
return fail("添加失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:update')") |
|||
@OperationLog |
|||
@ApiOperation("修改保养记录") |
|||
@PutMapping() |
|||
public ApiResult<?> update(@RequestBody TowerSecurityPlant towerSecurityPlant) { |
|||
if (towerSecurityPlantService.updateById(towerSecurityPlant)) { |
|||
return success("修改成功"); |
|||
} |
|||
return fail("修改失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:remove')") |
|||
@OperationLog |
|||
@ApiOperation("删除保养记录") |
|||
@DeleteMapping("/{id}") |
|||
public ApiResult<?> remove(@PathVariable("id") Integer id) { |
|||
if (towerSecurityPlantService.removeById(id)) { |
|||
return success("删除成功"); |
|||
} |
|||
return fail("删除失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:save')") |
|||
@OperationLog |
|||
@ApiOperation("批量添加保养记录") |
|||
@PostMapping("/batch") |
|||
public ApiResult<?> saveBatch(@RequestBody List<TowerSecurityPlant> list) { |
|||
if (towerSecurityPlantService.saveBatch(list)) { |
|||
return success("添加成功"); |
|||
} |
|||
return fail("添加失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:update')") |
|||
@OperationLog |
|||
@ApiOperation("批量修改保养记录") |
|||
@PutMapping("/batch") |
|||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TowerSecurityPlant> batchParam) { |
|||
if (batchParam.update(towerSecurityPlantService, "security_record_id")) { |
|||
return success("修改成功"); |
|||
} |
|||
return fail("修改失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerSecurityPlant:remove')") |
|||
@OperationLog |
|||
@ApiOperation("批量删除保养记录") |
|||
@DeleteMapping("/batch") |
|||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) { |
|||
if (towerSecurityPlantService.removeByIds(ids)) { |
|||
return success("删除成功"); |
|||
} |
|||
return fail("删除失败"); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,125 @@ |
|||
package com.gxwebsoft.tower.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
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 2024-02-25 19:03:48 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@ApiModel(value = "TowerSecurityPlant对象", description = "保养记录") |
|||
public class TowerSecurityPlant implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "自增ID") |
|||
@TableId(value = "security_record_id", type = IdType.AUTO) |
|||
private Integer securityRecordId; |
|||
|
|||
@ApiModelProperty(value = "保养计划ID") |
|||
private Integer securityId; |
|||
|
|||
@ApiModelProperty(value = "保养编号") |
|||
private String securityCode; |
|||
|
|||
@ApiModelProperty(value = "现场图片") |
|||
private String images; |
|||
|
|||
@ApiModelProperty(value = "经度") |
|||
private String longitude; |
|||
|
|||
@ApiModelProperty(value = "纬度") |
|||
private String latitude; |
|||
|
|||
@ApiModelProperty(value = "所在国家") |
|||
private String country; |
|||
|
|||
@ApiModelProperty(value = "所在省份") |
|||
private String province; |
|||
|
|||
@ApiModelProperty(value = "所在城市") |
|||
private String city; |
|||
|
|||
@ApiModelProperty(value = "所在辖区") |
|||
private String region; |
|||
|
|||
@ApiModelProperty(value = "区域名称") |
|||
private String regionName; |
|||
|
|||
@ApiModelProperty(value = "状态, 0待确认, 1已确认") |
|||
private Integer status; |
|||
|
|||
@ApiModelProperty(value = "确认状态, 0待确认, 1已确认") |
|||
private Integer confirmStatus; |
|||
|
|||
@ApiModelProperty(value = "备注") |
|||
private String comments; |
|||
|
|||
@ApiModelProperty(value = "排序号") |
|||
private Integer sortNumber; |
|||
|
|||
@ApiModelProperty(value = "所有人") |
|||
private Integer userId; |
|||
|
|||
@ApiModelProperty(value = "所有人") |
|||
private Integer confirmId; |
|||
|
|||
@ApiModelProperty(value = "是否删除, 0否, 1是") |
|||
@TableLogic |
|||
private Integer deleted; |
|||
|
|||
@ApiModelProperty(value = "租户id") |
|||
private Integer tenantId; |
|||
|
|||
@ApiModelProperty(value = "创建时间") |
|||
private Date createTime; |
|||
|
|||
@ApiModelProperty(value = "修改时间") |
|||
private Date updateTime; |
|||
|
|||
@ApiModelProperty(value = "昵称") |
|||
@TableField(exist = false) |
|||
private String nickname; |
|||
|
|||
@ApiModelProperty(value = "手机号码") |
|||
@TableField(exist = false) |
|||
private String phone; |
|||
|
|||
@ApiModelProperty(value = "头像") |
|||
@TableField(exist = false) |
|||
private String avatar; |
|||
|
|||
@ApiModelProperty(value = "配件名称") |
|||
@TableField(exist = false) |
|||
private String accessoryName; |
|||
|
|||
@ApiModelProperty(value = "配件编号") |
|||
@TableField(exist = false) |
|||
private String accessoryNo; |
|||
|
|||
@ApiModelProperty(value = "配件分类") |
|||
@TableField(exist = false) |
|||
private String accessoryCategory; |
|||
|
|||
@ApiModelProperty(value = "配件规格") |
|||
@TableField(exist = false) |
|||
private String accessorySpecs; |
|||
|
|||
@ApiModelProperty(value = "适用设备型号") |
|||
@TableField(exist = false) |
|||
private String accessoryModel; |
|||
|
|||
} |
@ -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.TowerSecurityPlant; |
|||
import com.gxwebsoft.tower.param.TowerSecurityPlantParam; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 保养记录Mapper |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-02-25 19:03:48 |
|||
*/ |
|||
public interface TowerSecurityPlantMapper extends BaseMapper<TowerSecurityPlant> { |
|||
|
|||
/** |
|||
* 分页查询 |
|||
* |
|||
* @param page 分页对象 |
|||
* @param param 查询参数 |
|||
* @return List<TowerSecurityPlant> |
|||
*/ |
|||
List<TowerSecurityPlant> selectPageRel(@Param("page") IPage<TowerSecurityPlant> page, |
|||
@Param("param") TowerSecurityPlantParam param); |
|||
|
|||
/** |
|||
* 查询全部 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return List<User> |
|||
*/ |
|||
List<TowerSecurityPlant> selectListRel(@Param("param") TowerSecurityPlantParam param); |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
<?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.TowerSecurityPlantMapper"> |
|||
|
|||
<!-- 关联查询sql --> |
|||
<sql id="selectSql"> |
|||
SELECT a.*,b.nickname,b.phone,b.avatar,c.accessory_no,c.accessory_category,c.accessory_name,c.accessory_model,c.accessory_specs |
|||
FROM tower_security_plant a |
|||
LEFT JOIN sys_user b ON a.user_id = b.user_id |
|||
LEFT JOIN tower_accessory c ON c.accessory_id = a.security_id |
|||
<where> |
|||
<if test="param.securityRecordId != null"> |
|||
AND a.security_record_id = #{param.securityRecordId} |
|||
</if> |
|||
<if test="param.securityId != null"> |
|||
AND a.security_id = #{param.securityId} |
|||
</if> |
|||
<if test="param.securityCode != null"> |
|||
AND a.security_code LIKE CONCAT('%', #{param.securityCode}, '%') |
|||
</if> |
|||
<if test="param.images != null"> |
|||
AND a.images LIKE CONCAT('%', #{param.images}, '%') |
|||
</if> |
|||
<if test="param.longitude != null"> |
|||
AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%') |
|||
</if> |
|||
<if test="param.latitude != null"> |
|||
AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%') |
|||
</if> |
|||
<if test="param.country != null"> |
|||
AND a.country LIKE CONCAT('%', #{param.country}, '%') |
|||
</if> |
|||
<if test="param.province != null"> |
|||
AND a.province LIKE CONCAT('%', #{param.province}, '%') |
|||
</if> |
|||
<if test="param.city != null"> |
|||
AND a.city LIKE CONCAT('%', #{param.city}, '%') |
|||
</if> |
|||
<if test="param.region != null"> |
|||
AND a.region LIKE CONCAT('%', #{param.region}, '%') |
|||
</if> |
|||
<if test="param.regionName != null"> |
|||
AND a.region_name LIKE CONCAT('%', #{param.regionName}, '%') |
|||
</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.TowerSecurityPlant"> |
|||
<include refid="selectSql"></include> |
|||
</select> |
|||
|
|||
<!-- 查询全部 --> |
|||
<select id="selectListRel" resultType="com.gxwebsoft.tower.entity.TowerSecurityPlant"> |
|||
<include refid="selectSql"></include> |
|||
</select> |
|||
|
|||
</mapper> |
@ -0,0 +1,79 @@ |
|||
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 2024-02-25 19:03:48 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
@ApiModel(value = "TowerSecurityPlantParam对象", description = "保养记录查询参数") |
|||
public class TowerSecurityPlantParam extends BaseParam { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "自增ID") |
|||
@QueryField(type = QueryType.EQ) |
|||
private Integer securityRecordId; |
|||
|
|||
@ApiModelProperty(value = "保养计划ID") |
|||
@QueryField(type = QueryType.EQ) |
|||
private Integer securityId; |
|||
|
|||
@ApiModelProperty(value = "保养编号") |
|||
private String securityCode; |
|||
|
|||
@ApiModelProperty(value = "现场图片") |
|||
private String images; |
|||
|
|||
@ApiModelProperty(value = "经度") |
|||
private String longitude; |
|||
|
|||
@ApiModelProperty(value = "纬度") |
|||
private String latitude; |
|||
|
|||
@ApiModelProperty(value = "所在国家") |
|||
private String country; |
|||
|
|||
@ApiModelProperty(value = "所在省份") |
|||
private String province; |
|||
|
|||
@ApiModelProperty(value = "所在城市") |
|||
private String city; |
|||
|
|||
@ApiModelProperty(value = "所在辖区") |
|||
private String region; |
|||
|
|||
@ApiModelProperty(value = "区域名称") |
|||
private String regionName; |
|||
|
|||
@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.TowerSecurityPlant; |
|||
import com.gxwebsoft.tower.param.TowerSecurityPlantParam; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 保养记录Service |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-02-25 19:03:48 |
|||
*/ |
|||
public interface TowerSecurityPlantService extends IService<TowerSecurityPlant> { |
|||
|
|||
/** |
|||
* 分页关联查询 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return PageResult<TowerSecurityPlant> |
|||
*/ |
|||
PageResult<TowerSecurityPlant> pageRel(TowerSecurityPlantParam param); |
|||
|
|||
/** |
|||
* 关联查询全部 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return List<TowerSecurityPlant> |
|||
*/ |
|||
List<TowerSecurityPlant> listRel(TowerSecurityPlantParam param); |
|||
|
|||
/** |
|||
* 根据id查询 |
|||
* |
|||
* @param securityRecordId 自增ID |
|||
* @return TowerSecurityPlant |
|||
*/ |
|||
TowerSecurityPlant getByIdRel(Integer securityRecordId); |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.gxwebsoft.tower.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.gxwebsoft.tower.mapper.TowerSecurityPlantMapper; |
|||
import com.gxwebsoft.tower.service.TowerSecurityPlantService; |
|||
import com.gxwebsoft.tower.entity.TowerSecurityPlant; |
|||
import com.gxwebsoft.tower.param.TowerSecurityPlantParam; |
|||
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 2024-02-25 19:03:48 |
|||
*/ |
|||
@Service |
|||
public class TowerSecurityPlantServiceImpl extends ServiceImpl<TowerSecurityPlantMapper, TowerSecurityPlant> implements TowerSecurityPlantService { |
|||
|
|||
@Override |
|||
public PageResult<TowerSecurityPlant> pageRel(TowerSecurityPlantParam param) { |
|||
PageParam<TowerSecurityPlant, TowerSecurityPlantParam> page = new PageParam<>(param); |
|||
page.setDefaultOrder("create_time desc"); |
|||
List<TowerSecurityPlant> list = baseMapper.selectPageRel(page, param); |
|||
return new PageResult<>(list, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public List<TowerSecurityPlant> listRel(TowerSecurityPlantParam param) { |
|||
List<TowerSecurityPlant> list = baseMapper.selectListRel(param); |
|||
// 排序
|
|||
PageParam<TowerSecurityPlant, TowerSecurityPlantParam> page = new PageParam<>(); |
|||
//page.setDefaultOrder("create_time desc");
|
|||
return page.sortRecords(list); |
|||
} |
|||
|
|||
@Override |
|||
public TowerSecurityPlant getByIdRel(Integer securityRecordId) { |
|||
TowerSecurityPlantParam param = new TowerSecurityPlantParam(); |
|||
param.setSecurityRecordId(securityRecordId); |
|||
return param.getOne(baseMapper.selectListRel(param)); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue