You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.2 KiB
66 lines
2.2 KiB
package {{ package.Controller }};
|
|
|
|
//VUE 固定引入 CommonEnums
|
|
import {{ package.Entity }}.CommonEnums;
|
|
import {{ package.Service }}.{{ table.entity }}Service;
|
|
import {{ package.Common }}.vo.Result;
|
|
|
|
//--- import 固定引入 ---//
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.validation.Valid;
|
|
import java.util.List;
|
|
//--- import 固定引入 ---//
|
|
|
|
/**
|
|
* <p>
|
|
* 后台枚举 前端控制器
|
|
* </p>
|
|
*
|
|
* @author tiger
|
|
* @since 2026-03-17
|
|
*/
|
|
@Api(tags = "公共方法对外接口")
|
|
@RestController
|
|
@RequestMapping("/model/common")
|
|
public class CommonController {
|
|
|
|
@Resource
|
|
private {{ table.entity }}Service {{table.lowerEntity}}Service;
|
|
|
|
|
|
@ApiOperation(value = "枚举列表查询", response = {{ table.entity }}.class)
|
|
@PostMapping(value = "/optionList")
|
|
public Result<?> optionList(@Valid @RequestBody {{ table.entity }} param,
|
|
@RequestHeader("token") String token,
|
|
@RequestHeader(value = "version", defaultValue = "1.0") String version) {
|
|
|
|
List<{{ table.entity }}> list = {{table.lowerEntity}}Service.list(param);
|
|
if (list == null) {
|
|
return Result.error("无数据");
|
|
}
|
|
List<CommonVueEnumsEntity> option = new ArrayList<>();
|
|
list.forEach(item -> {
|
|
AtomicReference<Boolean> isExt = new AtomicReference<>(false);
|
|
option.forEach(item2 -> {
|
|
if (item.getFieldName().equals(item2.getFieldName())
|
|
&& item.getFieldLabel().equals(item2.getFieldLabel())) {
|
|
item2.getOptions().add(item);
|
|
isExt.set(true);
|
|
}
|
|
});
|
|
if(!isExt.get()){
|
|
CommonVueEnumsEntity optionItem = new CommonVueEnumsEntity();
|
|
optionItem.setFieldName(item.getFieldName());
|
|
optionItem.setFieldLabel(item.getFieldLabel());
|
|
optionItem.setOptions(new ArrayList<>());
|
|
optionItem.getOptions().add(item);
|
|
option.add(optionItem);
|
|
}
|
|
});
|
|
return Result.OK( option );
|
|
}
|
|
}
|
|
|