package com.java110.fee.api;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.java110.utils.util.Assert;
|
import com.java110.utils.util.BeanConvertUtil;
|
import org.mybatis.spring.SqlSessionTemplate;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 业主支取信息接口
|
* 适配 owner_withdrawal_info 表
|
* @author dev
|
* @date 2025-12-24
|
*/
|
@RestController
|
@RequestMapping(value = "/ownerWithdrawalInfo")
|
public class OwnerWithdrawalInfoApi {
|
|
@Autowired
|
protected SqlSessionTemplate sqlSessionTemplate;
|
|
/**
|
* 保存业主支取信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /ownerWithdrawalInfo/saveOwnerWithdrawalInfo
|
* @path /app/ownerWithdrawalInfo/saveOwnerWithdrawalInfo
|
*/
|
@RequestMapping(value = "/saveOwnerWithdrawalInfo", method = RequestMethod.POST)
|
public ResponseEntity<String> saveOwnerWithdrawalInfo(@RequestBody JSONObject reqJson) {
|
// 核心参数校验
|
Assert.hasKeyAndValue(reqJson, "mpId", "请求报文中未包含业务标识mpId");
|
|
// 转换为POJO
|
OwnerWithdrawalInfoPo po = BeanConvertUtil.covertBean(reqJson, OwnerWithdrawalInfoPo.class);
|
|
// 调用Mapper保存方法
|
int insert = sqlSessionTemplate.insert("ownerWithdrawalInfoServiceDaoImpl.saveOwnerWithdrawalInfo",
|
BeanConvertUtil.beanCovertMap(po));
|
|
// 构造响应结果
|
JSONObject resJson = new JSONObject();
|
if (insert > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "保存业主支取信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "保存业主支取信息失败");
|
}
|
resJson.put("count", insert);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
|
public ResponseEntity<String> saveOwnerWithdrawalInfo(OwnerWithdrawalInfoPo po) {
|
|
// 调用Mapper保存方法
|
int insert = sqlSessionTemplate.insert("ownerWithdrawalInfoServiceDaoImpl.saveOwnerWithdrawalInfo",
|
BeanConvertUtil.beanCovertMap(po));
|
|
// 构造响应结果
|
JSONObject resJson = new JSONObject();
|
if (insert > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "保存业主支取信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "保存业主支取信息失败");
|
}
|
resJson.put("count", insert);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
|
/**
|
* 批量保存业主支取信息
|
*
|
* @param reqJson 请求参数(包含ownerWithdrawalInfoList数组)
|
* @return 响应结果
|
* @serviceCode /ownerWithdrawalInfo/saveOwnerWithdrawalInfos
|
* @path /app/ownerWithdrawalInfo/saveOwnerWithdrawalInfos
|
*/
|
@RequestMapping(value = "/saveOwnerWithdrawalInfos", method = RequestMethod.POST)
|
public ResponseEntity<String> saveOwnerWithdrawalInfos(@RequestBody JSONObject reqJson) {
|
Assert.hasKeyAndValue(reqJson, "ownerWithdrawalInfoList", "请求报文中未包含批量数据列表");
|
|
// 转换批量数据
|
List<OwnerWithdrawalInfoPo> poList = BeanConvertUtil.covertBeanList(
|
reqJson.getJSONArray("ownerWithdrawalInfoList"), OwnerWithdrawalInfoPo.class);
|
|
Map<String, Object> param = BeanConvertUtil.beanCovertMap(reqJson);
|
param.put("conventionList", poList);
|
|
// 批量插入
|
int insert = sqlSessionTemplate.insert("ownerWithdrawalInfoServiceDaoImpl.batchSaveOwnerWithdrawalInfo", param);
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "批量保存业主支取信息成功");
|
resJson.put("count", insert);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 修改业主支取信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /ownerWithdrawalInfo/updateOwnerWithdrawalInfo
|
* @path /app/ownerWithdrawalInfo/updateOwnerWithdrawalInfo
|
*/
|
@RequestMapping(value = "/updateOwnerWithdrawalInfo", method = RequestMethod.POST)
|
public ResponseEntity<String> updateOwnerWithdrawalInfo(@RequestBody JSONObject reqJson) {
|
// 主键校验
|
Assert.hasKeyAndValue(reqJson, "id", "请求报文中未包含主键ID");
|
|
OwnerWithdrawalInfoPo po = BeanConvertUtil.covertBean(reqJson, OwnerWithdrawalInfoPo.class);
|
|
// 调用Mapper修改方法
|
int update = sqlSessionTemplate.update("ownerWithdrawalInfoServiceDaoImpl.updateOwnerWithdrawalInfo",
|
BeanConvertUtil.beanCovertMap(po));
|
|
JSONObject resJson = new JSONObject();
|
if (update > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "修改业主支取信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "修改业主支取信息失败,未找到对应记录");
|
}
|
resJson.put("count", update);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 删除业主支取信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /ownerWithdrawalInfo/deleteOwnerWithdrawalInfo
|
* @path /app/ownerWithdrawalInfo/deleteOwnerWithdrawalInfo
|
*/
|
@RequestMapping(value = "/deleteOwnerWithdrawalInfo", method = RequestMethod.POST)
|
public ResponseEntity<String> deleteOwnerWithdrawalInfo(@RequestBody JSONObject reqJson) {
|
// 必要参数校验
|
Assert.hasKeyAndValue(reqJson, "id", "主键ID不能为空");
|
|
OwnerWithdrawalInfoPo po = BeanConvertUtil.covertBean(reqJson, OwnerWithdrawalInfoPo.class);
|
|
// 调用Mapper删除方法
|
int delete = sqlSessionTemplate.delete("ownerWithdrawalInfoServiceDaoImpl.deleteOwnerWithdrawalInfo",
|
BeanConvertUtil.beanCovertMap(po));
|
|
JSONObject resJson = new JSONObject();
|
if (delete > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "删除业主支取信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "删除业主支取信息失败,未找到对应记录");
|
}
|
resJson.put("count", delete);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 分页查询业主支取信息列表
|
*
|
* @param mpId 业务标识(必传)
|
* @param page 页码(默认1)
|
* @param row 每页条数(默认10)
|
* @param id 主键ID(可选)
|
* @param roadName 路名(可选)
|
* @param doorRoomNumber 门室号(可选)
|
* @return 响应结果
|
* @serviceCode /ownerWithdrawalInfo/queryOwnerWithdrawalInfo
|
* @path /app/ownerWithdrawalInfo/queryOwnerWithdrawalInfo
|
*/
|
@RequestMapping(value = "/queryOwnerWithdrawalInfo", method = RequestMethod.GET)
|
public ResponseEntity<String> queryOwnerWithdrawalInfo(
|
@RequestParam(value = "mpId") String mpId,
|
@RequestParam(value = "page", defaultValue = "1") int page,
|
@RequestParam(value = "row", defaultValue = "10") int row,
|
@RequestParam(value = "id", required = false) Long id,
|
@RequestParam(value = "roadName", required = false) String roadName,
|
@RequestParam(value = "doorRoomNumber", required = false) String doorRoomNumber) {
|
|
// 封装查询参数
|
OwnerWithdrawalInfoPo queryPo = new OwnerWithdrawalInfoPo();
|
queryPo.setMpId(mpId);
|
queryPo.setPage((page - 1) * row); // 转换为MySQL分页偏移量
|
queryPo.setRow(row);
|
|
if (id != null) {
|
queryPo.setId(id);
|
}
|
if (roadName != null && !roadName.isEmpty()) {
|
queryPo.setRoadName(roadName);
|
}
|
if (doorRoomNumber != null && !doorRoomNumber.isEmpty()) {
|
queryPo.setDoorRoomNumber(doorRoomNumber);
|
}
|
|
// 查询列表数据
|
List<Map<String, Object>> list = sqlSessionTemplate.selectList(
|
"ownerWithdrawalInfoServiceDaoImpl.getOwnerWithdrawalInfo",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
// 查询总数
|
Object total = ((HashMap) sqlSessionTemplate.selectOne(
|
"ownerWithdrawalInfoServiceDaoImpl.queryOwnerWithdrawalInfoCount",
|
BeanConvertUtil.beanCovertMap(queryPo))).get("count");
|
|
// 构造分页响应
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询业主支取信息成功");
|
resJson.put("page", page);
|
resJson.put("row", row);
|
resJson.put("total", total);
|
resJson.put("data", list);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 根据ID查询单条业主支取信息
|
*
|
* @param id 主键ID
|
* @return 响应结果
|
* @serviceCode /ownerWithdrawalInfo/getOwnerWithdrawalInfoById
|
* @path /app/ownerWithdrawalInfo/getOwnerWithdrawalInfoById
|
*/
|
@RequestMapping(value = "/getOwnerWithdrawalInfoById", method = RequestMethod.GET)
|
public ResponseEntity<String> getOwnerWithdrawalInfoById(@RequestParam(value = "id") Long id) {
|
// 主键校验
|
Assert.notNull(id, "主键ID不能为空");
|
|
OwnerWithdrawalInfoPo queryPo = new OwnerWithdrawalInfoPo();
|
queryPo.setId(id);
|
|
// 查询单条数据
|
Map<String, Object> result = sqlSessionTemplate.selectOne(
|
"ownerWithdrawalInfoServiceDaoImpl.getOwnerWithdrawalInfo",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
if (result != null) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询业主支取信息成功");
|
resJson.put("data", result);
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "未找到对应业主支取记录");
|
}
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 根据mpId查询业主支取信息
|
*
|
* @param mpId 业务标识
|
* @return 响应结果
|
* @serviceCode /ownerWithdrawalInfo/getOwnerWithdrawalInfoByMpId
|
* @path /app/ownerWithdrawalInfo/getOwnerWithdrawalInfoByMpId
|
*/
|
@RequestMapping(value = "/getOwnerWithdrawalInfoByMpId", method = RequestMethod.GET)
|
public ResponseEntity<String> getOwnerWithdrawalInfoByMpId(@RequestParam(value = "mpId") String mpId) {
|
Assert.hasLength(mpId, "业务标识mpId不能为空");
|
|
OwnerWithdrawalInfoPo queryPo = new OwnerWithdrawalInfoPo();
|
queryPo.setMpId(mpId);
|
|
List<Map<String, Object>> result = sqlSessionTemplate.selectList(
|
"ownerWithdrawalInfoServiceDaoImpl.getOwnerWithdrawalInfo",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询业主支取信息成功");
|
resJson.put("data", result);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 统计业主支取信息
|
*
|
* @param mpId 业务标识(可选)
|
* @param startCreateTime 开始创建时间(可选,格式:yyyy-MM-dd HH:mm:ss)
|
* @param endCreateTime 结束创建时间(可选)
|
* @return 响应结果
|
* @serviceCode /ownerWithdrawalInfo/queryOwnerWithdrawalInfoStatistics
|
* @path /app/ownerWithdrawalInfo/queryOwnerWithdrawalInfoStatistics
|
*/
|
@RequestMapping(value = "/queryOwnerWithdrawalInfoStatistics", method = RequestMethod.GET)
|
public ResponseEntity<String> queryOwnerWithdrawalInfoStatistics(
|
@RequestParam(value = "mpId", required = false) String mpId,
|
@RequestParam(value = "startCreateTime", required = false) String startCreateTime,
|
@RequestParam(value = "endCreateTime", required = false) String endCreateTime) {
|
|
OwnerWithdrawalInfoPo queryPo = new OwnerWithdrawalInfoPo();
|
queryPo.setMpId(mpId);
|
queryPo.setStartCreateTime(startCreateTime);
|
queryPo.setEndCreateTime(endCreateTime);
|
|
// 统计查询
|
Map<String, Object> statistics = sqlSessionTemplate.selectOne(
|
"ownerWithdrawalInfoServiceDaoImpl.queryOwnerWithdrawalInfoStatistics",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "统计业主支取信息成功");
|
resJson.put("data", statistics);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
}
|