update
This commit is contained in:
@ -75,6 +75,8 @@ public class UpdateLngContractPurPngPointDto implements Serializable {
|
||||
@ApiModelProperty("租户id")
|
||||
private Long tenantId;
|
||||
|
||||
private Boolean hasDel;
|
||||
|
||||
/**
|
||||
* lngContractPurPngPoint
|
||||
*/
|
||||
|
||||
@ -13,11 +13,20 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.google.api.client.util.Lists;
|
||||
import com.pictc.datalog.DataOperationContent;
|
||||
import com.pictc.datalog.DataOperationListener;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.pictc.enums.ExceptionCommonCode;
|
||||
import com.pictc.jdbc.JdbcTools;
|
||||
import com.pictc.jdbc.model.JdbcParam;
|
||||
import com.pictc.utils.StringUtils;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.module.contract.dto.LngContractPageDto;
|
||||
import com.xjrsoft.module.contract.dto.UpdateLngContractPurDto;
|
||||
import com.xjrsoft.module.contract.dto.UpdateLngContractPurPngPointDto;
|
||||
import com.xjrsoft.module.contract.dto.UpdateLngContractSalesPngPointDto;
|
||||
import com.xjrsoft.module.contract.service.IContractPurPngService;
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
|
||||
@ -71,7 +80,7 @@ public class ContractPurPngController {
|
||||
@ApiOperation(value = "新增LngContract")
|
||||
@SaCheckPermission("contractPurPng:add")
|
||||
public R add(@Valid @RequestBody UpdateLngContractPurDto dto){
|
||||
//UpdateLngContractPurDto res = dataService.insert(dto);
|
||||
|
||||
UpdateLngContractPurDto res = dataService.insert(dto, new DataOperationListener<UpdateLngContractPurDto>() {
|
||||
@Override
|
||||
public UpdateLngContractPurDto before(DataOperationContent<UpdateLngContractPurDto> content) {
|
||||
@ -80,7 +89,8 @@ public class ContractPurPngController {
|
||||
|
||||
@Override
|
||||
public UpdateLngContractPurDto after(DataOperationContent<UpdateLngContractPurDto> content) {
|
||||
return null;
|
||||
execAfter(content.getTableName(), content.getIdValue(), "I");
|
||||
return content.getObj();
|
||||
}
|
||||
});
|
||||
|
||||
@ -95,12 +105,29 @@ public class ContractPurPngController {
|
||||
boolean res = dataService.updateById(dto, new DataOperationListener<UpdateLngContractPurDto>() {
|
||||
@Override
|
||||
public UpdateLngContractPurDto before(DataOperationContent<UpdateLngContractPurDto> content) {
|
||||
return null;
|
||||
List<UpdateLngContractPurPngPointDto> list = dto.getLngContractPurPngPointList();
|
||||
for (UpdateLngContractPurPngPointDto dto : list) {
|
||||
if (dto.getHasDel()) {
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f before_delete_point(?)}",
|
||||
"pc_lng_contract_pur_png");
|
||||
List<JdbcParam> params = Lists.newArrayList();
|
||||
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
|
||||
params.add(outParam);
|
||||
params.add(JdbcParam.ofLong(dto.getId()));
|
||||
JdbcTools.call(sql,params);
|
||||
String error = outParam.getStringValue();
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
|
||||
}
|
||||
}
|
||||
}
|
||||
return content.getObj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngContractPurDto after(DataOperationContent<UpdateLngContractPurDto> content) {
|
||||
return null;
|
||||
execAfter(content.getTableName(), content.getIdValue(), "U");
|
||||
return content.getObj();
|
||||
}
|
||||
});
|
||||
return R.ok(res);
|
||||
@ -114,7 +141,17 @@ public class ContractPurPngController {
|
||||
boolean res = dataService.deleteByIds(UpdateLngContractPurDto.class,ids, new DataOperationListener<UpdateLngContractPurDto>() {
|
||||
@Override
|
||||
public UpdateLngContractPurDto before(DataOperationContent<UpdateLngContractPurDto> content) {
|
||||
return null;
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f_before_delete(?)}", content.getTableName());
|
||||
List<JdbcParam> params = Lists.newArrayList();
|
||||
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
|
||||
params.add(outParam);
|
||||
params.add(JdbcParam.ofLong(content.getIdValue()));
|
||||
JdbcTools.call(sql,params);
|
||||
String error = outParam.getStringValue();
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
|
||||
}
|
||||
return content.getObj();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,6 +161,22 @@ public class ContractPurPngController {
|
||||
});
|
||||
return R.ok(res);
|
||||
}
|
||||
|
||||
private void execAfter(String table, Long id, String sign) {
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f_save(?, ?)}", table);
|
||||
List<JdbcParam> params = Lists.newArrayList();
|
||||
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
|
||||
params.add(outParam);
|
||||
params.add(JdbcParam.ofLong(id));
|
||||
params.add(JdbcParam.ofString(sign));
|
||||
JdbcTools.call(sql,params);
|
||||
String error = outParam.getStringValue();
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_SAVE_EXEC_ERROR, error));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user