Selaa lähdekoodia

add 增加分部云教练价格配置

周箭河 4 vuotta sitten
vanhempi
commit
53b6fdc4f6

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OrganizationCloudTeacherFee.java

@@ -7,6 +7,9 @@ import java.util.Date;
 
 public class OrganizationCloudTeacherFee {
 
+    @ApiModelProperty(value = "")
+    private Integer Id;
+
     @ApiModelProperty(value = "分部id")
     private Integer organId;
 
@@ -17,6 +20,9 @@ public class OrganizationCloudTeacherFee {
 
     private Date updateTime;
 
+    @ApiModelProperty(value = "分部")
+    private String organName;
+
     public Integer getOrganId() {
         return organId;
     }
@@ -49,4 +55,19 @@ public class OrganizationCloudTeacherFee {
         this.updateTime = updateTime;
     }
 
+    public Integer getId() {
+        return Id;
+    }
+
+    public void setId(Integer id) {
+        Id = id;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
 }

+ 19 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/OrganizationCloudTeacherFeeQueryInfo.java

@@ -0,0 +1,19 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+
+public class OrganizationCloudTeacherFeeQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "所属分部编号", required = false)
+    private String organId;
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+}

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/OrganizationCloudTeacherFeeService.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee;
+import com.ym.mec.common.service.BaseService;
+
+public interface OrganizationCloudTeacherFeeService extends BaseService<Integer, OrganizationCloudTeacherFee> {
+
+    /**
+     * 新增分部云教练价格配置
+     * @param organizationCloudTeacherFee
+     * @return
+     */
+    OrganizationCloudTeacherFee add(OrganizationCloudTeacherFee organizationCloudTeacherFee);
+
+    /**
+     * 修改分部云教练价格配置
+     * @param organizationCloudTeacherFee
+     * @return
+     */
+    OrganizationCloudTeacherFee updateFee(OrganizationCloudTeacherFee organizationCloudTeacherFee);
+
+}

+ 43 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrganizationCloudTeacherFeeServiceImpl.java

@@ -0,0 +1,43 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.OrganizationCloudTeacherFeeDao;
+import com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee;
+import com.ym.mec.biz.service.OrganizationCloudTeacherFeeService;
+import com.ym.mec.common.dal.BaseDAO;
+
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class OrganizationCloudTeacherFeeServiceImpl extends BaseServiceImpl<Integer, OrganizationCloudTeacherFee> implements OrganizationCloudTeacherFeeService {
+
+    @Autowired
+    private OrganizationCloudTeacherFeeDao organizationCloudTeacherFeeDao;
+
+    @Override
+    public BaseDAO<Integer, OrganizationCloudTeacherFee> getDAO() {
+        return organizationCloudTeacherFeeDao;
+    }
+
+    @Override
+    public OrganizationCloudTeacherFee add(OrganizationCloudTeacherFee organizationCloudTeacherFee) {
+        OrganizationCloudTeacherFee old = organizationCloudTeacherFeeDao.getByOrganId(organizationCloudTeacherFee.getOrganId());
+        if (old != null) {
+            throw new BizException("分部配置已存在,不能重复添加");
+        }
+        organizationCloudTeacherFeeDao.insert(organizationCloudTeacherFee);
+        return organizationCloudTeacherFee;
+    }
+
+    @Override
+    public OrganizationCloudTeacherFee updateFee(OrganizationCloudTeacherFee organizationCloudTeacherFee) {
+        OrganizationCloudTeacherFee old = organizationCloudTeacherFeeDao.get(organizationCloudTeacherFee.getId());
+        if (old == null || old.getOrganId().equals(organizationCloudTeacherFee.getOrganId())) {
+            throw new BizException("分部不能修改,请核查");
+        }
+        organizationCloudTeacherFeeDao.update(organizationCloudTeacherFee);
+        return organizationCloudTeacherFee;
+    }
+}

+ 73 - 50
mec-biz/src/main/resources/config/mybatis/OrganizationCloudTeacherFeeMapper.xml

@@ -3,62 +3,85 @@
 <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 <mapper namespace="com.ym.mec.biz.dal.dao.OrganizationCloudTeacherFeeDao">
 
-	<resultMap type="com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee" id="OrganizationCloudTeacherFee">
-		<result column="organ_id_" property="organId" />
-		<result column="price_" property="price" />
-		<result column="create_time_" property="createTime" />
-		<result column="update_time_" property="updateTime" />
-	</resultMap>
+    <resultMap type="com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee" id="OrganizationCloudTeacherFee">
+        <id column="id_" property="id"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="price_" property="price"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+        <result column="organName" property="organName"/>
+    </resultMap>
 
-	<!-- 根据主键查询一条记录 -->
-	<select id="get" resultMap="OrganizationCloudTeacherFee">
-		SELECT * FROM
-		organization_cloud_teacher_fee WHERE organ_id_ = #{id}
-	</select>
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="OrganizationCloudTeacherFee">
+        SELECT *
+        FROM organization_cloud_teacher_fee
+        WHERE id_ = #{id}
+    </select>
 
-	<!-- 全查询 -->
-	<select id="findAll" resultMap="OrganizationCloudTeacherFee">
-		SELECT * FROM organization_cloud_teacher_fee
-		ORDER BY id_
-	</select>
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="OrganizationCloudTeacherFee">
+        SELECT *
+        FROM organization_cloud_teacher_fee
+        ORDER BY id_
+    </select>
 
