Commit 9d438574 authored by 王夏晖's avatar 王夏晖

建筑分区后台维护

parent 0ca50697
...@@ -2,13 +2,16 @@ package org.rcisoft.business.manage.controller; ...@@ -2,13 +2,16 @@ package org.rcisoft.business.manage.controller;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.manage.entity.BusFactory;
import org.rcisoft.business.manage.entity.BusProjectZone;
import org.rcisoft.business.manage.service.BusProjectZoneService; import org.rcisoft.business.manage.service.BusProjectZoneService;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result; import org.rcisoft.core.result.Result;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/** /**
* Created by JiChao on 2018/5/7. * Created by JiChao on 2018/5/7.
...@@ -21,6 +24,31 @@ public class BusProjectZoneController { ...@@ -21,6 +24,31 @@ public class BusProjectZoneController {
@Autowired @Autowired
private BusProjectZoneService busProjectZoneServiceImpl; private BusProjectZoneService busProjectZoneServiceImpl;
@ApiOperation(value="添加", notes="添加")
@PostMapping(value = "/add")
public Result add(@Valid BusProjectZone busProjectZone) {
PersistModel data = busProjectZoneServiceImpl.save(busProjectZone);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busProjectZone);
}
@ApiOperation(value="修改", notes="修改")
@PutMapping("/update")
public Result update(@Valid BusProjectZone busProjectZone) {
PersistModel data = busProjectZoneServiceImpl.merge(busProjectZone);
return Result.builder(data);
}
@ApiOperation(value="删除", notes="删除")
@DeleteMapping("/delete")
public Result delete(@RequestParam String id) {
PersistModel data = busProjectZoneServiceImpl.delete(id);
return Result.builder(data);
}
@ApiOperation(value="查询建筑分区", notes="查询建筑分区") @ApiOperation(value="查询建筑分区", notes="查询建筑分区")
@RequestMapping("/getZone") @RequestMapping("/getZone")
public Result getZone() { public Result getZone() {
......
package org.rcisoft.business.manage.service; package org.rcisoft.business.manage.service;
import org.rcisoft.business.manage.entity.BusFactory;
import org.rcisoft.business.manage.entity.BusProjectZone; import org.rcisoft.business.manage.entity.BusProjectZone;
import org.rcisoft.core.model.PersistModel;
import java.util.List; import java.util.List;
...@@ -9,6 +11,23 @@ import java.util.List; ...@@ -9,6 +11,23 @@ import java.util.List;
*/ */
public interface BusProjectZoneService { public interface BusProjectZoneService {
/**
* 保存
* @return
*/
PersistModel save(BusProjectZone busProjectZone);
/**
* 修改
* @return
*/
PersistModel merge(BusProjectZone busProjectZone);
/**
* 删除
* @return
*/
PersistModel delete(String id);
/** /**
* 查询建筑分区 * 查询建筑分区
* @return * @return
......
package org.rcisoft.business.manage.service.impl; package org.rcisoft.business.manage.service.impl;
import org.rcisoft.business.manage.dao.BusProjectZoneRepository; import org.rcisoft.business.manage.dao.BusProjectZoneRepository;
import org.rcisoft.business.manage.entity.BusFactory;
import org.rcisoft.business.manage.entity.BusProjectZone; import org.rcisoft.business.manage.entity.BusProjectZone;
import org.rcisoft.business.manage.service.BusProjectZoneService; import org.rcisoft.business.manage.service.BusProjectZoneService;
import org.rcisoft.core.model.PersistModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* Created by JiChao on 2018/5/7. * Created by JiChao on 2018/5/7.
...@@ -17,6 +21,44 @@ public class BusProjectZoneServiceImpl implements BusProjectZoneService { ...@@ -17,6 +21,44 @@ public class BusProjectZoneServiceImpl implements BusProjectZoneService {
@Autowired @Autowired
private BusProjectZoneRepository busProjectZoneRepository; private BusProjectZoneRepository busProjectZoneRepository;
@Override
public PersistModel save(BusProjectZone busProjectZone) {
//增加操作
busProjectZone.setBldZoneId(UUID.randomUUID().toString().replace("-",""));
int line = busProjectZoneRepository.insertSelective(busProjectZone);
return new PersistModel(line);
}
@Override
public PersistModel merge(BusProjectZone busProjectZone) {
Integer line = 0;
String message = "";
Example example = new Example(BusFactory.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("bldZoneId",busProjectZone.getBldZoneId());
if(busProjectZone.getBldZoneId()!=null && !busProjectZone.getBldZoneId().equals("")){
line = busProjectZoneRepository.updateByExampleSelective(busProjectZone,example);
}else{
message = "ID为空,更新失败";
}
return new PersistModel(line,message);
}
@Override
public PersistModel delete(String id) {
Integer line = 0;
String message = "";
Example example = new Example(BusProjectZone.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("bldZoneId",id);
if(id!=null && !id.equals("")){
line = busProjectZoneRepository.deleteByExample(example);
}else{
message = "ID为空,删除失败";
}
return new PersistModel(line,message);
}
@Override @Override
public List<BusProjectZone> getZone() { public List<BusProjectZone> getZone() {
return busProjectZoneRepository.selectAll(); return busProjectZoneRepository.selectAll();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment