Commit d8bb0670 by 陶光胜

配置表

parent ee9e0bd1
......@@ -64,4 +64,6 @@ public interface TabTableSettingFieldMapper {
* @throws
*/
List<TabTableSettingField> listField(@Param("tableId") Integer tableId);
TabTableSettingField getFieldByKey(@Param("tableId") Integer tableId, @Param("fieldKey") String fieldKey);
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ import com.gic.enterprise.dto.TableSettingFieldDTO;
import java.util.List;
public interface TableSettingFieldService {
void saveTableField(TableSettingFieldDTO tableSettingFieldDTO);
String saveTableField(TableSettingFieldDTO tableSettingFieldDTO);
List<TableSettingFieldDTO> listTableField(Integer tableId);
......
......@@ -17,16 +17,26 @@ public class TableSettingFieldServiceImpl implements TableSettingFieldService {
private TabTableSettingFieldMapper tabTableSettingFieldMapper;
@Override
public void saveTableField(TableSettingFieldDTO tableSettingFieldDTO) {
public String saveTableField(TableSettingFieldDTO tableSettingFieldDTO) {
TabTableSettingField tab = EntityUtil.changeEntityByJSON(TabTableSettingField.class, tableSettingFieldDTO);
Date date = new Date();
tableSettingFieldDTO.setUpdateTime(date);
if(tableSettingFieldDTO.getFieldId() != null){
tab.setUpdateTime(date);
TabTableSettingField field = tabTableSettingFieldMapper.getFieldByKey(tab.getTableId(), tab.getFieldKey());
if(tab.getFieldId() != null){
if(field != null){
if(field.getFieldId() != tab.getFieldId()){
return "该字段已经存在";
}
}
tabTableSettingFieldMapper.updateByPrimaryKeySelective(tab);
} else {
tableSettingFieldDTO.setCreateTime(date);
if(field != null){
return "该字段已经存在";
}
tab.setCreateTime(date);
tabTableSettingFieldMapper.insertSelective(tab);
}
return null;
}
@Override
......
......@@ -54,8 +54,11 @@ public class TableSettingApiServiceImpl implements TableSettingApiService {
@Override
public ServiceResponse<Void> saveTableField(TableSettingFieldDTO fieldDTO) {
tableSettingFieldService.saveTableField(fieldDTO);
return ServiceResponse.success();
String result = tableSettingFieldService.saveTableField(fieldDTO);
if(StringUtils.isBlank(result)){
return ServiceResponse.success();
}
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), result);
}
@Override
......
......@@ -133,4 +133,11 @@
from tab_table_setting_field
where table_id = #{tableId,jdbcType=INTEGER} and delete_flag = 0
</select>
<select id="getFieldByKey" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_table_setting_field
where table_id = #{tableId,jdbcType=INTEGER} and delete_flag = 0 and field_key = #{fieldKey}
</select>
</mapper>
\ No newline at end of file
......@@ -39,7 +39,7 @@ public class TableSettingController {
@RequestMapping("page-table-setting")
@ResponseBody
public RestResponse pageTableSetting(String search, @RequestParam(defaultValue = 1) Integer pageNum, @RequestParam(defaultValue = 20) Integer pageSize){
public RestResponse pageTableSetting(String search, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "20") Integer pageSize){
Page<TableSettingDTO> result = tableSettingApiService.pageTableSetting(search, pageNum, pageSize).getResult();
return RestResponse.success(result);
}
......@@ -62,8 +62,11 @@ public class TableSettingController {
@ResponseBody
public RestResponse addTableField(TableSettingFieldQO qo){
TableSettingFieldDTO tableSettingFieldDTO = EntityUtil.changeEntityByJSON(TableSettingFieldDTO.class, qo);
tableSettingApiService.saveTableField(tableSettingFieldDTO);
return RestResponse.success();
ServiceResponse<Void> response = tableSettingApiService.saveTableField(tableSettingFieldDTO);
if(response.isSuccess()){
return RestResponse.success();
}
return EnterpriseRestResponse.failure(response);
}
@RequestMapping("list-table-field")
......
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