日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

物流项目宣传活动任务前台分页展示

發布時間:2025/1/21 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 物流项目宣传活动任务前台分页展示 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

PromotionAction代碼:

@ParentPackage("json-default") @Namespace("/") @Controller @Scope("prototype") public class PromotionAction extends BaseAction<Promotion>{private File titleImgFile;//接收上傳的圖片private String titleImgFileName;//接收上傳圖片的名稱public void setTitleImgFileFileName(String titleImgFileFileName) {this.titleImgFileFileName = titleImgFileFileName;}public void setTitleImgFile(File titleImgFile) {this.titleImgFile = titleImgFile;}@Autowiredprivate PromotionService promotionService;@Action(value="promotion_save",results={@Result(name="success",type="redirect",location="./pages/take_delivery/promotion.html")})public String save() throws IOException{//宣傳圖上傳、在數據表保存宣傳圖的路徑String savePath = ServletActionContext.getServletContext().getRealPath("/upload/");String saveUrl = ServletActionContext.getServletContext().getContextPath("/upload/");//生成隨機圖片名UUID uuid = UUID.randomUUID();String ext = titleImgFileFileName.substring(titleImgFileName.lastIndexOf("."));//擴展名String randomFileName = uuid +ext;//圖片名=隨機唯一串+擴展名//保存圖片(絕對路徑保存)File destFile = new File(savePath + "/" + randomFileName);System.out.println(destFile.getAbsolutePath());FileUtils.copyFile(titleImgFile,destFile);//將相對工程web的訪問路徑,保存到model中model.setTitleImg(ServletActionContext.getRequest().getContextPath()+"/upload/"+randomFileName);//調用業務層,完成活動任務數據保存promotionService.save(model);return SUCCESS;}//促銷活動列表分頁查詢@Action(value="promotion_pageQuery",results = {@Result(name="success",type="json")})public String pageQuery(){//構造分頁查詢參數Pageable pageable = new PageRequest(page-1,rows);//調用業務層完成查詢Page<Promotion> pageData = promotionService.findPageData(pageable);//壓入值棧pushPageDataToValueStack(pageData);return SUCCESS;} }

apache.common.io包下有一個FileUtils類,其中有一個copyFile的方法,可以直接將上傳的圖片保存到指定路徑。

public static void copyFile(File srcFile, File destFile) throws IOException {copyFile(srcFile, destFile, true); }

PromotionService接口代碼:

public interface PromotionService {//保存宣傳任務void save(Promotion promotion);//分頁查詢Page<Promotion> findPageData(Pageable pageable);//根據page和rows返回分頁數據@Path("/pageQuery")@GET@Produces({"application/xml","application/json"})PageBean<Promotion> findPageData(@QueryParam("page") int page,@QueryParam("rows") int rows);//根據id查詢@Path("/promotion/{id}")@GET@Produces({"application/xml","application/json"})Promotion findById(@PathParam("id") Integer id);//設置活動過期void updateStatus(Date date); }

PromotionServiceImpl實現類代碼:

@Service @Transactional public class PromotionServiceImpl implements PromotionService {@Autowiredprivate PromotionRepository promotionRepository;@Overridepublic void save(Promotion promotion){promotionRepository.save(promotion);}@Overridepublic Page<Promotion> findPageData(Pageable pageable){return promotionRepository.findAll(pageable);}@Overridepublic PageBean<Promotion> findPageData(int page,int rows){Pageable pageable = new PageRequest(page-1,rows);Pahe<Promotion> pageData = promotionRepository.findAll(pageable);//封裝到Page對象PageBean<Promotion> pageBean = new PageBean<Promotion>();pageBean.setTotalCount(pageData.getTotalElements());pageBean.setPageData(pageData.getContent());return pageBean;}@Overridepublic Promotion findById(Integer id){return promotionRepository.findOne(id);}@Overridepublic void updateStatus(Date date){promotionRepository.updateStatus(date);} }

dao持久層PromotionRepository代碼:

public interface PromotionRepository extends JpaRepository<Promotion,Integer>{@Query("update Promotion set sratus='2' where endDate<? and status='1'>")@Modifyingvoid updateStatus(Date now); }

總結

以上是生活随笔為你收集整理的物流项目宣传活动任务前台分页展示的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。