|
@@ -0,0 +1,165 @@
|
|
|
+package cn.com.ty.lift.enterprise.custom.controller;
|
|
|
+
|
|
|
+import cn.com.ty.lift.enterprise.custom.entity.PropertyCompany;
|
|
|
+import cn.com.ty.lift.enterprise.custom.service.impl.PropertyCompanyServiceImpl;
|
|
|
+import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/property-company")
|
|
|
+@AllArgsConstructor
|
|
|
+/**
|
|
|
+ * @author wang-hai-cheng
|
|
|
+ * @date 2019/11/27
|
|
|
+ * @description
|
|
|
+ * 客户接口(物业公司)(甲方公司) 前端控制器
|
|
|
+ */
|
|
|
+public class PropertyCompanyController {
|
|
|
+ private final PropertyCompanyServiceImpl propertyCompanyService;
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ /**
|
|
|
+ * @description id顺序+分页客户列表
|
|
|
+ * @date 2019/11/27 11:33
|
|
|
+ * @param [current, size]
|
|
|
+ * @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
+ */
|
|
|
+ public RestResponse page(@RequestParam Integer current,@RequestParam Integer size) {
|
|
|
+ Page<PropertyCompany> page = new Page<>(current, size);
|
|
|
+ return RestResponse.ok(propertyCompanyService.page(page).getRecords(), "查询成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ /**
|
|
|
+ * @description 根据id获取客户详细信息
|
|
|
+ * @date 2019/11/27 11:36
|
|
|
+ * @param [id]
|
|
|
+ * @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
+ */
|
|
|
+ public RestResponse propertyCompany(@PathVariable int id) {
|
|
|
+ PropertyCompany byId = propertyCompanyService.getById(id);
|
|
|
+ if (byId != null) {
|
|
|
+ return RestResponse.ok(byId, "查询成功");
|
|
|
+ } else {
|
|
|
+ return RestResponse.ok(null,"无数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/name")
|
|
|
+ /**
|
|
|
+ * @description 根据客户名称分页获取客户列表
|
|
|
+ * @date 2019/11/27 11:37
|
|
|
+ * @param [name, current, size]
|
|
|
+ * @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
+ */
|
|
|
+ public RestResponse propertyCompaniesFromName(@RequestParam String name,@RequestParam Integer current,@RequestParam Integer size) {
|
|
|
+ Page<PropertyCompany> page = new Page<>(current, size);
|
|
|
+ List<PropertyCompany> propertyCompanies = propertyCompanyService.page(page, new QueryWrapper<PropertyCompany>().like("name",name)).getRecords();
|
|
|
+ if (null != propertyCompanies) {
|
|
|
+ return RestResponse.ok(propertyCompanies, "查询成功");
|
|
|
+ } else {
|
|
|
+ return RestResponse.ok(null,"未搜索到客户");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/address")
|
|
|
+ /**
|
|
|
+ * @description 根据客户地址分页获取客户列表
|
|
|
+ * @date 2019/11/27 11:38
|
|
|
+ * @param [address, current, size]
|
|
|
+ * @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
+ */
|
|
|
+ public RestResponse propertyCompaniesFromAddress(@RequestParam String address,@RequestParam Integer current,@RequestParam Integer size) {
|
|
|
+ Page<PropertyCompany> page = new Page<>(current, size);
|
|
|
+ List<PropertyCompany> propertyCompanies = propertyCompanyService.page(page, new QueryWrapper<PropertyCompany>().like("address",address)).getRecords();
|
|
|
+ if (null != propertyCompanies) {
|
|
|
+ return RestResponse.ok(propertyCompanies,"查询成功");
|
|
|
+ } else {
|
|
|
+ return RestResponse.ok(null,"未搜索到客户");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/phone")
|
|
|
+ /**
|
|
|
+ * @description 根据客户电话分页获取客户列表
|
|
|
+ * @date 2019/11/27 11:39
|
|
|
+ * @param [phone, current, size]
|
|
|
+ * @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
+ */
|
|
|
+ public RestResponse propertyCompaniesFromPhone(@RequestParam String phone,@RequestParam Integer current,@RequestParam Integer size) {
|
|
|
+ Page<PropertyCompany> page = new Page<>(current, size);
|
|
|
+ List<PropertyCompany> propertyCompanies = propertyCompanyService.page(page, new QueryWrapper<PropertyCompany>().like("telephone",phone)).getRecords();
|
|
|
+ if (null != propertyCompanies) {
|
|
|
+ return RestResponse.ok(propertyCompanies,"查询成功");
|
|
|
+ } else {
|
|
|
+ return RestResponse.ok(null,"未搜索到客户");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ /**
|
|
|
+ * @description 新增客户
|
|
|
+ * @date 2019/11/27 11:45
|
|
|
+ * @param [propertyCompany]
|
|
|
+ * @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
+ */
|
|
|
+ public RestResponse add(@RequestBody PropertyCompany propertyCompany) {
|
|
|
+ String s = propertyCompanyService.savePropertyCompany(propertyCompany);
|
|
|
+ if (s.equals("新增客户成功")) {
|
|
|
+ return RestResponse.ok(null,"新增客户成功");
|
|
|
+ }else if (s.equals("新增客户失败")){
|
|
|
+ return RestResponse.ok(null,"新增客户失败");
|
|
|
+ }else {
|
|
|
+ return RestResponse.ok(null,"客户已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/update")
|
|
|
+ /**
|
|
|
+ * @description 更新客户信息
|
|
|
+ * @date 2019/11/27 11:45
|
|
|
+ * @param [propertyCompany]
|
|
|
+ * @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
+ */
|
|
|
+ public RestResponse update( PropertyCompany propertyCompany) {
|
|
|
+ if (propertyCompanyService.updateById(propertyCompany)) {
|
|
|
+ return RestResponse.ok(null,"更新成功");
|
|
|
+ } else {
|
|
|
+ return RestResponse.ok(null,"更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/delete/{id}")
|
|
|
+ /**
|
|
|
+ * @description RestResponse
|
|
|
+ * @date 2019/11/27 11:46
|
|
|
+ * @param [id]
|
|
|
+ * @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
+ */
|
|
|
+ public RestResponse delete(@PathVariable int id) {
|
|
|
+
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //判断维保电梯台数是否为0
|
|
|
+ //也就是客户公司创建的所有项目的总电梯的在保电梯是否为0
|
|
|
+
|
|
|
+ if (propertyCompanyService.delete(id)) {
|
|
|
+ return RestResponse.ok(null,"删除成功");
|
|
|
+ } else {
|
|
|
+ return RestResponse.ok(null,"删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|