Browse Source

commit code

master
刘力 3 years ago
parent
commit
19246f40a6
  1. 23
      archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java
  2. 15
      archives/src/main/java/com/storeroom/modules/dictionary/domain/ArchivesDictionary.java
  3. 8
      archives/src/main/java/com/storeroom/modules/dictionary/domain/Dictionary.java
  4. 7
      archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java
  5. 8
      archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java
  6. 14
      archives/src/main/java/com/storeroom/modules/dictionary/service/dto/ArchivesDictionaryDTO.java
  7. 6
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java

23
archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java

@ -3,6 +3,7 @@ package com.storeroom.modules.dictionary.controller;
import com.storeroom.annotaion.rest.AnonymousGetMapping; import com.storeroom.annotaion.rest.AnonymousGetMapping;
import com.storeroom.annotaion.rest.AnonymousPostMapping; import com.storeroom.annotaion.rest.AnonymousPostMapping;
import com.storeroom.annotaion.rest.AnonymousPutMapping;
import com.storeroom.exception.BaseException; import com.storeroom.exception.BaseException;
import com.storeroom.exception.constant.ResponseStatus; import com.storeroom.exception.constant.ResponseStatus;
import com.storeroom.modules.common.ArchivesTypeEnum; import com.storeroom.modules.common.ArchivesTypeEnum;
@ -12,6 +13,7 @@ import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO; import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import com.storeroom.utils.ApiResponse; import com.storeroom.utils.ApiResponse;
import com.storeroom.utils.StringUtils; import com.storeroom.utils.StringUtils;
import com.storeroom.utils.ValidationUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -90,12 +92,29 @@ public class ArchivesTypeController {
} }
@ApiOperation("修改数据") @ApiOperation("修改数据")
@AnonymousPostMapping("update")
public ApiResponse<Object> update(@RequestBody ArchivesDictionaryDTO arcdicDto) {
@AnonymousPutMapping("update")
public ApiResponse<Object> update(@RequestBody ArchivesDictionaryDTO arcdicDto) throws Exception {
if (!StringUtils.isEmpty(arcdicDto.getId())) { if (!StringUtils.isEmpty(arcdicDto.getId())) {
archivesDictionaryService.update(arcdicDto); archivesDictionaryService.update(arcdicDto);
return ApiResponse.success(ResponseStatus.SUCCESS); return ApiResponse.success(ResponseStatus.SUCCESS);
} }
throw new BaseException("id异常"); throw new BaseException("id异常");
} }
@ApiOperation("创建门类字典")
@AnonymousPostMapping("createDic")
public ApiResponse<Object> createDic(ArchivesDictionaryDTO arcdicDto){
if (!StringUtils.isEmpty(arcdicDto.getId())){
throw new BaseException("id添加异常");
}
if (!StringUtils.isEmpty(arcdicDto.getFieldCnName()) || StringUtils.isEmpty(arcdicDto.getFieldName())){
throw new BaseException("字段名字不能为空");
}
if (!StringUtils.isEmpty(arcdicDto.getDictionaryConfigId())){
throw new BaseException("系统字典不能为空");
}
archivesDictionaryService.create(arcdicDto);
return ApiResponse.success(ResponseStatus.SUCCESS);
}
} }

15
archives/src/main/java/com/storeroom/modules/dictionary/domain/ArchivesDictionary.java

