Commit 2b2e87a1 authored by jichao's avatar jichao

评估--节能改造--认定 更改接口

parent caffdb36
...@@ -7,15 +7,16 @@ import io.swagger.annotations.ApiOperation; ...@@ -7,15 +7,16 @@ import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.manage.entity.BusSaving; import org.rcisoft.business.manage.entity.BusSaving;
import org.rcisoft.business.manage.service.BusSavingService; import org.rcisoft.business.manage.service.BusSavingService;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.controller.PaginationController;
import org.rcisoft.core.model.GridModel;
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.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import javax.validation.Valid;
/** /**
* Created by JiChao on 2018/5/17. * Created by JiChao on 2018/5/17.
...@@ -23,32 +24,61 @@ import java.util.List; ...@@ -23,32 +24,61 @@ import java.util.List;
@Api(tags = "评估--节能改造--认定") @Api(tags = "评估--节能改造--认定")
@RestController @RestController
@RequestMapping("bussaving") @RequestMapping("bussaving")
public class BusSavingController { public class BusSavingController extends PaginationController<BusSaving> {
@Autowired @Autowired
private BusSavingService busSavingServiceImpl; private BusSavingService busSavingServiceImpl;
@ApiOperation(value="修改", notes="传list对象") @ApiOperation(value="增加", notes="增加")
/* @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "字符串"), @ApiImplicitParams({
@ApiImplicitParam(name = "examiner", value = "检定员", dataType = "字符串"),
@ApiImplicitParam(name = "qualification", value = "执业资质", dataType = "字符串"),
@ApiImplicitParam(name = "tm", value = "从业时间", dataType = "字符串"),
@ApiImplicitParam(name = "performance", value = "项目业绩", dataType = "字符串")
})
@RequestMapping("/save")
public Result save(@Valid BusSaving busSaving) {
Integer result = busSavingServiceImpl.save(busSaving);
return Result.builder(new PersistModel(result), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, result);
}
@ApiOperation(value="修改", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "字符串"),
@ApiImplicitParam(name = "examiner", value = "检定员", dataType = "字符串"), @ApiImplicitParam(name = "examiner", value = "检定员", dataType = "字符串"),
@ApiImplicitParam(name = "qualification", value = "执业资质", dataType = "字符串"), @ApiImplicitParam(name = "qualification", value = "执业资质", dataType = "字符串"),
@ApiImplicitParam(name = "tm", value = "从业时间", dataType = "字符串"), @ApiImplicitParam(name = "tm", value = "从业时间", dataType = "字符串"),
@ApiImplicitParam(name = "performance", value = "项目业绩", dataType = "字符串"), @ApiImplicitParam(name = "performance", value = "项目业绩", dataType = "字符串")
@ApiImplicitParam(name = "type", value = "1:工程造价认定,2:节能认定", dataType = "字符串"), })
@ApiImplicitParam(name = "proId", value = "项目表主键", dataType = "字符串,可以不传")
})*/
@RequestMapping("/update") @RequestMapping("/update")
public Result update(@RequestBody List<BusSaving> busSavingList) { public Result update(@Valid BusSaving busSaving) {
return Result.builder(busSavingServiceImpl.update(busSavingList)); Integer result = busSavingServiceImpl.update(busSaving);
return Result.builder(new PersistModel(result), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, result);
}
@ApiOperation(value="删除", notes="删除")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "字符串")
})
@RequestMapping("/delete/{id:\\w+}")
public Result delete(@PathVariable String id) {
Integer result = busSavingServiceImpl.delete(id);
return Result.builder(new PersistModel(result), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, result);
}
@ApiOperation(value="分页查询", notes="分页查询")
@RequestMapping("/findAllByPagination")
public GridModel findAllByPagination() {
busSavingServiceImpl.findAllByPagination(getPaginationUtility());
return getGridModelResponse();
} }
@ApiOperation(value="查询", notes="2条记录,工程造价认定、节能认定") @ApiOperation(value="根据id查找", notes="根据id查找")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "proId", value = "项目表主键", required = true, dataType = "字符串") @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "字符串")
}) })
@RequestMapping("/queryBusSaving/{proId:\\w+}") @RequestMapping("/findBusSaving/{id:\\w+}")
public Result queryBusSaving(@PathVariable String proId) { public Result findBusSaving(@PathVariable String id) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, busSavingServiceImpl.queryBusSaving(proId)); return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, busSavingServiceImpl.findBusSaving(id));
} }
} }
...@@ -25,7 +25,7 @@ public class BusSaving { ...@@ -25,7 +25,7 @@ public class BusSaving {
private String qualification; private String qualification;
private String tm; private String tm;
private String performance; private String performance;
private String type; // private String type;
private String proId; // private String proId;
} }
package org.rcisoft.business.manage.service; package org.rcisoft.business.manage.service;
import org.rcisoft.business.manage.entity.BusSaving; import org.rcisoft.business.manage.entity.BusSaving;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import java.util.List; import java.util.List;
...@@ -14,24 +15,30 @@ public interface BusSavingService { ...@@ -14,24 +15,30 @@ public interface BusSavingService {
* 保存 * 保存
* @return * @return
*/ */
PersistModel save(List<BusSaving> busSavingList); Integer save(BusSaving busSaving);
/** /**
* 修改 * 修改
* @return * @return
*/ */
PersistModel update(List<BusSaving> busSavingList); Integer update(BusSaving busSaving);
/** /**
* 删除 * 删除
* @return * @return
*/ */
PersistModel delete(String proId); Integer delete(String id);
/**
* 分页查询
* @return
*/
List<BusSaving> findAllByPagination(PageUtil<BusSaving> paginationUtility);
/** /**
* 根据proId查询 * 查询单条
* @param id
* @return * @return
*/ */
List<BusSaving> queryBusSaving(String proId); BusSaving findBusSaving(String id);
} }
...@@ -5,6 +5,7 @@ import org.rcisoft.business.manage.dao.BusSavingRepository; ...@@ -5,6 +5,7 @@ import org.rcisoft.business.manage.dao.BusSavingRepository;
import org.rcisoft.business.manage.entity.BusSaving; import org.rcisoft.business.manage.entity.BusSaving;
import org.rcisoft.business.manage.service.BusSavingService; import org.rcisoft.business.manage.service.BusSavingService;
import org.rcisoft.business.overview.entity.BusProjectArea; import org.rcisoft.business.overview.entity.BusProjectArea;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel; 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;
...@@ -12,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -12,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* Created by JiChao on 2018/5/17. * Created by JiChao on 2018/5/17.
...@@ -24,56 +26,40 @@ public class BusSavingServiceImpl implements BusSavingService { ...@@ -24,56 +26,40 @@ public class BusSavingServiceImpl implements BusSavingService {
@Transactional @Transactional
@Override @Override
public PersistModel save(List<BusSaving> busSavingList) { public Integer save(BusSaving busSaving) {
int result = 0; String id = UUID.randomUUID().toString().replaceAll("-", "");
for (BusSaving busSaving : busSavingList) { busSaving.setId(id);
result += busSavingRepository.insertSelective(busSaving); return busSavingRepository.insertSelective(busSaving);
}
return new PersistModel(result);
} }
@Transactional @Transactional
@Override @Override
public PersistModel update(List<BusSaving> busSavingList) { public Integer update(BusSaving busSaving) {
int result = 0; Example example = new Example(BusSaving.class);
String message = ""; Example.Criteria criteria = example.createCriteria();
for (BusSaving busSaving : busSavingList) { criteria.andEqualTo("id", busSaving.getId());
String id = busSaving.getId(); return busSavingRepository.updateByExampleSelective(busSaving, example);
if (StringUtils.isNotEmpty(id)) {
Example example = new Example(BusSaving.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
result += busSavingRepository.updateByExampleSelective(busSaving, example);
message = "更新成功";
} else {
message = "ID为空,更新失败";
}
}
return new PersistModel(result, message);
} }
@Transactional @Transactional
@Override @Override
public PersistModel delete(String proId) { public Integer delete(String id) {
int result = 0;
String message = "";
Example example = new Example(BusSaving.class); Example example = new Example(BusSaving.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
if (StringUtils.isNotEmpty(proId)) { criteria.andEqualTo("id", id);
criteria.andEqualTo("proId", proId); return busSavingRepository.deleteByExample(example);
result += busSavingRepository.deleteByExample(example);
message = "删除成功";
} else {
message = "项目ID为空,删除失败";
}
return new PersistModel(result, message);
} }
@Override @Override
public List<BusSaving> queryBusSaving(String proId) { public List<BusSaving> findAllByPagination(PageUtil<BusSaving> paginationUtility) {
Example example = new Example(BusSaving.class); return busSavingRepository.selectAll();
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("proId", proId);
return busSavingRepository.selectByExample(example);
} }
@Override
public BusSaving findBusSaving(String id) {
BusSaving busSaving = new BusSaving();
busSaving.setId(id);
return busSavingRepository.selectOne(busSaving);
}
} }
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<result column="QUALIFICATION" jdbcType="VARCHAR" property="qualification"/> <result column="QUALIFICATION" jdbcType="VARCHAR" property="qualification"/>
<result column="TM" jdbcType="VARCHAR" property="tm"/> <result column="TM" jdbcType="VARCHAR" property="tm"/>
<result column="PERFORMANCE" jdbcType="VARCHAR" property="performance"/> <result column="PERFORMANCE" jdbcType="VARCHAR" property="performance"/>
<result column="TYPE" jdbcType="VARCHAR" property="type"/> <!--<result column="TYPE" jdbcType="VARCHAR" property="type"/>-->
<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/> <!--<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>-->
</resultMap> </resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>--> <!--<cache type="${corePackag!}.util.RedisCache"/>-->
......
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