|
@@ -35,28 +35,28 @@ public class FarmKindCountServiceImpl extends ServiceImpl<FarmKindCountMapper, F
|
|
|
@Override
|
|
|
public Result getFarmKindCount(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
String farmCode = paramsMap.get("farmCode");
|
|
|
- if (StringUtils.isBlank(farmCode)){
|
|
|
+ if (StringUtils.isBlank(farmCode)) {
|
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
|
}
|
|
|
List<FarmKindCount> farmKindCount = farmKindCountMapper.getFarmKindCount(farmCode);
|
|
|
- return new Result(ResultCode.SUCCESS,farmKindCount);
|
|
|
+ return new Result(ResultCode.SUCCESS, farmKindCount);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Result saveFarmKindCount(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
String farmCode = paramsMap.get("farmCode");
|
|
|
- if (StringUtils.isBlank(farmCode)){
|
|
|
+ if (StringUtils.isBlank(farmCode)) {
|
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
|
}
|
|
|
String list = paramsMap.get("list");
|
|
|
JSONArray listJa = JSONArray.parseArray(list);
|
|
|
List<FarmKindCount> farmKindCountList = listJa.toJavaList(FarmKindCount.class);
|
|
|
if (checkRepeat(farmKindCountList)) {
|
|
|
- return new Result(10001,"有重复类型",false);
|
|
|
- }else {
|
|
|
+ return new Result(10001, "有重复类型", false);
|
|
|
+ } else {
|
|
|
farmKindCountMapper.deleteAll(farmCode);
|
|
|
}
|
|
|
- for (int a = listJa.size()-1; a >= 0 ; a--){
|
|
|
+ for (int a = listJa.size() - 1; a >= 0; a--) {
|
|
|
JSONObject jsonObject = listJa.getJSONObject(a);
|
|
|
FarmKindCount farmKindCount = new FarmKindCount();
|
|
|
farmKindCount.setFarmKind(jsonObject.getString("farmKind"));
|
|
@@ -67,12 +67,12 @@ public class FarmKindCountServiceImpl extends ServiceImpl<FarmKindCountMapper, F
|
|
|
return new Result(ResultCode.SUCCESS);
|
|
|
}
|
|
|
|
|
|
- private Boolean checkRepeat(List<FarmKindCount> list){
|
|
|
+ private Boolean checkRepeat(List<FarmKindCount> list) {
|
|
|
List<String> collectionOptionList = new ArrayList<>();
|
|
|
- for (FarmKindCount a : list){
|
|
|
+ for (FarmKindCount a : list) {
|
|
|
collectionOptionList.add(a.getFarmKind());
|
|
|
}
|
|
|
Set<String> set = new HashSet<>(collectionOptionList);
|
|
|
- return collectionOptionList.size()!= set.size();
|
|
|
+ return collectionOptionList.size() != set.size();
|
|
|
}
|
|
|
}
|