|
@@ -1,15 +1,20 @@
|
|
|
package com.huimv.env.produce.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.huimv.common.utils.Result;
|
|
|
+import com.huimv.common.utils.ResultCode;
|
|
|
import com.huimv.env.common.utils.DateUtil;
|
|
|
import com.huimv.env.produce.entity.WarningInfo;
|
|
|
import com.huimv.env.produce.mapper.WarningInfoMapper;
|
|
|
import com.huimv.env.produce.service.WarningInfoService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -34,4 +39,70 @@ public class WarningInfoServiceImpl extends ServiceImpl<WarningInfoMapper, Warni
|
|
|
queryWrapper.eq("add_date",dateUtil.getTodayDate());
|
|
|
return warningInfoMapper.selectCount(queryWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result add(Map<String, String> paramsMap) throws ParseException {
|
|
|
+ DateUtil dateUtil = new DateUtil();
|
|
|
+ WarningInfo warningInfo = new WarningInfo();
|
|
|
+ warningInfo.setTitle(paramsMap.get("title"));
|
|
|
+ warningInfo.setContent(paramsMap.get("content"));
|
|
|
+ warningInfo.setAddDate(dateUtil.getTodayDate());
|
|
|
+ warningInfo.setFarmCode(paramsMap.get("farmCode"));
|
|
|
+ int rows = warningInfoMapper.insert(warningInfo);
|
|
|
+ if(rows == 0){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }else{
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result edit(Map<String, String> paramsMap) throws ParseException {
|
|
|
+ DateUtil dateUtil = new DateUtil();
|
|
|
+ WarningInfo warningInfo = new WarningInfo();
|
|
|
+ warningInfo.setId(Integer.parseInt(paramsMap.get("id")));
|
|
|
+ warningInfo.setTitle(paramsMap.get("title"));
|
|
|
+ warningInfo.setContent(paramsMap.get("content"));
|
|
|
+ warningInfo.setAddDate(dateUtil.getTodayDate());
|
|
|
+ warningInfo.setFarmCode(paramsMap.get("farmCode"));
|
|
|
+ int rows = warningInfoMapper.updateById(warningInfo);
|
|
|
+ if(rows == 0){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }else{
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result remove(Map<String, String> paramsMap) {
|
|
|
+ String ids = paramsMap.get("ids");
|
|
|
+ String[] idArray = ids.split(",");
|
|
|
+ int rows = warningInfoMapper.deleteBatchIds(Arrays.asList(idArray));
|
|
|
+ if(rows == 0){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }else{
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result list(Map<String, String> paramsMap) {
|
|
|
+ //pageNo
|
|
|
+ String pageNo = "1";
|
|
|
+ if (StringUtils.isBlank(paramsMap.get("pageNo") + "")){
|
|
|
+ pageNo = paramsMap.get("pageNo") + "";
|
|
|
+ }
|
|
|
+ //pageSize
|
|
|
+ String pageSize = "10";
|
|
|
+ if (StringUtils.isBlank(paramsMap.get("pageSize") + "")) {
|
|
|
+ pageSize = paramsMap.get("pageSize") + "";
|
|
|
+ }
|
|
|
+ //
|
|
|
+ String farmCode = paramsMap.get("farmCode");
|
|
|
+ QueryWrapper<WarningInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("farm_code",farmCode);
|
|
|
+ queryWrapper.orderByDesc("add_date");
|
|
|
+ Page<WarningInfo> page = new Page<>(Integer.parseInt(pageNo), Integer.parseInt(pageSize));
|
|
|
+ return new Result(ResultCode.SUCCESS, warningInfoMapper.selectPage(page, queryWrapper));
|
|
|
+ }
|
|
|
}
|