New file |
| | |
| | | package com.panzhihua.service_community.api; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.api.ApiController; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.dtos.property.CommonPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.model.vos.community.social.ComActSocialProjectPublicityVO; |
| | | import com.panzhihua.service_community.entity.ComActSocialProjectPublicity; |
| | | import com.panzhihua.service_community.service.ComActSocialProjectPublicityService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 项目宣传表(ComActSocialProjectPublicity)表控制层 |
| | | * |
| | | * @author makejava |
| | | * @since 2021-12-23 14:30:55 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("comActSocialProjectPublicity") |
| | | public class ComActSocialProjectPublicityApi { |
| | | /** |
| | | * 服务对象 |
| | | */ |
| | | @Resource |
| | | private ComActSocialProjectPublicityService comActSocialProjectPublicityService; |
| | | |
| | | /** |
| | | * 分页查询所有数据 |
| | | * |
| | | * @param commonPage 查询实体 |
| | | * @return 所有数据 |
| | | */ |
| | | @PostMapping("queryAll") |
| | | public R selectAll(@RequestBody CommonPage commonPage) { |
| | | return this.comActSocialProjectPublicityService.pageList(commonPage); |
| | | } |
| | | |
| | | /** |
| | | * 通过主键查询单条数据 |
| | | * |
| | | * @param id 主键 |
| | | * @return 单条数据 |
| | | */ |
| | | @GetMapping("{id}") |
| | | public R selectOne(@PathVariable("id") Long id) { |
| | | return R.ok(this.comActSocialProjectPublicityService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 小程序通过主键查询单条数据 |
| | | * |
| | | * @param id 主键 |
| | | * @return 单条数据 |
| | | */ |
| | | @GetMapping("/getByApplet/{id}") |
| | | public R getByApplet(@PathVariable("id") Long id) { |
| | | ComActSocialProjectPublicity comActSocialProjectPublicity=this.comActSocialProjectPublicityService.getById(id); |
| | | comActSocialProjectPublicity.setViews(comActSocialProjectPublicity.getViews()+1); |
| | | this.comActSocialProjectPublicityService.updateById(comActSocialProjectPublicity); |
| | | return this.comActSocialProjectPublicityService.selectOne(id); |
| | | } |
| | | |
| | | /** |
| | | * 新增数据 |
| | | * |
| | | * @param comActSocialProjectPublicityVO 实体对象 |
| | | * @return 新增结果 |
| | | */ |
| | | @PostMapping |
| | | public R insert(@RequestBody ComActSocialProjectPublicityVO comActSocialProjectPublicityVO) { |
| | | ComActSocialProjectPublicity comActSocialProjectPublicity=new ComActSocialProjectPublicity(); |
| | | BeanUtils.copyProperties(comActSocialProjectPublicityVO,comActSocialProjectPublicity); |
| | | comActSocialProjectPublicity.setCreateTime(new Date()); |
| | | return R.ok(this.comActSocialProjectPublicityService.save(comActSocialProjectPublicity)); |
| | | } |
| | | |
| | | /** |
| | | * 修改数据 |
| | | * |
| | | * @param comActSocialProjectPublicityVO 实体对象 |
| | | * @return 修改结果 |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody ComActSocialProjectPublicityVO comActSocialProjectPublicityVO) { |
| | | ComActSocialProjectPublicity comActSocialProjectPublicity=new ComActSocialProjectPublicity(); |
| | | BeanUtils.copyProperties(comActSocialProjectPublicityVO,comActSocialProjectPublicity); |
| | | return R.ok(this.comActSocialProjectPublicityService.updateById(comActSocialProjectPublicity)); |
| | | } |
| | | |
| | | /** |
| | | * 删除数据 |
| | | * |
| | | * @param id 主键结合 |
| | | * @return 删除结果 |
| | | */ |
| | | @GetMapping("del") |
| | | public R delete(@RequestParam("id") Long id) { |
| | | return R.ok(this.comActSocialProjectPublicityService.removeById(id)); |
| | | } |
| | | /** |
| | | * 多条删除数据 |
| | | * |
| | | * @param ids 主键结合 |
| | | * @return 删除结果 |
| | | */ |
| | | @GetMapping("delBatch") |
| | | public R delBatch(@RequestParam("ids") List<Long> ids) { |
| | | return R.ok(this.comActSocialProjectPublicityService.removeByIds(ids)); |
| | | } |
| | | } |