@ -28,15 +28,10 @@ public class ArchivesDictionary extends BaseEntity implements Serializable {
@Column(name = "category_id") @Column(name = "category_id")
private String categoryId; private String categoryId;
@ManyToOne
@ApiModelProperty(value = "系统字典id") @ApiModelProperty(value = "系统字典id")
@Column(name = "sys_dictionary_id")
private String sysDictionaryId;
// @OneToMany(mappedBy = "",cascade = {CascadeType.PERSIST,CascadeType.REMOVE})
// private List<Category> category_id;
// @OneToMany(mappedBy = "archivesDictionary",cascade = {CascadeType.PERSIST,CascadeType.REMOVE})
// private List<Dictionary> sysDictionaryId;
@JoinColumn(name = "dictionary_config_id")
private Dictionary dictionaryConfig;
@ApiModelProperty(value = "字段名称") @ApiModelProperty(value = "字段名称")
@Column(name = "field_name") @Column(name = "field_name")
@ -154,11 +149,11 @@ public class ArchivesDictionary extends BaseEntity implements Serializable {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
ArchivesDictionary that = (ArchivesDictionary) o; ArchivesDictionary that = (ArchivesDictionary) o;
return Objects.equals(id, that.id) && Objects.equals(categoryId, that.categoryId) && Objects.equals(sysDictionaryId, that.sysDictionaryId) && Objects.equals(fieldName, that.fieldName) && Objects.equals(fieldCnName, that.fieldCnName) && Objects.equals(isDefaultValue, that.isDefaultValue) && Objects.equals(isInputClass, that.isInputClass) && Objects.equals(isDataType, that.isDataType) && Objects.equals(isDataTypeDetails, that.isDataTypeDetails) && Objects.equals(isColumnLength, that.isColumnLength) && Objects.equals(isColumnType, that.isColumnType) && Objects.equals(isSequence, that.isSequence) && Objects.equals(isType, that.isType) && Objects.equals(isSystem, that.isSystem) && Objects.equals(isLine, that.isLine) && Objects.equals(isInput, that.isInput) && Objects.equals(isRequired, that.isRequired) && Objects.equals(isAutomatic, that.isAutomatic) && Objects.equals(isAdd, that.isAdd) && Objects.equals(isSearch, that.isSearch) && Objects.equals(isInherit, that.isInherit) && Objects.equals(isFilling, that.isFilling) && Objects.equals(fillingDigit, that.fillingDigit) && Objects.equals(isRepeat, that.isRepeat) && Objects.equals(isDisplay, that.isDisplay) && Objects.equals(displayOrder, that.displayOrder) && Objects.equals(isDisplayformat, that.isDisplayformat) && Objects.equals(displayformatType, that.displayformatType) && Objects.equals(editLength, that.editLength) && Objects.equals(displayLength, that.displayLength);
return Objects.equals(id, that.id) && Objects.equals(categoryId, that.categoryId) && Objects.equals(dictionaryConfig, that.dictionaryConfig) && Objects.equals(fieldName, that.fieldName) && Objects.equals(fieldCnName, that.fieldCnName) && Objects.equals(isDefaultValue, that.isDefaultValue) && Objects.equals(isInputClass, that.isInputClass) && Objects.equals(isDataType, that.isDataType) && Objects.equals(isDataTypeDetails, that.isDataTypeDetails) && Objects.equals(isColumnLength, that.isColumnLength) && Objects.equals(isColumnType, that.isColumnType) && Objects.equals(isSequence, that.isSequence) && Objects.equals(isType, that.isType) && Objects.equals(isSystem, that.isSystem) && Objects.equals(isLine, that.isLine) && Objects.equals(isInput, that.isInput) && Objects.equals(isRequired, that.isRequired) && Objects.equals(isAutomatic, that.isAutomatic) && Objects.equals(isAdd, that.isAdd) && Objects.equals(isSearch, that.isSearch) && Objects.equals(isInherit, that.isInherit) && Objects.equals(isFilling, that.isFilling) && Objects.equals(fillingDigit, that.fillingDigit) && Objects.equals(isRepeat, that.isRepeat) && Objects.equals(isDisplay, that.isDisplay) && Objects.equals(displayOrder, that.displayOrder) && Objects.equals(isDisplayformat, that.isDisplayformat) && Objects.equals(displayformatType, that.displayformatType) && Objects.equals(editLength, that.editLength) && Objects.equals(displayLength, that.displayLength);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, categoryId, sysDictionaryId, fieldName, fieldCnName, isDefaultValue, isInputClass, isDataType, isDataTypeDetails, isColumnLength, isColumnType, isSequence, isType, isSystem, isLine, isInput, isRequired, isAutomatic, isAdd, isSearch, isInherit, isFilling, fillingDigit, isRepeat, isDisplay, displayOrder, isDisplayformat, displayformatType, editLength, displayLength);
return Objects.hash(id, categoryId, dictionaryConfig, fieldName, fieldCnName, isDefaultValue, isInputClass, isDataType, isDataTypeDetails, isColumnLength, isColumnType, isSequence, isType, isSystem, isLine, isInput, isRequired, isAutomatic, isAdd, isSearch, isInherit, isFilling, fillingDigit, isRepeat, isDisplay, displayOrder, isDisplayformat, displayformatType, editLength, displayLength);
} }
} }

8
archives/src/main/java/com/storeroom/modules/dictionary/domain/Dictionary.java

