Commit d8d793ad by wangming

banner

1 parent 54cb8f5d
...@@ -13,12 +13,15 @@ public class TKzyRelationClass extends BaseModel { ...@@ -13,12 +13,15 @@ public class TKzyRelationClass extends BaseModel {
private Date createDt; private Date createDt;
public TKzyRelationClass(Long id, Long relationId, Long firstClassId, Long secondClassId, Date createDt) { private Integer type;
public TKzyRelationClass(Long id, Long relationId, Long firstClassId, Long secondClassId, Date createDt, Integer type) {
this.id = id; this.id = id;
this.relationId = relationId; this.relationId = relationId;
this.firstClassId = firstClassId; this.firstClassId = firstClassId;
this.secondClassId = secondClassId; this.secondClassId = secondClassId;
this.createDt = createDt; this.createDt = createDt;
this.type = type;
} }
public TKzyRelationClass() { public TKzyRelationClass() {
...@@ -64,4 +67,12 @@ public class TKzyRelationClass extends BaseModel { ...@@ -64,4 +67,12 @@ public class TKzyRelationClass extends BaseModel {
public void setCreateDt(Date createDt) { public void setCreateDt(Date createDt) {
this.createDt = createDt; this.createDt = createDt;
} }
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
} }
\ No newline at end of file
...@@ -404,6 +404,66 @@ public class TKzyRelationClassExample { ...@@ -404,6 +404,66 @@ public class TKzyRelationClassExample {
addCriterion("create_dt not between", value1, value2, "createDt"); addCriterion("create_dt not between", value1, value2, "createDt");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {
......
package com.server.web.common.service;
import com.server.web.common.model.TKzyCourse;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by yinbin on 2018/1/15.
*/
public interface CourseService {
@Transactional
void insertCourse(TKzyCourse course, String classIds);
@Transactional
void updateCourse(TKzyCourse course, String classIds);
}
package com.server.web.common.service.Impl;
import com.server.web.common.mapper.TBaseSecondClassMapper;
import com.server.web.common.mapper.TKzyCourseMapper;
import com.server.web.common.mapper.TKzyRelationClassMapper;
import com.server.web.common.model.TBaseSecondClass;
import com.server.web.common.model.TKzyCourse;
import com.server.web.common.model.TKzyRelationClass;
import com.server.web.common.model.TKzyRelationClassExample;
import com.server.web.common.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class CourseServiceImpl implements CourseService {
@Autowired
private TKzyCourseMapper courseMapper;
@Autowired
private TKzyRelationClassMapper relationClassMapper;
@Autowired
private TBaseSecondClassMapper secondClassMapper;
@Override
public void insertCourse(TKzyCourse course, String classIds) {
courseMapper.insertSelective(course);
if(!("").equals(classIds)){
String [] id = classIds.split(",");
TKzyRelationClass relationClass = null;
for (int i=0;i<id.length;i++){
TBaseSecondClass secondClass = secondClassMapper.selectByPrimaryKey(Long.valueOf(id[i]));
relationClass = new TKzyRelationClass();
relationClass.setRelationId(course.getId());
relationClass.setFirstClassId(secondClass.getFirstId());
relationClass.setSecondClassId(secondClass.getId());
relationClass.setCreateDt(new Date());
relationClass.setType(1);
relationClassMapper.insertSelective(relationClass);
}
}
}
@Override
public void updateCourse(TKzyCourse course, String classIds) {
courseMapper.updateByPrimaryKeySelective(course);
TKzyRelationClassExample example = new TKzyRelationClassExample();
example.createCriteria().andRelationIdEqualTo(course.getId()).andTypeEqualTo(1);
relationClassMapper.deleteByExample(example);
if(!("").equals(classIds)){
String [] id = classIds.split(",");
TKzyRelationClass relationClass = null;
for (int i=0;i<id.length;i++){
TBaseSecondClass secondClass = secondClassMapper.selectByPrimaryKey(Long.valueOf(id[i]));
relationClass = new TKzyRelationClass();
relationClass.setRelationId(course.getId());
relationClass.setFirstClassId(secondClass.getFirstId());
relationClass.setSecondClassId(secondClass.getId());
relationClass.setCreateDt(new Date());
relationClass.setType(1);
relationClassMapper.insertSelective(relationClass);
}
}
}
}
...@@ -68,33 +68,33 @@ ...@@ -68,33 +68,33 @@
<javaClientGenerator targetPackage="com.server.web.common.mapper" targetProject="src/main/java" type="XMLMAPPER"> <javaClientGenerator targetPackage="com.server.web.common.mapper" targetProject="src/main/java" type="XMLMAPPER">
<property name="exampleMethodVisibility" value="public"/> <property name="exampleMethodVisibility" value="public"/>
</javaClientGenerator> </javaClientGenerator>
<table tableName="t_base_banner" schema="kzy_db_test"> <!--<table tableName="t_base_banner" schema="kzy_db_test">-->
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <!--<generatedKey column="ID" sqlStatement="JDBC" identity="true"/>-->
</table> <!--</table>-->
<table tableName="t_base_first_class" schema="kzy_db_test"> <!--<table tableName="t_base_first_class" schema="kzy_db_test">-->
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <!--<generatedKey column="ID" sqlStatement="JDBC" identity="true"/>-->
</table> <!--</table>-->
<table tableName="t_base_second_class" schema="kzy_db_test"> <!--<table tableName="t_base_second_class" schema="kzy_db_test">-->
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <!--<generatedKey column="ID" sqlStatement="JDBC" identity="true"/>-->
</table> <!--</table>-->
<table tableName="t_kzy_comment" schema="kzy_db_test"> <!--<table tableName="t_kzy_comment" schema="kzy_db_test">-->
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <!--<generatedKey column="ID" sqlStatement="JDBC" identity="true"/>-->
</table> <!--</table>-->
<table tableName="t_kzy_course" schema="kzy_db_test"> <!--<table tableName="t_kzy_course" schema="kzy_db_test">-->
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <!--<generatedKey column="ID" sqlStatement="JDBC" identity="true"/>-->
</table> <!--</table>-->
<table tableName="t_kzy_information" schema="kzy_db_test"> <!--<table tableName="t_kzy_information" schema="kzy_db_test">-->
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <!--<generatedKey column="ID" sqlStatement="JDBC" identity="true"/>-->
</table> <!--</table>-->
<table tableName="t_kzy_relation_class" schema="kzy_db_test"> <table tableName="t_kzy_relation_class" schema="kzy_db_test">
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <generatedKey column="ID" sqlStatement="JDBC" identity="true"/>
</table> </table>
<table tableName="t_kzy_user" schema="kzy_db_test"> <!--<table tableName="t_kzy_user" schema="kzy_db_test">-->
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <!--<generatedKey column="ID" sqlStatement="JDBC" identity="true"/>-->
</table> <!--</table>-->
<table tableName="t_kzy_user_integral_flowing" schema="kzy_db_test"> <!--<table tableName="t_kzy_user_integral_flowing" schema="kzy_db_test">-->
<generatedKey column="ID" sqlStatement="JDBC" identity="true"/> <!--<generatedKey column="ID" sqlStatement="JDBC" identity="true"/>-->
</table> <!--</table>-->
</context> </context>
</generatorConfiguration> </generatorConfiguration>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<arg column="first_class_id" javaType="java.lang.Long" jdbcType="BIGINT" /> <arg column="first_class_id" javaType="java.lang.Long" jdbcType="BIGINT" />
<arg column="second_class_id" javaType="java.lang.Long" jdbcType="BIGINT" /> <arg column="second_class_id" javaType="java.lang.Long" jdbcType="BIGINT" />
<arg column="create_dt" javaType="java.util.Date" jdbcType="TIMESTAMP" /> <arg column="create_dt" javaType="java.util.Date" jdbcType="TIMESTAMP" />
<arg column="type" javaType="java.lang.Integer" jdbcType="INTEGER" />
</constructor> </constructor>
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, relation_id, first_class_id, second_class_id, create_dt id, relation_id, first_class_id, second_class_id, create_dt, type
</sql> </sql>
<select id="selectByExample" parameterType="com.server.web.common.model.TKzyRelationClassExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.server.web.common.model.TKzyRelationClassExample" resultMap="BaseResultMap">
select select
...@@ -103,9 +104,9 @@ ...@@ -103,9 +104,9 @@
</delete> </delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.server.web.common.model.TKzyRelationClass" useGeneratedKeys="true"> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.server.web.common.model.TKzyRelationClass" useGeneratedKeys="true">
insert into t_kzy_relation_class (relation_id, first_class_id, second_class_id, insert into t_kzy_relation_class (relation_id, first_class_id, second_class_id,
create_dt) create_dt, type)
values (#{relationId,jdbcType=BIGINT}, #{firstClassId,jdbcType=BIGINT}, #{secondClassId,jdbcType=BIGINT}, values (#{relationId,jdbcType=BIGINT}, #{firstClassId,jdbcType=BIGINT}, #{secondClassId,jdbcType=BIGINT},
#{createDt,jdbcType=TIMESTAMP}) #{createDt,jdbcType=TIMESTAMP}, #{type,jdbcType=INTEGER})
</insert> </insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.server.web.common.model.TKzyRelationClass" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.server.web.common.model.TKzyRelationClass" useGeneratedKeys="true">
insert into t_kzy_relation_class insert into t_kzy_relation_class
...@@ -122,6 +123,9 @@ ...@@ -122,6 +123,9 @@
<if test="createDt != null"> <if test="createDt != null">
create_dt, create_dt,
</if> </if>
<if test="type != null">
type,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="relationId != null"> <if test="relationId != null">
...@@ -136,6 +140,9 @@ ...@@ -136,6 +140,9 @@
<if test="createDt != null"> <if test="createDt != null">
#{createDt,jdbcType=TIMESTAMP}, #{createDt,jdbcType=TIMESTAMP},
</if> </if>
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.server.web.common.model.TKzyRelationClassExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.server.web.common.model.TKzyRelationClassExample" resultType="java.lang.Long">
...@@ -162,6 +169,9 @@ ...@@ -162,6 +169,9 @@
<if test="record.createDt != null"> <if test="record.createDt != null">
create_dt = #{record.createDt,jdbcType=TIMESTAMP}, create_dt = #{record.createDt,jdbcType=TIMESTAMP},
</if> </if>
<if test="record.type != null">
type = #{record.type,jdbcType=INTEGER},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
...@@ -173,7 +183,8 @@ ...@@ -173,7 +183,8 @@
relation_id = #{record.relationId,jdbcType=BIGINT}, relation_id = #{record.relationId,jdbcType=BIGINT},
first_class_id = #{record.firstClassId,jdbcType=BIGINT}, first_class_id = #{record.firstClassId,jdbcType=BIGINT},
second_class_id = #{record.secondClassId,jdbcType=BIGINT}, second_class_id = #{record.secondClassId,jdbcType=BIGINT},
create_dt = #{record.createDt,jdbcType=TIMESTAMP} create_dt = #{record.createDt,jdbcType=TIMESTAMP},
type = #{record.type,jdbcType=INTEGER}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
...@@ -193,6 +204,9 @@ ...@@ -193,6 +204,9 @@
<if test="createDt != null"> <if test="createDt != null">
create_dt = #{createDt,jdbcType=TIMESTAMP}, create_dt = #{createDt,jdbcType=TIMESTAMP},
</if> </if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
</set> </set>
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
...@@ -201,7 +215,8 @@ ...@@ -201,7 +215,8 @@
set relation_id = #{relationId,jdbcType=BIGINT}, set relation_id = #{relationId,jdbcType=BIGINT},
first_class_id = #{firstClassId,jdbcType=BIGINT}, first_class_id = #{firstClassId,jdbcType=BIGINT},
second_class_id = #{secondClassId,jdbcType=BIGINT}, second_class_id = #{secondClassId,jdbcType=BIGINT},
create_dt = #{createDt,jdbcType=TIMESTAMP} create_dt = #{createDt,jdbcType=TIMESTAMP},
type = #{type,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
</mapper> </mapper>
\ No newline at end of file
...@@ -160,4 +160,48 @@ ...@@ -160,4 +160,48 @@
</select> </select>
<select id="queryCourseZbInfo" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT
c.id,
c.course_name AS courseName,
c.pic_url AS picUrl,
c.live_url AS liveUrl,
c.course_introduce AS courseIntroduce,
date_format(c.start_dt,'%Y-%m-%d %H:%i:%S') startDt,
date_format(c.end_dt,'%Y-%m-%d %H:%i:%S') endDt
FROM
t_kzy_course c
WHERE c.course_type = 1
AND c.id = #{id,jdbcType=BIGINT}
</select>
<select id="queryCourseClass" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT
t.first_class_id as firstClassId,
t1.class_name as firstName,
t.second_class_id as secondClassId,
t2.class_name as secondName
FROM
t_kzy_relation_class t
LEFT JOIN t_base_first_class t1 ON t1.id= t.first_class_id
LEFT JOIN t_base_second_class t2 ON t2.id = t.second_class_id
where t.type =1
AND t.relation_id = #{id,jdbcType=BIGINT}
ORDER BY t.create_dt ASC
</select>
<select id="queryCourseLbInfo" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT
c.id,
c.course_name AS courseName,
c.pic_url AS picUrl,
c.live_url AS liveUrl,
c.course_introduce AS courseIntroduce
FROM
t_kzy_course c
WHERE c.course_type = 2
AND c.id = #{id,jdbcType=BIGINT}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!