基於Java+SpringBoot+vue+elementui圖書商城系統設計實現

專注的阿熊發表於2022-11-23

/**

  * 新書榜

  * 後端介面

  * @author

  * @email

  * @date 2022-01-18 07:36:34

  */

@RestController

@RequestMapping("/xinshubang")

public class XinshubangController {

     @Autowired

     private XinshubangService xinshubangService;

     /**

      * 後端列表

      */

     @RequestMapping("/page")

     public R page(@RequestParam Map<String, Object> params,XinshubangEntity xinshubang, HttpServletRequest request){

         EntityWrapper<XinshubangEntity> ew = new EntityWrapper<XinshubangEntity>();

PageUtils page = xinshubangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinshubang), params), params));

         return R.ok().put("data", page);

     }

  /**

      * 查詢

      */

     @RequestMapping("/query")

     public R query(XinshubangEntity xinshubang){

         EntityWrapper< XinshubangEntity> ew = new EntityWrapper< XinshubangEntity>();

    ew.allEq(MPUtil.allEQMapPre( xinshubang, "xinshubang"));

XinshubangView xinshubangView =  xinshubangService.selectView(ew);

return R.ok(" 查詢新書榜成功 ").put("data", xinshubangView);

     }

     /**

      * 後端詳情

      */

     @RequestMapping("/info/{id}")

     public R info(@PathVariable("id") Long id){

         XinshubangEntity xinshubang = xinshubangService.selectById(id);

xinshubang.setClicknum(xinshubang.getClicknum()+1);

xinshubang.setClicktime(new Date());

xinshubangService.updateById(xinshubang);

         return R.ok().put("data", xinshubang);

     }

     /**

      * 前端儲存

      */

     @RequestMapping("/add")

     public R add(@RequestBody XinshubangEntity xinshubang, HttpServletRequest request){

     xinshubang.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());

     //ValidatorUtils.validateEntity(xinshubang);

         xinshubangService.insert(xinshubang);

         return R.ok();

     }

     /**

      * 刪除

      */

     @RequestMapping("/delete")

     public R delete(@RequestBody Long[] ids){

         xinshubangService.deleteBatchIds(Arrays.asList(ids));

         return R.ok();

     }

    /**

      * 前端智慧排序

      */

@IgnoreAuth

     @RequestMapping("/autoSort")

     public R autoSort(@RequestParam Map<String, Object> params,XinshubangEntity xinshubang, HttpServletRequest request,String pre){

         EntityWrapper<XinshubangEntity> ew = new EntityWrapper<XinshubangEntity>();

         Map<String, Object> newMap = new HashMap<String, Object>();

         Map<String, Object> param =跟單網gendan5.com new HashMap<String, Object>();

Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();

while (it.hasNext()) {

Map.Entry<String, Object> entry = it.next();

String key = entry.getKey();

String newKey = entry.getKey();

if (pre.endsWith(".")) {

newMap.put(pre + newKey, entry.getValue());

} else if (StringUtils.isEmpty(pre)) {

newMap.put(newKey, entry.getValue());

} else {

newMap.put(pre + "." + newKey, entry.getValue());

}

}

params.put("sort", "clicknum");

         params.put("order", "desc");

PageUtils page = xinshubangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinshubang), params), params));

         return R.ok().put("data", page);

     }

}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69946337/viewspace-2924806/,如需轉載,請註明出處,否則將追究法律責任。

相關文章