| | |
| | | package com.ltkj.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.utils.DateUtils; |
| | | import com.ltkj.mall.service.IMallSchedulingTimeService; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ltkj.common.annotation.Log; |
| | | import com.ltkj.common.core.controller.BaseController; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | |
| | | public class StjMemoController extends BaseController { |
| | | @Autowired |
| | | private IStjMemoService stjMemoService; |
| | | |
| | | @Autowired |
| | | private IMallSchedulingTimeService mallSchedulingTimeService; |
| | | |
| | | /** |
| | | * 查询备忘录列表 |
| | |
| | | @Log(title = "备忘录", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody StjMemo stjMemo) { |
| | | return toAjax(stjMemoService.insertStjMemo(stjMemo)); |
| | | stjMemo.setMFlag("0"); |
| | | return toAjax(stjMemoService.save(stjMemo)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "备忘录", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody StjMemo stjMemo) { |
| | | return toAjax(stjMemoService.updateStjMemo(stjMemo)); |
| | | return toAjax(stjMemoService.saveOrUpdate(stjMemo)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "备忘录", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) { |
| | | return toAjax(stjMemoService.deleteStjMemoByIds(ids)); |
| | | return toAjax(stjMemoService.removeByIds(Arrays.asList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 根据userid和日期查看当日所有事件 |
| | | */ |
| | | @GetMapping("/listByUserAndDate") |
| | | public AjaxResult listByUserAndDate(@RequestParam String userId, |
| | | @RequestParam Date mDate) { |
| | | LambdaQueryWrapper<StjMemo> wq=new LambdaQueryWrapper<>(); |
| | | wq.eq(StjMemo::getUserId,userId); |
| | | wq.eq(StjMemo::getMDate,mDate); |
| | | List<StjMemo> list = stjMemoService.list(wq); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据userid和日期查看当月所有事件 |
| | | */ |
| | | @GetMapping("/listByDate") |
| | | public AjaxResult listByDate(@RequestParam String userId, |
| | | @RequestParam Date mDate) { |
| | | // Map<String,List<StjMemo>> res=new HashMap<>(); |
| | | // List<Date> dateList = mallSchedulingTimeService.getDateListByBetweenTime(DateUtil.format(DateUtil.beginOfMonth(mDate),"yyyy-MM-dd HH:mm:ss"), |
| | | // DateUtil.format(DateUtil.endOfMonth(mDate),"yyyy-MM-dd HH:mm:ss")); |
| | | // |
| | | // for (Date date : dateList) { |
| | | // LambdaQueryWrapper<StjMemo> wq=new LambdaQueryWrapper<>(); |
| | | // wq.eq(StjMemo::getUserId,userId); |
| | | // wq.eq(StjMemo::getMDate,date); |
| | | // List<StjMemo> list = stjMemoService.list(wq); |
| | | // String format = DateUtil.format(date, "yyyy-MM-dd"); |
| | | // if (list.size()==0){ |
| | | // StjMemo stjMemo=new StjMemo(); |
| | | // stjMemo.setTitle("无"); |
| | | // stjMemo.setMFlag("0"); |
| | | // list.add(stjMemo); |
| | | // } |
| | | // res.put(format,list); |
| | | // } |
| | | // return AjaxResult.success(res); |
| | | |
| | | LambdaQueryWrapper<StjMemo> wq=new LambdaQueryWrapper<>(); |
| | | wq.eq(StjMemo::getUserId,userId); |
| | | wq.between(StjMemo::getMDate,(DateUtil.format(DateUtil.beginOfMonth(mDate),"yyyy-MM-dd")),(DateUtil.format(DateUtil.endOfMonth(mDate),"yyyy-MM-dd"))); |
| | | List<StjMemo> list = stjMemoService.list(wq); |
| | | for (StjMemo stjMemo : list) { |
| | | String formatDate = DateUtil.format(stjMemo.getMDate(),"yyyy-MM"); |
| | | stjMemo.setFormat(formatDate); |
| | | } |
| | | return AjaxResult.success(list); |
| | | } |
| | | } |