-	<!-- 向数据库增加一条记录 -->
-	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee"
-		useGeneratedKeys="true" keyColumn="id_" keyProperty="id">
-		INSERT INTO organization_cloud_teacher_fee
-		(organ_id_, price_,  create_time_, update_time_)
-		VALUES(#{organId},#{price},NOW(),NOW())
-	</insert>
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee"
+            useGeneratedKeys="true" keyColumn="id_" keyProperty="id">
+        INSERT INTO organization_cloud_teacher_fee
+            (organ_id_, price_, create_time_, update_time_)
+        VALUES (#{organId}, #{price}, NOW(), NOW())
+    </insert>
 
-	<!-- 根据主键查询一条记录 -->
-	<update id="update" parameterType="com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee">
-		UPDATE organization_cloud_teacher_fee
-		<set>
-			<if test="price != null">
-				price_ = #{price},
-			</if>
-			update_time_=NOW()
-		</set>
-		WHERE organ_id_ = #{organId}
-	</update>
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee">
+        UPDATE organization_cloud_teacher_fee
+        <set>
+            <if test="price != null">
+                price_ = #{price},
+            </if>
+            update_time_=NOW()
+        </set>
+        WHERE id_ = #{id}
+    </update>
 
-	<!-- 根据主键删除一条记录 -->
-	<delete id="delete">
-		DELETE FROM organization_cloud_teacher_fee WHERE id_ = #{id}
-	</delete>
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+        DELETE
+        FROM organization_cloud_teacher_fee
+        WHERE id_ = #{id}
+    </delete>
 
-	<!-- 分页查询 -->
-	<select id="queryPage" resultMap="OrganizationCloudTeacherFee" parameterType="map">
-		SELECT * FROM organization_cloud_teacher_fee ORDER BY id_
-		<include refid="global.limit" />
-	</select>
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="OrganizationCloudTeacherFee" parameterType="map">
+        SELECT octf.*,o.name_ organName FROM organization_cloud_teacher_fee octf
+        LEFT JOIN organization o ON octf.organ_id_ = o.id_
+        <include refid="queryPageSql"/>
+        <include refid="global.limit"/>
+    </select>
 
-	<!-- 查询当前表的总记录数 -->
-	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM organization_cloud_teacher_fee
-	</select>
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*) FROM organization_cloud_teacher_fee octf
+        LEFT JOIN organization o on octf.organ_id_ = o.id_
+        <include refid="queryPageSql"/>
+    </select>
 
-	<select id="getByOrganId" resultMap="OrganizationCloudTeacherFee">
-		SELECT * FROM organization_cloud_teacher_fee WHERE organ_id_ = #{organId}
-	</select>
+    <sql id="queryPageSql">
+        <where>
+            <if test="organId != null">
+                AND FIND_IN_SET(octf.organ_id_,#{organId})
+            </if>
+            <if test="search != null">
+                AND (octf.organ_id_ =#{search} OR o.name_ LIKE CONCAT('%',#{search},'%'))
+            </if>
+        </where>
+    </sql>
+
+    <select id="getByOrganId" resultMap="OrganizationCloudTeacherFee">
+        SELECT *
+        FROM organization_cloud_teacher_fee
+        WHERE organ_id_ = #{organId}
+    </select>
 </mapper>

+ 75 - 0
mec-web/src/main/java/com/ym/mec/web/controller/OrganizationCloudTeacherFeeController.java

@@ -0,0 +1,75 @@
+package com.ym.mec.web.controller;
+
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee;
+import com.ym.mec.biz.dal.page.OrganizationCloudTeacherFeeQueryInfo;
+import com.ym.mec.biz.service.OrganizationCloudTeacherFeeService;
+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 org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Arrays;
+import java.util.List;
+
+@RequestMapping("organizationCloudTeacherFee")
+@Api(tags = "分部云教练价格配置服务")
+@RestController
+public class OrganizationCloudTeacherFeeController extends BaseController {
+
+    @Autowired
+    private OrganizationCloudTeacherFeeService organizationCloudTeacherFeeService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private EmployeeDao employeeDao;
+
+    @ApiOperation(value = "分页查询分部列表")
+    @GetMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('organizationCloudTeacherFee/queryPage')")
+    public HttpResponseResult<PageInfo<OrganizationCloudTeacherFee>> queryPage(OrganizationCloudTeacherFeeQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+            return failed("用户所在分部异常");
+        } else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
+                return failed("非法请求");
+            }
+        }
+        return succeed(organizationCloudTeacherFeeService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "新增分部配置")
+    @PostMapping("/add")
+    @PreAuthorize("@pcs.hasPermissions('organizationCloudTeacherFee/add')")
+    public HttpResponseResult<OrganizationCloudTeacherFee> add(OrganizationCloudTeacherFee organizationCloudTeacherFee) {
+        return succeed(organizationCloudTeacherFeeService.add(organizationCloudTeacherFee));
+    }
+
+    @ApiOperation(value = "修改分部配置")
+    @PostMapping("/update")
+    @PreAuthorize("@pcs.hasPermissions('organizationCloudTeacherFee/update')")
+    public HttpResponseResult<OrganizationCloudTeacherFee> update(OrganizationCloudTeacherFee organizationCloudTeacherFee) {
+        return succeed(organizationCloudTeacherFeeService.updateFee(organizationCloudTeacherFee));
+    }
+
+}