Browse Source

add 分部课程时长设置

周箭河 4 năm trước cách đây
mục cha
commit
a04737fd02

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OrganizationCourseDurationSettingsDao.java

@@ -0,0 +1,21 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.biz.dal.entity.OrganizationCourseDurationSettings;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface OrganizationCourseDurationSettingsDao extends BaseDAO<Integer, OrganizationCourseDurationSettings> {
+
+	/**
+	 * 根据分部编号以及课程类型查询对象
+	 *
+	 * @param organId    分部编号
+	 * @param courseType 课程类型
+	 * @return
+	 */
+	OrganizationCourseDurationSettings queryByOrganIdAndCourseType(@Param("organId") Integer organId,
+																			  @Param("courseScheduleType") CourseScheduleType courseType);
+}

+ 92 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OrganizationCourseDurationSettings.java

@@ -0,0 +1,92 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(organization_course_unit_price_settings):
+ */
+public class OrganizationCourseDurationSettings {
+
+	/**  */
+	private Integer id;
+	
+	/**  */
+	private Integer organId;
+	
+	/** 课程类型 */
+	private CourseScheduleType courseType;
+
+	/** 课程时长 */
+	private String duration;
+
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+	
+	private Organization organ = new Organization();
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setOrganId(Integer organId){
+		this.organId = organId;
+	}
+	
+	public Integer getOrganId(){
+		return this.organId;
+	}
+			
+	public CourseScheduleType getCourseType() {
+		return courseType;
+	}
+
+	public void setCourseType(CourseScheduleType courseType) {
+		this.courseType = courseType;
+	}
+
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+
+
+	public Organization getOrgan() {
+		return organ;
+	}
+
+	public void setOrgan(Organization organ) {
+		this.organ = organ;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+	public String getDuration() {
+		return duration;
+	}
+
+	public void setDuration(String duration) {
+		this.duration = duration;
+	}
+}

+ 30 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/OrganizationDurationSettingsQueryInfo.java

@@ -0,0 +1,30 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+public class OrganizationDurationSettingsQueryInfo extends QueryInfo {
+
+	@ApiModelProperty(value = "分部编号", required = false)
+	private Integer organId;
+
+	@ApiModelProperty(value = "课程类型", required = false)
+	private CourseScheduleType courseScheduleType;
+
+	public Integer getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(Integer organId) {
+		this.organId = organId;
+	}
+
+	public CourseScheduleType getCourseScheduleType() {
+		return courseScheduleType;
+	}
+
+	public void setCourseScheduleType(CourseScheduleType courseScheduleType) {
+		this.courseScheduleType = courseScheduleType;
+	}
+}

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/OrganizationCourseDurationSettingsService.java

@@ -0,0 +1,17 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.biz.dal.entity.OrganizationCourseDurationSettings;
+import com.ym.mec.common.service.BaseService;
+
+public interface OrganizationCourseDurationSettingsService extends BaseService<Integer, OrganizationCourseDurationSettings> {
+
+    /**
+     * 根据分部编号以及课程类型查询对象
+     *
+     * @param organId    分部编号
+     * @param courseType 课程类型
+     * @return
+     */
+    OrganizationCourseDurationSettings queryByOrganIdAndCourseType(Integer organId, CourseScheduleType courseType);
+}

+ 28 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrganizationCourseDurationSettingsServiceImpl.java

@@ -0,0 +1,28 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.OrganizationCourseDurationSettingsDao;
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.biz.dal.entity.OrganizationCourseDurationSettings;
+import com.ym.mec.biz.service.OrganizationCourseDurationSettingsService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class OrganizationCourseDurationSettingsServiceImpl extends BaseServiceImpl<Integer, OrganizationCourseDurationSettings>  implements OrganizationCourseDurationSettingsService {
+	
+	@Autowired
+	private OrganizationCourseDurationSettingsDao organizationCourseDurationSettingsDao;
+
+	@Override
+	public BaseDAO<Integer, OrganizationCourseDurationSettings> getDAO() {
+		return organizationCourseDurationSettingsDao;
+	}
+
+	@Override
+	public OrganizationCourseDurationSettings queryByOrganIdAndCourseType(Integer organId, CourseScheduleType courseType) {
+		return organizationCourseDurationSettingsDao.queryByOrganIdAndCourseType(organId, courseType);
+	}
+	
+}

+ 110 - 0
mec-biz/src/main/resources/config/mybatis/OrganizationCourseDurationSettingsMapper.xml

@@ -0,0 +1,110 @@
+<?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="com.ym.mec.biz.dal.dao.OrganizationCourseDurationSettingsDao">
+
+    <resultMap type="com.ym.mec.biz.dal.entity.OrganizationCourseDurationSettings"
+               id="OrganizationCourseDurationSettings">
+        <result column="id_" property="id"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="duration_" property="duration"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+        <result column="organ_name_" property="organ.name"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="OrganizationCourseDurationSettings">
+        SELECT *
+        FROM organization_course_duration_settings
+        WHERE id_ = #{id}
+    </select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="OrganizationCourseDurationSettings">
+        SELECT *
+        FROM organization_course_duration_settings
+        ORDER BY id_
+    </select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.OrganizationCourseDurationSettings"
+            useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+        <!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval
+            AS ID FROM DUAL </selectKey> -->
+        INSERT INTO organization_course_duration_settings
+        (id_,organ_id_,course_type_,duration,create_time_,update_time_)
+        VALUES(#{id},#{organId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{duration},now(),now())
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.OrganizationCourseDurationSettings">
+        UPDATE organization_course_duration_settings
+        <set>
+            <if test="organId != null">
+                organ_id_ = #{organId},
+            </if>
+            <if test="id != null">
+                id_ = #{id},
+            </if>
+            <if test="courseType != null">
+                course_type_ = #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
+            <if test="duration != null">
+                duration_ = #{duration},
+            </if>
+            <if test="createTime != null">
+                create_time_ = #{createTime},
+            </if>
+            <if test="updateTime != null">
+                update_time_ = #{updateTime},
+            </if>
+        </set>
+        WHERE id_ = #{id}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+        DELETE
+        FROM organization_course_duration_settings
+        WHERE id_ = #{id}
+    </delete>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="OrganizationCourseDurationSettings" parameterType="map">
+        SELECT ocds.*,o.name_ organ_name_ FROM organization_course_duration_settings ocds
+        LEFT JOIN organization o on ocds.organ_id_ = o.id_
+        <where>
+            <if test="organId != null">
+                and ocds.organ_id_ = #{organId}
+            </if>
+            <if test="courseScheduleType != null">
+                and ocds.course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+        </where>
+        ORDER BY ocds.id_ desc
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(ups.id_) FROM organization_course_duration_settings ups
+        <where>
+            <if test="organId != null">
+                and ups.organ_id_ = #{organId}
+            </if>
+            <if test="courseScheduleType != null">
+                and ups.course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+        </where>
+    </select>
+
+    <select id="queryByOrganIdAndCourseType" resultMap="OrganizationCourseDurationSettings" parameterType="map">
+        SELECT *
+        FROM organization_course_duration_settings
+        WHERE organ_id_ = #{organId}
+          AND course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+    </select>
+
+</mapper>

+ 71 - 0
mec-web/src/main/java/com/ym/mec/web/controller/OrganizationCourseDurationSettingsController.java

@@ -0,0 +1,71 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.OrganizationCourseDurationSettings;
+import com.ym.mec.biz.dal.page.OrganizationDurationSettingsQueryInfo;
+import com.ym.mec.biz.service.OrganizationCourseDurationSettingsService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
+
+@RequestMapping("organizationCourseDurationSettings")
+@Api(tags = "分部课程时长设置服务")
+@RestController
+public class OrganizationCourseDurationSettingsController extends BaseController {
+
+    @Autowired
+    private OrganizationCourseDurationSettingsService organizationCourseDurationSettingsService;
+
+    @ApiOperation(value = "分页查询列表")
+    @GetMapping(value = "/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('organizationCourseDurationSettings/queryPage')")
+    public HttpResponseResult<PageInfo<OrganizationCourseDurationSettings>> queryPage(OrganizationDurationSettingsQueryInfo queryInfo) {
+        return succeed(organizationCourseDurationSettingsService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "新增分部课程时长")
+    @PostMapping(value = "/insert")
+    @PreAuthorize("@pcs.hasPermissions('organizationCourseDurationSettings/insert')")
+    public HttpResponseResult<OrganizationCourseDurationSettings> insert(OrganizationCourseDurationSettings organizationCourseDurationSettings) {
+        OrganizationCourseDurationSettings originalObj = organizationCourseDurationSettingsService.queryByOrganIdAndCourseType(
+                organizationCourseDurationSettings.getOrganId(), organizationCourseDurationSettings.getCourseType());
+        if (originalObj != null) {
+            return failed("当前分部已经存在该课程类型的课程时长设置");
+        }
+        organizationCourseDurationSettingsService.insert(organizationCourseDurationSettings);
+        return succeed(organizationCourseDurationSettings);
+    }
+
+    @ApiOperation(value = "修改分部课程时长设置")
+    @PostMapping(value = "/update")
+    @PreAuthorize("@pcs.hasPermissions('organizationCourseDurationSettings/update')")
+    public HttpResponseResult<OrganizationCourseDurationSettings> update(OrganizationCourseDurationSettings organizationCourseDurationSettings) {
+        organizationCourseDurationSettings.setUpdateTime(new Date());
+        organizationCourseDurationSettingsService.update(organizationCourseDurationSettings);
+        return succeed(organizationCourseDurationSettings);
+    }
+
+    @ApiOperation(value = "删除分部课程类型时长设置")
+    @PostMapping("/del/{id}")
+    @PreAuthorize("@pcs.hasPermissions('organizationCourseDurationSettings/del')")
+    public Object del(@ApiParam(value = "编号", required = true) @PathVariable("id") Integer id) {
+        organizationCourseDurationSettingsService.delete(id);
+        return succeed();
+    }
+
+    @ApiOperation(value = "获取分部对应类型课程的课程时长")
+    @GetMapping(value = "/queryByOrganIdAndCourseType")
+    @PreAuthorize("@pcs.hasPermissions('organizationCourseDurationSettings/queryByOrganIdAndCourseType')")
+    public HttpResponseResult<OrganizationCourseDurationSettings> queryByOrganIdAndCourseType(Integer organId, CourseSchedule.CourseScheduleType courseScheduleType) {
+        return succeed(organizationCourseDurationSettingsService.queryByOrganIdAndCourseType(organId, courseScheduleType));
+    }
+
+}