first commit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package com.sqx.modules.banner.controller;
|
||||
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.banner.entity.Activity;
|
||||
import com.sqx.modules.banner.service.ActivityService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(value = "菜单和活动管理", tags = {"菜单和活动管理"})
|
||||
@RequestMapping(value = "/activity")
|
||||
public class ActivityController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ActivityService activityService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台详情")
|
||||
@ResponseBody
|
||||
public Result getBanner(@PathVariable Long id) {
|
||||
return Result.success().put("data",activityService.selectActivityById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/state/{state}", method = RequestMethod.GET)
|
||||
@ApiOperation("根据状态查询菜单列表")
|
||||
@ResponseBody
|
||||
public Result getBannerState(@PathVariable String state) {
|
||||
return Result.success().put("data",activityService.selectByState(state));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateActivity", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台修改")
|
||||
@ResponseBody
|
||||
public Result addBanner(@RequestBody Activity activity) {
|
||||
activityService.updateActivity(activity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateActivityStatus", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台修改状态")
|
||||
@ResponseBody
|
||||
public Result updateActivity(Long id) {
|
||||
Activity activity = activityService.selectActivityById(id);
|
||||
if("1".equals(activity.getState())){
|
||||
activity.setState("2");
|
||||
activityService.updateActivity(activity);
|
||||
}else{
|
||||
activity.setState("1");
|
||||
activityService.updateActivity(activity);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/insertActivity")
|
||||
@ApiOperation("添加")
|
||||
@ResponseBody
|
||||
public Result insertActivity(@RequestBody Activity activity){
|
||||
activityService.insertActivity(activity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台删除")
|
||||
public Result deleteBanner(@PathVariable Long id) {
|
||||
activityService.deleteActivity(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||
@ApiOperation("用户端获取广告位")
|
||||
@ResponseBody
|
||||
public Result getBannerList() {
|
||||
return Result.success().put("data",activityService.selectActivity());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/selectActivity", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台获取全部广告位")
|
||||
@ResponseBody
|
||||
public Result selectActivity() {
|
||||
return Result.success().put("data",activityService.selectActivitys());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.sqx.modules.banner.controller;
|
||||
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.banner.entity.Banner;
|
||||
import com.sqx.modules.banner.service.BannerService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(value = "banner图", tags = {"banner图"})
|
||||
@RequestMapping(value = "/banner")
|
||||
public class BannerController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectBannerList", method = RequestMethod.GET)
|
||||
@ApiOperation("查询所有banner图")
|
||||
@ResponseBody
|
||||
public Result selectBannerList(Integer classify){
|
||||
return Result.success().put("data",bannerService.selectBannerLists(classify));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/selectBannerPage", method = RequestMethod.GET)
|
||||
@ApiOperation("查询所有banner图")
|
||||
@ResponseBody
|
||||
public Result selectBannerPage(Integer page,Integer limit,Integer classify){
|
||||
return Result.success().put("data",bannerService.selectBannerPage(page,limit,classify));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/selectBannerById", method = RequestMethod.GET)
|
||||
@ApiOperation("根据id查看详细信息")
|
||||
@ResponseBody
|
||||
public Result selectBannerById(Long id){
|
||||
return Result.success().put("data",bannerService.selectBannerById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateBannerStateById", method = RequestMethod.GET)
|
||||
@ApiOperation("隐藏banner图")
|
||||
@ResponseBody
|
||||
public Result updateBannerStateById(Long id){
|
||||
|
||||
return bannerService.updateBannerStateById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateBannerById", method = RequestMethod.POST)
|
||||
@ApiOperation("修改banner图")
|
||||
@ResponseBody
|
||||
public Result updateBannerById(@RequestBody Banner banner){
|
||||
bannerService.updateBannerById(banner);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deleteBannerById", method = RequestMethod.GET)
|
||||
@ApiOperation("删除banner图")
|
||||
@ResponseBody
|
||||
public Result deleteBannerById(String ids){
|
||||
bannerService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/insertBanner", method = RequestMethod.POST)
|
||||
@ApiOperation("添加banner图")
|
||||
@ResponseBody
|
||||
public Result insertBanner(@RequestBody Banner banner){
|
||||
bannerService.insertBanner(banner);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.sqx.modules.banner.controller.app;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.banner.entity.Banner;
|
||||
import com.sqx.modules.banner.service.BannerService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(value = "app banner图", tags = {"app banner图"})
|
||||
@RequestMapping(value = "/app/banner")
|
||||
public class AppBannerController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
@RequestMapping(value = "/selectBannerList", method = RequestMethod.GET)
|
||||
@ApiOperation("查询所有banner图")
|
||||
@ResponseBody
|
||||
public Result selectBannerList(Integer classify) {
|
||||
return Result.success().put("data", bannerService.selectBannerList(classify));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/selectBannerPage", method = RequestMethod.GET)
|
||||
@ApiOperation("查询所有banner图")
|
||||
@ResponseBody
|
||||
public Result selectBannerPage(Integer page,Integer limit,Integer classify) {
|
||||
return Result.success().put("data", new PageUtils(bannerService.page(new Page<>(page,limit),new QueryWrapper<Banner>().eq("classify",classify))));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/clickBanner", method = RequestMethod.GET)
|
||||
@ApiOperation("点击金刚图")
|
||||
@ResponseBody
|
||||
public Result clickBanner(Integer bannerId,int page,int limit) {
|
||||
return bannerService.clickBanner(bannerId,page,limit);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
src/main/java/com/sqx/modules/banner/dao/ActivityDao.java
Normal file
19
src/main/java/com/sqx/modules/banner/dao/ActivityDao.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.sqx.modules.banner.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.banner.entity.Activity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
*/
|
||||
@Mapper
|
||||
public interface ActivityDao extends BaseMapper<Activity> {
|
||||
|
||||
|
||||
List<Activity> selectByState(String state);
|
||||
|
||||
}
|
||||
26
src/main/java/com/sqx/modules/banner/dao/BannerDao.java
Normal file
26
src/main/java/com/sqx/modules/banner/dao/BannerDao.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.sqx.modules.banner.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.banner.entity.Banner;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
*/
|
||||
@Mapper
|
||||
public interface BannerDao extends BaseMapper<Banner> {
|
||||
|
||||
|
||||
List<Banner> selectLists(@Param("classify") Integer classify);
|
||||
|
||||
List<Banner> selectList(@Param("classify") Integer classify);
|
||||
|
||||
IPage<Banner> selectBannerPage(Page<Banner> page,@Param("classify") Integer classify);
|
||||
|
||||
}
|
||||
29
src/main/java/com/sqx/modules/banner/entity/Activity.java
Normal file
29
src/main/java/com/sqx/modules/banner/entity/Activity.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.sqx.modules.banner.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 活动推广
|
||||
*/
|
||||
@Data
|
||||
@TableName("activity")
|
||||
public class Activity implements Serializable {
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long id;
|
||||
|
||||
private String createAt;
|
||||
|
||||
private String imageUrl;
|
||||
|
||||
private String url;
|
||||
|
||||
private String title;
|
||||
|
||||
private String state;
|
||||
|
||||
}
|
||||
77
src/main/java/com/sqx/modules/banner/entity/Banner.java
Normal file
77
src/main/java/com/sqx/modules/banner/entity/Banner.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package com.sqx.modules.banner.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
*/
|
||||
@Data
|
||||
@TableName("banner")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Banner implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* banner图id
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
private String imageUrl;
|
||||
|
||||
/**
|
||||
* 状态 1正常 2隐藏
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 分类 1 banner图 2 首页分类
|
||||
*/
|
||||
private Integer classify;
|
||||
|
||||
/**
|
||||
* 跳转地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String describes;
|
||||
/**
|
||||
* 短剧信息
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<Course> course;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.sqx.modules.banner.service;
|
||||
|
||||
|
||||
import com.sqx.modules.banner.entity.Activity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ActivityService {
|
||||
|
||||
|
||||
List<Activity> selectByState(String state);
|
||||
|
||||
Activity selectActivityById(Long id);
|
||||
|
||||
int insertActivity(Activity info);
|
||||
|
||||
int updateActivity(Activity info);
|
||||
|
||||
int deleteActivity(Long id);
|
||||
|
||||
List<Activity> selectActivity();
|
||||
|
||||
List<Activity> selectActivitys();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.sqx.modules.banner.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.banner.entity.Banner;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BannerService extends IService<Banner> {
|
||||
|
||||
List<Banner> selectBannerList(Integer classify);
|
||||
|
||||
List<Banner> selectBannerLists(Integer classify);
|
||||
|
||||
PageUtils selectBannerPage(Integer page, Integer limit, Integer classify);
|
||||
|
||||
int saveBody(String image, String url, Integer sort);
|
||||
|
||||
Banner selectBannerById(Long id);
|
||||
|
||||
int deleteBannerById(Long id);
|
||||
|
||||
Result updateBannerStateById(Long id);
|
||||
|
||||
int updateBannerById(Banner banner);
|
||||
|
||||
int insertBanner(Banner banner);
|
||||
|
||||
Result clickBanner(Integer bannerId,int page,int limit);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.sqx.modules.banner.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.banner.dao.ActivityDao;
|
||||
import com.sqx.modules.banner.entity.Activity;
|
||||
import com.sqx.modules.banner.service.ActivityService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 活动推广
|
||||
*/
|
||||
@Service
|
||||
public class ActivityServiceImpl extends ServiceImpl<ActivityDao, Activity> implements ActivityService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ActivityDao activityDao;
|
||||
|
||||
@Override
|
||||
public List<Activity> selectByState(String state) {
|
||||
return activityDao.selectByState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity selectActivityById(Long id) {
|
||||
return activityDao.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertActivity(Activity activity) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
activity.setCreateAt(sdf.format(now));
|
||||
return activityDao.insert(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateActivity(Activity activity) {
|
||||
return activityDao.updateById(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteActivity(Long id) {
|
||||
return activityDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Activity> selectActivity() {
|
||||
return activityDao.selectList(new QueryWrapper<Activity>().eq("state", 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Activity> selectActivitys() {
|
||||
return activityDao.selectList(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.sqx.modules.banner.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.banner.dao.BannerDao;
|
||||
import com.sqx.modules.banner.entity.Banner;
|
||||
import com.sqx.modules.banner.service.BannerService;
|
||||
import com.sqx.modules.course.dao.CourseDao;
|
||||
import com.sqx.modules.course.dao.CourseDetailsDao;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* banner图
|
||||
*/
|
||||
@Service
|
||||
public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements BannerService {
|
||||
|
||||
@Autowired
|
||||
private CourseDao courseDao;
|
||||
@Autowired
|
||||
private BannerDao bannerDao;
|
||||
@Autowired
|
||||
private CourseDetailsDao courseDetailsDao;
|
||||
|
||||
|
||||
@Override
|
||||
public List<Banner> selectBannerList(Integer classify) {
|
||||
return bannerDao.selectList(classify);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Banner> selectBannerLists(Integer classify) {
|
||||
return bannerDao.selectLists(classify);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils selectBannerPage(Integer page,Integer limit,Integer classify) {
|
||||
Page<Banner> pages=new Page<>(page,limit);
|
||||
return new PageUtils(bannerDao.selectBannerPage(pages,classify));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveBody(String image, String url, Integer sort) {
|
||||
Banner banner = new Banner();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
banner.setImageUrl(image);
|
||||
banner.setCreateTime(sdf.format(now));
|
||||
banner.setState(1);
|
||||
banner.setUrl(url);
|
||||
banner.setSort(sort == null ? 1 : sort);
|
||||
return bannerDao.insert(banner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertBanner(Banner banner) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
banner.setCreateTime(sdf.format(now));
|
||||
banner.setState(2);
|
||||
return bannerDao.insert(banner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result clickBanner(Integer bannerId, int page, int limit) {
|
||||
Page<Course> page1 = new Page<>(page, limit);
|
||||
QueryWrapper<Course> queryWrapper = new QueryWrapper();
|
||||
//查询banner 对应短剧
|
||||
queryWrapper.eq("banner_id", bannerId);
|
||||
IPage<Course> coursePage = courseDao.selectPage(page1, queryWrapper);
|
||||
return Result.success().put("data", coursePage);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Banner selectBannerById(Long id) {
|
||||
return bannerDao.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBannerById(Long id) {
|
||||
return bannerDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateBannerStateById(Long id) {
|
||||
Banner banner = selectBannerById(id);
|
||||
if (banner != null) {
|
||||
if (banner.getState() == 1) {
|
||||
banner.setState(2);
|
||||
} else {
|
||||
banner.setState(1);
|
||||
}
|
||||
bannerDao.updateById(banner);
|
||||
return Result.success();
|
||||
} else {
|
||||
return Result.error("修改对象为空!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateBannerById(Banner banner) {
|
||||
return bannerDao.updateById(banner);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user