新增采购入库功能
This commit is contained in:
@@ -5,9 +5,11 @@ import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.Dict;
|
||||
import com.gxwebsoft.common.system.entity.DictData;
|
||||
import com.gxwebsoft.common.system.param.DictDataParam;
|
||||
import com.gxwebsoft.common.system.service.DictDataService;
|
||||
import com.gxwebsoft.common.system.service.DictService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -28,6 +30,8 @@ import java.util.List;
|
||||
public class DictDataController extends BaseController {
|
||||
@Resource
|
||||
private DictDataService dictDataService;
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:dict:list')")
|
||||
@OperationLog
|
||||
@@ -53,26 +57,39 @@ public class DictDataController extends BaseController {
|
||||
return success(dictDataService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:dict:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加字典数据")
|
||||
@PostMapping()
|
||||
public ApiResult<?> add(@RequestBody DictData dictData) {
|
||||
if (dictDataService.count(new LambdaQueryWrapper<DictData>()
|
||||
.eq(DictData::getDictId, dictData.getDictId())
|
||||
.eq(DictData::getDictDataName, dictData.getDictDataName())) > 0) {
|
||||
return fail("字典数据名称已存在");
|
||||
}
|
||||
if (dictDataService.count(new LambdaQueryWrapper<DictData>()
|
||||
.eq(DictData::getDictId, dictData.getDictId())
|
||||
.eq(DictData::getDictDataCode, dictData.getDictDataCode())) > 0) {
|
||||
return fail("字典数据标识已存在");
|
||||
}
|
||||
if (dictDataService.save(dictData)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
@PreAuthorize("hasAuthority('sys:dict:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加字典数据")
|
||||
@PostMapping()
|
||||
public ApiResult<?> add(@RequestBody DictData dictData) {
|
||||
if (dictDataService.count(new LambdaQueryWrapper<DictData>()
|
||||
.eq(DictData::getDictId, dictData.getDictId())
|
||||
.eq(DictData::getDictDataName, dictData.getDictDataName())) > 0) {
|
||||
return fail("字典数据名称已存在");
|
||||
}
|
||||
if (dictDataService.count(new LambdaQueryWrapper<DictData>()
|
||||
.eq(DictData::getDictId, dictData.getDictId())
|
||||
.eq(DictData::getDictDataCode, dictData.getDictDataCode())) > 0) {
|
||||
return fail("字典数据标识已存在");
|
||||
}
|
||||
// 自动添加字典
|
||||
final int count = dictService.count(new LambdaQueryWrapper<Dict>().eq(Dict::getDictCode, dictData.getDictCode()));
|
||||
if (dictData.getDictCode() != null && count == 0) {
|
||||
final Dict dict = new Dict();
|
||||
dict.setDictCode(dictData.getDictCode());
|
||||
dict.setDictName(dictData.getDictCode());
|
||||
if (dictData.getDictName() != null) {
|
||||
dict.setDictName(dictData.getDictName());
|
||||
}
|
||||
if(dictService.save(dict)){
|
||||
dictData.setDictId(dict.getDictId());
|
||||
}
|
||||
}
|
||||
if (dictDataService.save(dictData)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:dict:update')")
|
||||
@OperationLog
|
||||
|
||||
Reference in New Issue
Block a user