Sfoglia il codice sorgente

增加、删除节目信息接口

yaobo 7 anni fa
parent
commit
ffe68489be

+ 5 - 5
src/main/java/cn/efunbox/controller/ClickController.java

@@ -28,28 +28,28 @@ public class ClickController {
 	
     private IClickService clickService;
     
-    public IClickService getRecommendService() {
+    public IClickService getClickService() {
         return clickService;
     }
 
     @Autowired
-    public void setPersonService(IClickService clickService) {
+    public void setClickService(IClickService clickService) {
         this.clickService = clickService;
     }
 
     @RequestMapping("/getAll")
     @ResponseBody
     public Map<String,Object> getAll(){
-        List<Click> clicks = clickService.loadAll();
+        List<Click> rows = clickService.loadAll();
         Map<String, Object> map = new HashMap<String, Object>(2);
         map.put("code", 200);
-        map.put("rows", clicks);
+        map.put("rows", rows);
         return map;
     }
 
     @RequestMapping("/add")
     @ResponseBody
-    public Map<String,Object> addClick(){
+    public Map<String,Object> add(){
     	Map<String, Object> map = new HashMap<String, Object>(2);
         String age = request.getParameter("age")==null?"0":request.getParameter("age").trim();
 		String sex = request.getParameter("sex")==null?"1":request.getParameter("sex").trim();

+ 113 - 0
src/main/java/cn/efunbox/controller/FilmController.java

@@ -0,0 +1,113 @@
+package cn.efunbox.controller;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
+
+import cn.efunbox.model.Film;
+import cn.efunbox.service.IFilmService;;
+
+@SuppressWarnings("deprecation")
+@Controller
+@RequestMapping("/film")
+public class FilmController {
+	 
+	@Autowired  
+	private  HttpServletRequest request;
+	
+    private IFilmService filmService;
+    
+    public IFilmService getFilmService() {
+        return filmService;
+    }
+
+    @Autowired
+    public void setFilmService(IFilmService filmService) {
+        this.filmService = filmService;
+    }
+
+    @RequestMapping("/getAll")
+    @ResponseBody
+    public Map<String,Object> getAll(){
+        List<Film> rows = filmService.loadAll();
+        Map<String, Object> map = new HashMap<String, Object>(2);
+        map.put("code", 200);
+        map.put("rows", rows);
+        return map;
+    }
+
+    @RequestMapping("/delete")
+    @ResponseBody
+    public Map<String,Object> delete(){
+    	Map<String, Object> map = new HashMap<String, Object>(2);
+        String film_code = request.getParameter("film_code")==null?"":request.getParameter("film_code").trim();
+		if(film_code.isEmpty()){
+			map.put("code", 301);
+			return map;
+		}
+    	filmService.delete(film_code);
+        map.put("code", 200);
+        return map;
+    }
+
+    @RequestMapping("/add")
+    @ResponseBody
+    public Map<String,Object> add(){
+    	Map<String, Object> map = new HashMap<String, Object>(2);
+        String film_code = request.getParameter("film_code")==null?"":request.getParameter("film_code").trim();
+		String film_type = request.getParameter("film_type")==null?"1":request.getParameter("film_type").trim();
+		String mark_type = request.getParameter("mark_type")==null?"0":request.getParameter("mark_type").trim();
+		String is_vip = request.getParameter("is_vip")==null?"0":request.getParameter("is_vip").trim();
+		String film_grade = request.getParameter("film_grade")==null?"5":request.getParameter("film_grade").trim();
+		String film_star = request.getParameter("film_star")==null?"5":request.getParameter("film_star").trim();
+		String age_group = request.getParameter("age_group")==null?"0":request.getParameter("age_group").trim();
+		String series_count = request.getParameter("series_count")==null?"1":request.getParameter("series_count").trim();
+		String publish_date = request.getParameter("publish_date")==null?"0":request.getParameter("publish_date").trim();
+		String online_date = request.getParameter("online_date")==null?"0":request.getParameter("online_date").trim();
+		String area = request.getParameter("area")==null?"0":request.getParameter("area").trim();
+		String movie_type = request.getParameter("movie_type")==null?"0":request.getParameter("movie_type").trim();
+		String target_people = request.getParameter("target_people")==null?"0":request.getParameter("target_people").trim();
+		String language = request.getParameter("language")==null?"0":request.getParameter("language").trim();
+		String duration = request.getParameter("duration")==null?"0":request.getParameter("duration").trim();
+		if(film_code.isEmpty()){
+			map.put("code", 301);
+			return map;
+		}
+		int curTime = (int)(System.currentTimeMillis()/1000);
+		Film film = new Film();
+		film.setAge_group(Integer.valueOf(age_group));
+		film.setArea(Integer.valueOf(area));
+		film.setCreated(curTime);
+		film.setDuration(Integer.valueOf(duration));
+		film.setFilm_code(film_code);
+		film.setFilm_grade(Float.valueOf(film_grade));
+		film.setFilm_star(Float.valueOf(film_star));
+		film.setFilm_type(Integer.valueOf(film_type));
+		film.setIs_vip(Integer.valueOf(is_vip));
+		film.setLanguage(Integer.valueOf(language));
+		film.setMark_type(Integer.valueOf(mark_type));
+		film.setMovie_type(Integer.valueOf(movie_type));
+		film.setOnline_date(Integer.valueOf(online_date));
+		film.setPublish_date(Integer.valueOf(publish_date));
+		film.setSeries_count(Integer.valueOf(series_count));
+		film.setTarget_people(Integer.valueOf(target_people));
+		
+		int ret = filmService.insert(film);
+		
+		map.put("code", 200);
+        map.put("rows", ret);
+        return map;
+    }
+    
+}

+ 7 - 7
src/main/java/cn/efunbox/controller/RecommendController.java

@@ -32,7 +32,7 @@ public class RecommendController {
     }
 
     @Autowired
-    public void setPersonService(IRecommendService recmdService) {
+    public void setRecommendService(IRecommendService recmdService) {
         this.recmdService = recmdService;
     }
 /*
@@ -75,17 +75,17 @@ public class RecommendController {
 */
     @RequestMapping("/getAll")
     @ResponseBody
-    public Map<String,Object> getRecommendAll(){
-        List<Recommend> recmds = recmdService.loadAll();
+    public Map<String,Object> getAll(){
+        List<Recommend> rows = recmdService.loadAll();
         Map<String, Object> map = new HashMap<String, Object>(2);
         map.put("code", 200);
-        map.put("rows", recmds);
+        map.put("rows", rows);
         return map;
     }
 
     @RequestMapping("/search")
     @ResponseBody
-    public Map<String,Object> searchRecommend(){
+    public Map<String,Object> search(){
     	String ageStr = request.getParameter("age");
 		String sexStr = request.getParameter("sex");
 		String pageStr = request.getParameter("page");
@@ -111,10 +111,10 @@ public class RecommendController {
 		if(size<10)
 			size = 10;
 		int offset = Math.max(0, (page-1)) * size;
-        List<Recommend> recmds = recmdService.search(age, sex, size, offset);
+        List<Recommend> rows = recmdService.search(age, sex, size, offset);
         Map<String, Object> map = new HashMap<String, Object>(2);
         map.put("code", 200);
-        map.put("rows", recmds);
+        map.put("rows", rows);
         return map;
     }
     

+ 30 - 0
src/main/java/cn/efunbox/dao/FilmMapper.java

@@ -0,0 +1,30 @@
+package cn.efunbox.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.annotations.Param;
+
+import cn.efunbox.model.Film;
+
+public interface FilmMapper {
+      
+    /**
+     * 查询所有
+     * @return
+     */
+    List<Film> queryAll();
+    
+    /**
+     * 插入一条记录
+     * @param film
+     */
+    int insert(Film film);
+
+    /**
+     * 删除一条记录
+     * @param film_code
+     */
+    void delete(@Param("film_code") String film_code);
+   
+}

+ 20 - 0
src/main/java/cn/efunbox/mapping/FilmMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.efunbox.dao.FilmMapper">
+    <!-- 新增 -->  
+     <insert id="insert" parameterType="Film">
+		insert into film_info(film_code,film_type,mark_type,is_vip,film_grade,film_star,age_group,series_count,publish_date,online_date,area,movie_type,target_people,language,duration,created) 
+		values(#{film_code},#{film_type},#{mark_type},#{is_vip},#{film_grade},#{film_star},#{age_group},#{series_count},#{publish_date},#{online_date},#{area},#{movie_type},#{target_people},#{language},#{duration},#{created}) 
+	</insert>
+    
+    <!-- 查询 -->  
+    <select id="queryAll" resultType="Film" >  
+        select * from film_info
+    </select>
+    
+    <!-- 删除 -->  
+    <select id="delete" resultType="int" >  
+        delete from film_info where film_code=#{film_code} limit 1 
+    </select>
+    
+</mapper>

+ 296 - 0
src/main/java/cn/efunbox/model/Film.java

@@ -0,0 +1,296 @@
+package cn.efunbox.model;
+
+
+/**
+ * 用户点击记录
+ * @author yaobo
+ *
+ */
+public class Film {
+ 
+	private int id;			//唯一编号
+    private String film_code;//电影编号
+    private int film_type;	//电影类型 1、电影 2:剧集
+    private int mark_type;	//角标类型 1:new
+    private int is_vip;		//是否为vip 1:是
+    private Float film_grade;//电影评分
+    private Float film_star;//电影评星
+    private int age_group;	//适用年龄段
+    private int series_count;//集数,电影为1
+    private int publish_date;//发行时间
+    private int online_date;//上线时间
+    private int area;		//地区
+    private int movie_type;	//类型
+    private int target_people;//适合人群
+    private int language;	//语言
+    private int duration;	//电影时长,分钟
+    private int created;	//创建时间
+    
+    /*
+     CREATE TABLE `film_info` (
+                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '唯一编号',
+                  `film_code` varchar(100) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '电影编号',
+                  `film_type` int(2) DEFAULT '1' COMMENT '电影类型 1、电影 2:剧集',
+                  `mark_type` int(2) DEFAULT '0' COMMENT '角标类型 1:new',
+                  `is_vip` int(2) DEFAULT '0' COMMENT '是否为vip 1:是',                  
+                  `film_grade` float(4,2) DEFAULT '5' COMMENT '电影评分',
+                  `film_star` float(4,2) DEFAULT '5' COMMENT '电影评星',
+                  `age_group` int(5) DEFAULT '0' COMMENT '适用年龄段',
+                  `series_count` int(5) DEFAULT '1' COMMENT '集数,电影为1',
+                  `publish_date` int(10) DEFAULT '0' COMMENT '发行时间',
+                  `online_date` int(10) DEFAULT '0' COMMENT '上线时间',
+                  `area` int(5) DEFAULT '0' COMMENT '地区',
+                  `movie_type` int(5) DEFAULT '0' COMMENT '类型',
+                  `target_people` int(5) DEFAULT '0' COMMENT '适合人群',
+                  `language` int(5) DEFAULT '0' COMMENT '语言',
+                  `duration` int(5) DEFAULT '0' COMMENT '电影时长,分钟',
+                  `created` int(10) DEFAULT '0' COMMENT '创建时间',
+                  PRIMARY KEY (`id`),
+                  KEY `film_code` (`film_code`),
+                  KEY `film_type` (`film_type`)
+                ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='节目记录'; 
+     */
+    
+	/**
+	 * @return the id
+	 */
+	public int getId() {
+		return id;
+	}
+
+	/**
+	 * @param id the id to set
+	 */
+	public void setId(int id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the film_code
+	 */
+	public String getFilm_code() {
+		return film_code;
+	}
+
+	/**
+	 * @param film_code the film_code to set
+	 */
+	public void setFilm_code(String film_code) {
+		this.film_code = film_code;
+	}
+
+	/**
+	 * @return the film_type
+	 */
+	public int getFilm_type() {
+		return film_type;
+	}
+
+	/**
+	 * @param film_type the film_type to set
+	 */
+	public void setFilm_type(int film_type) {
+		this.film_type = film_type;
+	}
+
+	/**
+	 * @return the mark_type
+	 */
+	public int getMark_type() {
+		return mark_type;
+	}
+
+	/**
+	 * @param mark_type the mark_type to set
+	 */
+	public void setMark_type(int mark_type) {
+		this.mark_type = mark_type;
+	}
+
+	/**
+	 * @return the is_vip
+	 */
+	public int getIs_vip() {
+		return is_vip;
+	}
+
+	/**
+	 * @param is_vip the is_vip to set
+	 */
+	public void setIs_vip(int is_vip) {
+		this.is_vip = is_vip;
+	}
+
+	/**
+	 * @return the film_grade
+	 */
+	public Float getFilm_grade() {
+		return film_grade;
+	}
+
+	/**
+	 * @param film_grade the film_grade to set
+	 */
+	public void setFilm_grade(Float film_grade) {
+		this.film_grade = film_grade;
+	}
+
+	/**
+	 * @return the film_star
+	 */
+	public Float getFilm_star() {
+		return film_star;
+	}
+
+	/**
+	 * @param film_star the film_star to set
+	 */
+	public void setFilm_star(Float film_star) {
+		this.film_star = film_star;
+	}
+
+	/**
+	 * @return the age_group
+	 */
+	public int getAge_group() {
+		return age_group;
+	}
+
+	/**
+	 * @param age_group the age_group to set
+	 */
+	public void setAge_group(int age_group) {
+		this.age_group = age_group;
+	}
+
+	/**
+	 * @return the series_count
+	 */
+	public int getSeries_count() {
+		return series_count;
+	}
+
+	/**
+	 * @param series_count the series_count to set
+	 */
+	public void setSeries_count(int series_count) {
+		this.series_count = series_count;
+	}
+
+	/**
+	 * @return the publish_date
+	 */
+	public int getPublish_date() {
+		return publish_date;
+	}
+
+	/**
+	 * @param publish_date the publish_date to set
+	 */
+	public void setPublish_date(int publish_date) {
+		this.publish_date = publish_date;
+	}
+
+	/**
+	 * @return the area
+	 */
+	public int getArea() {
+		return area;
+	}
+
+	/**
+	 * @param area the area to set
+	 */
+	public void setArea(int area) {
+		this.area = area;
+	}
+
+	/**
+	 * @return the movie_type
+	 */
+	public int getMovie_type() {
+		return movie_type;
+	}
+
+	/**
+	 * @param movie_type the movie_type to set
+	 */
+	public void setMovie_type(int movie_type) {
+		this.movie_type = movie_type;
+	}
+
+	/**
+	 * @return the target_people
+	 */
+	public int getTarget_people() {
+		return target_people;
+	}
+
+	/**
+	 * @param target_people the target_people to set
+	 */
+	public void setTarget_people(int target_people) {
+		this.target_people = target_people;
+	}
+
+	/**
+	 * @return the language
+	 */
+	public int getLanguage() {
+		return language;
+	}
+
+	/**
+	 * @param language the language to set
+	 */
+	public void setLanguage(int language) {
+		this.language = language;
+	}
+
+	/**
+	 * @return the online_date
+	 */
+	public int getOnline_date() {
+		return online_date;
+	}
+
+	/**
+	 * @param online_date the online_date to set
+	 */
+	public void setOnline_date(int online_date) {
+		this.online_date = online_date;
+	}
+
+	/**
+	 * @return the duration
+	 */
+	public int getDuration() {
+		return duration;
+	}
+
+	/**
+	 * @param duration the duration to set
+	 */
+	public void setDuration(int duration) {
+		this.duration = duration;
+	}
+
+	/**
+	 * @return the created
+	 */
+	public int getCreated() {
+		return created;
+	}
+
+	/**
+	 * @param created the created to set
+	 */
+	public void setCreated(int created) {
+		this.created = created;
+	}
+
+    @Override
+    public String toString() {
+        return "Person [id=" + id + ", film_code=" + film_code + "]";
+    }
+}

+ 27 - 0
src/main/java/cn/efunbox/service/IFilmService.java

@@ -0,0 +1,27 @@
+package cn.efunbox.service;
+
+import java.util.List;
+
+import cn.efunbox.model.Film;
+
+public interface IFilmService {
+
+    /**
+     * 新增记录
+     * @return
+     */
+    int insert(Film film);
+
+    /**
+     * 删除记录
+     * @return
+     */
+    void delete(String film_code);
+    
+    /**
+     * 加载全部
+     * @return
+     */
+    List<Film> loadAll();
+
+}

+ 43 - 0
src/main/java/cn/efunbox/service/impl/FilmServiceImpl.java

@@ -0,0 +1,43 @@
+package cn.efunbox.service.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.efunbox.model.Film;
+import cn.efunbox.dao.FilmMapper;
+import cn.efunbox.service.IFilmService;
+
+@Service("filmService")
+public class FilmServiceImpl implements IFilmService {
+    	
+    private FilmMapper filmMapper;
+
+    public FilmMapper getFilmMapper() {
+        return filmMapper;
+    }
+    
+    @Autowired
+    public void setFilmMapper(FilmMapper filmMapper) {
+        this.filmMapper = filmMapper;
+    }
+
+	public List<Film> loadAll() {
+		// TODO Auto-generated method stub
+		return filmMapper.queryAll();
+	}
+
+	public int insert(Film film) {
+		// TODO Auto-generated method stub
+		return filmMapper.insert(film);
+	}
+
+	public void delete(String film_code) {
+		// TODO Auto-generated method stub
+		filmMapper.delete(film_code);
+	}
+
+}

+ 3 - 1
src/main/resources/mybatis-config.xml

@@ -8,11 +8,13 @@
     <typeAliases>    
          <typeAlias type="cn.efunbox.model.Person" alias="Person"/>  
          <typeAlias type="cn.efunbox.model.Recommend" alias="Recommend"/> 
-         <typeAlias type="cn.efunbox.model.Click" alias="Click"/>  
+         <typeAlias type="cn.efunbox.model.Click" alias="Click"/>   
+         <typeAlias type="cn.efunbox.model.Film" alias="Film"/>  
     </typeAliases>     
       <mappers>  
         <mapper resource="cn/efunbox/mapping/PersonMapper.xml" />  
         <mapper resource="cn/efunbox/mapping/RecommendMapper.xml" />  
         <mapper resource="cn/efunbox/mapping/ClickMapper.xml" />  
+        <mapper resource="cn/efunbox/mapping/FilmMapper.xml" />  
     </mappers>
 </configuration>

+ 2 - 2
src/main/resources/mybatis-spring.xml

@@ -15,9 +15,9 @@
     <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
         <!-- 基本属性 url、user、password -->  
         <property name="driverClassName" value="com.mysql.jdbc.Driver" />  
-        <property name="url" value="jdbc:mysql://192.168.1.87:3306/efunbox_recmd" />  
+        <property name="url" value="jdbc:mysql://127.0.0.1:3306/efunbox_recmd" />  
         <property name="username" value="root" />  
-        <property name="password" value="admin123" /> 
+        <property name="password" value="223732" /> 
         <property name="initialSize" value="1" />  
         <property name="minIdle" value="1" />   
         <property name="maxActive" value="20" />