package com.woniu.community.entity;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;@Data
@AllArgsConstructor
@NoArgsConstructor
public class Owner {private int id;private String userName;private String tel;//联系方式private String sex;private String identity;//身份证号private int houseId;private String remarks;//备注private String password;//密码private String houseNumbers;
}
package com.woniu.community.mapper;import com.woniu.community.entity.Owner;import java.util.List;public interface OwnerMapper {List selectAll(String tel,String identity,int start,int size);int count(String tel,String identity);int insertOwner(Owner owner);int deleteOwner(int id);int updateOwner(Owner owner);Owner selectById(int id);
}
package com.woniu.community.service;import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Owner;import java.util.List;public interface IOwnerService {/*** 查询所有* @param tel* @param identity* @param pageIndex* @param pageSize* @return*/HttpResult selectAll(String tel, String identity, int pageIndex, int pageSize);/*** 添加* @param owner* @return*/HttpResult insertOwner(Owner owner);/*** 删除* @param id* @return*/HttpResult deleteOwner(int id);/*** 修改* @param owner* @return*/HttpResult updateOwner(Owner owner);/*** 根据id查询* @param id* @return*/HttpResult selectById(int id);}
package com.woniu.community.service.impl;import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Owner;
import com.woniu.community.mapper.OwnerMapper;
import com.woniu.community.service.IOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class OwnerServiceImpl implements IOwnerService {@Autowired(required = false)private OwnerMapper ownerMapper;/*** 查询所有** @param tel* @param identity* @param pageIndex* @param pageSize* @return*/@Overridepublic HttpResult selectAll(String tel, String identity, int pageIndex, int pageSize) {HttpResult result=null;List owners = ownerMapper.selectAll(tel, identity, (pageIndex - 1) * pageSize, pageSize);int count = ownerMapper.count(tel, identity);if (owners!=null&&owners.size()>0){result=new HttpResult(owners,count,200,null);}else{result=new HttpResult(null,0,500,"没有更多数据");}return result;}/*** 添加** @param owner* @return*/@Overridepublic HttpResult insertOwner(Owner owner) {HttpResult result=null;int count = ownerMapper.insertOwner(owner);if (count>0){result=new HttpResult(null,0,200,"添加成功");}else{result=new HttpResult(null,0,500,"添加失败");}return result;}/*** 删除** @param id* @return*/@Overridepublic HttpResult deleteOwner(int id) {HttpResult result=null;int count = ownerMapper.deleteOwner(id);if (count>0){result=new HttpResult(null,0,200,"删除成功");}else{result=new HttpResult(null,0,500,"删除失败");}return result;}/*** 修改** @param owner* @return*/@Overridepublic HttpResult updateOwner(Owner owner) {HttpResult result=null;int count = ownerMapper.updateOwner(owner);if (count>0){result=new HttpResult(null,0,200,"修改成功");}else{result=new HttpResult(null,0,500,"修改失败");}return result;}/*** 根据id查询** @param id* @return*/@Overridepublic HttpResult selectById(int id) {HttpResult result=null;Owner owner = ownerMapper.selectById(id);if (owner!=null){result=new HttpResult(owner,0,200,null);}else{result=new HttpResult(null,0,500,null);}return result;}
}
package com.woniu.community.controller;import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Owner;
import com.woniu.community.service.IOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/owner")
@CrossOrigin(origins = "*")
public class OwnerController {@Autowiredprivate IOwnerService iOwnerService;@RequestMapping("/list")HttpResult selectAll(String tel, String identity, int pageIndex, int pageSize){return iOwnerService.selectAll(tel,identity,pageIndex,pageSize);}@RequestMapping("/add")HttpResult insertOwner(Owner owner){return iOwnerService.insertOwner(owner);}@RequestMapping("/delete")HttpResult deleteOwner(int id){return iOwnerService.deleteOwner(id);}@RequestMapping("/update")HttpResult updateOwner(Owner owner){return iOwnerService.updateOwner(owner);}@RequestMapping("/info")HttpResult selectById(int id){return iOwnerService.selectById(id);}
}
Title
Title
{{title}}房屋编号