@ -24,14 +24,6 @@ public class Dictionary extends BaseEntity implements Serializable {
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
private String dicName; private String dicName;
/**
* 关联门类字典表 N:1
*
*/
// @JoinColumn(name = "id")
// @ManyToOne(fetch = FetchType.LAZY)
// @ApiModelProperty(value = "门类字典")
// private ArchivesDictionary archivesDictionary;
@Column(name = "dic_code") @Column(name = "dic_code")
@ApiModelProperty(value = "代码") @ApiModelProperty(value = "代码")

7
archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java

@ -18,12 +18,6 @@ public interface ArchivesDictionaryRepository extends JpaRepository<ArchivesDict
List<ArchivesDictionary> findAllByCategoryIdOrderByIsSequenceAsc(String categoryId); List<ArchivesDictionary> findAllByCategoryIdOrderByIsSequenceAsc(String categoryId);
// @Query(value = "INSERT INTO yxk_storeroom.archives_dictionary(id,category_id,field_name,field_cn_name,dictionary_id,is_data_type,is_data_type_details,is_column_length,is_sequence,is_type,is_system VALUES ())", nativeQuery = true)
// void insertData(String id,String categoryId,
// String fieldName,String fieldCnName,
// String isDefaultValue,Integer isDataType,
// String isDataTypeDetails,String isColumnLength,
// Integer isSequence,Integer isType,Integer isSystem);
@Query(value = "from ArchivesDictionary where categoryId = ?1 and isDisplay = true order by displayOrder asc") @Query(value = "from ArchivesDictionary where categoryId = ?1 and isDisplay = true order by displayOrder asc")
List<ArchivesDictionary> findDisPlay(String categoryId); List<ArchivesDictionary> findDisPlay(String categoryId);
@ -33,6 +27,7 @@ public interface ArchivesDictionaryRepository extends JpaRepository<ArchivesDict
* @param categoryId * @param categoryId
* @return * @return
*/ */
@Query(value = "",nativeQuery = true)
List<ArchivesDictionary> findByCategoryId(String categoryId); List<ArchivesDictionary> findByCategoryId(String categoryId);

8
archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java

@ -2,7 +2,6 @@ package com.storeroom.modules.dictionary.service;
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO; import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import java.util.List; import java.util.List;
@ -37,4 +36,11 @@ public interface ArchivesDictionaryService {
*/ */
void update(ArchivesDictionaryDTO arcdicDto); void update(ArchivesDictionaryDTO arcdicDto);
/**
* 创建门类字典
* @param arcdicDto
*/
void create(ArchivesDictionaryDTO arcdicDto);
} }

14
archives/src/main/java/com/storeroom/modules/dictionary/service/dto/ArchivesDictionaryDTO.java

@ -16,7 +16,7 @@ public class ArchivesDictionaryDTO extends BaseDTO implements Serializable {
private String categoryId; private String categoryId;
private String sysDictionaryId;
private String dictionaryConfigId;
private String fieldName; private String fieldName;
@ -72,4 +72,16 @@ public class ArchivesDictionaryDTO extends BaseDTO implements Serializable {
private Integer displayLength; private Integer displayLength;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ArchivesDictionaryDTO that = (ArchivesDictionaryDTO) o;
return Objects.equals(id, that.id) && Objects.equals(categoryId, that.categoryId) && Objects.equals(dictionaryConfigId, that.dictionaryConfigId) && Objects.equals(fieldName, that.fieldName) && Objects.equals(fieldCnName, that.fieldCnName) && Objects.equals(isDefaultValue, that.isDefaultValue) && Objects.equals(isInputClass, that.isInputClass) && Objects.equals(isDataType, that.isDataType) && Objects.equals(isDataTypeDetails, that.isDataTypeDetails) && Objects.equals(isColumnLength, that.isColumnLength) && Objects.equals(isColumnType, that.isColumnType) && Objects.equals(isSequence, that.isSequence) && Objects.equals(isType, that.isType) && Objects.equals(isSystem, that.isSystem) && Objects.equals(isLine, that.isLine) && Objects.equals(isInput, that.isInput) && Objects.equals(isRequired, that.isRequired) && Objects.equals(isAutomatic, that.isAutomatic) && Objects.equals(isAdd, that.isAdd) && Objects.equals(isSearch, that.isSearch) && Objects.equals(isInherit, that.isInherit) && Objects.equals(isFilling, that.isFilling) && Objects.equals(fillingDigit, that.fillingDigit) && Objects.equals(isRepeat, that.isRepeat) && Objects.equals(isDisplay, that.isDisplay) && Objects.equals(displayOrder, that.displayOrder) && Objects.equals(isDisplayformat, that.isDisplayformat) && Objects.equals(displayformatType, that.displayformatType) && Objects.equals(editLength, that.editLength) && Objects.equals(displayLength, that.displayLength);
}
@Override
public int hashCode() {
return Objects.hash(id, categoryId, dictionaryConfigId, fieldName, fieldCnName, isDefaultValue, isInputClass, isDataType, isDataTypeDetails, isColumnLength, isColumnType, isSequence, isType, isSystem, isLine, isInput, isRequired, isAutomatic, isAdd, isSearch, isInherit, isFilling, fillingDigit, isRepeat, isDisplay, displayOrder, isDisplayformat, displayformatType, editLength, displayLength);
}
} }

6
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java

@ -90,5 +90,11 @@ public class ArchivesDictionaryImpl implements ArchivesDictionaryService {
} }
@Override
public void create(ArchivesDictionaryDTO arcdicDto) {
arcdicDto.setId(NanoIdUtils.randomNanoId());
archivesDictionaryRepository.save(archivesDictionaryMapper.toEntity(arcdicDto));
}
} }
Loading…
Cancel
Save