Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/MusicTheoryDao.java
#	edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/MusicTheory.java
#	edu-user/edu-user-server/src/main/resources/config/mybatis/MusicTheoryMapper.xml
Joburgess 5 rokov pred
rodič
commit
8b2a86ff0c

+ 14 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java

@@ -1,5 +1,7 @@
 package com.keao.edu.user.controller;
 
+import com.keao.edu.auth.api.client.SysUserFeignService;
+import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
@@ -23,6 +25,8 @@ public class ExamRegistrationController extends BaseController {
 
     @Autowired
     private ExamRegistrationService examRegistrationService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     @ApiOperation(value = "学员报名记录查询")
     @GetMapping(value = "list")
@@ -39,4 +43,14 @@ public class ExamRegistrationController extends BaseController {
         return succeed();
     }
 
+
+    @ApiOperation(value = "报名")
+    @PostMapping(value = "add")
+    @PreAuthorize("@pcs.hasPermissions('examRegistration/add')")
+    public HttpResponseResult add(ExamRegistration examRegistration) {
+        SysUser student = sysUserFeignService.queryUserInfo();
+        examRegistration.setStudentId(student.getId());
+        return succeed(examRegistrationService.addRegistration(examRegistration));
+    }
+
 }

+ 70 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/MusicTheoryController.java

@@ -0,0 +1,70 @@
+package com.keao.edu.user.controller;
+
+import com.keao.edu.common.controller.BaseController;
+import com.keao.edu.common.entity.HttpResponseResult;
+import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.common.page.QueryInfo;
+import com.keao.edu.common.tenant.TenantContextHolder;
+import com.keao.edu.user.entity.ExamSong;
+import com.keao.edu.user.entity.MusicTheory;
+import com.keao.edu.user.service.ExamSongService;
+import com.keao.edu.user.service.MusicTheoryService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.Date;
+
+/**
+ * @Author wangyp
+ * @Date 2020/6/27 9:17
+ * @Description TODO
+ */
+@RestController
+@RequestMapping("musicTheory")
+@Api(tags = "乐理信息")
+public class MusicTheoryController extends BaseController {
+
+    @Autowired
+    private MusicTheoryService musicTheoryService;
+
+    @ApiOperation("分页查询")
+    @GetMapping(value = "/list")
+    public HttpResponseResult<PageInfo<MusicTheory>> getList(QueryInfo queryInfo) {
+        return succeed(musicTheoryService.queryPage(queryInfo));
+    }
+
+    @ApiOperation("查询乐理详情")
+    @ApiImplicitParam(name = "id", value = "机构ID", required = true, dataType = "Integer", paramType = "path")
+    @GetMapping(value = "/query")
+    public HttpResponseResult<MusicTheory> query(@RequestParam("id") Integer id) {
+        return succeed(musicTheoryService.get(id));
+    }
+
+    @ApiOperation("新增乐理")
+    @PostMapping(value = "/add")
+    public HttpResponseResult add(@ApiParam(value = "乐理信息") @RequestBody MusicTheory musicTheory) {
+        musicTheory.setTenantId(TenantContextHolder.getTenantId().toString());
+        musicTheoryService.insert(musicTheory);
+        return succeed();
+    }
+
+    @ApiOperation("更新乐理")
+    @PostMapping(value = "/update")
+    public HttpResponseResult update(@ApiParam(value = "乐理信息") @RequestBody MusicTheory musicTheory) {
+        musicTheoryService.update(musicTheory);
+        return succeed();
+    }
+
+    @ApiOperation("删除乐理")
+    @PostMapping(value = "/del/{id}")
+    public HttpResponseResult add(@PathVariable("id") Integer id) {
+        return succeed(musicTheoryService.delete(id));
+    }
+
+
+}

+ 5 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/MusicTheoryDao.java

@@ -3,7 +3,11 @@ package com.keao.edu.user.dao;
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.user.entity.MusicTheory;
 
+/**
+ * @author: wangyp
+ * @Date: 2020/6/27 11:26
+ * @desc 乐理Dao
+ */
 public interface MusicTheoryDao extends BaseDAO<Integer, MusicTheory> {
 
-	
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRegistration.java

@@ -8,7 +8,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 /**
  * 对应数据库表(exam_registration):
  */
-public class ExamRegistration {
+public class ExamRegistration extends Student {
 
 	private Long id;
 	

+ 68 - 72
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/MusicTheory.java

@@ -1,81 +1,77 @@
 package com.keao.edu.user.entity;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.util.Date;
 
 /**
- * 对应数据库表(music_theory):
+ * @Author wangyp
+ * @Date 2020/6/27 11:22
+ * @Description music_theory(乐理表)
  */
 public class MusicTheory {
 
-	/**  */
-	private Integer id;
-	
-	/** 等级 */
-	private Integer level;
-	
-	/** 费用 */
-	private java.math.BigDecimal fee;
-	
-	/**  */
-	private Integer tenantId;
-	
-	/**  */
-	private java.util.Date createTime;
-	
-	/**  */
-	private java.util.Date updateTime;
-	
-	public void setId(Integer id){
-		this.id = id;
-	}
-	
-	public Integer getId(){
-		return this.id;
-	}
-			
-	public void setLevel(Integer level){
-		this.level = level;
-	}
-	
-	public Integer getLevel(){
-		return this.level;
-	}
-			
-	public void setFee(java.math.BigDecimal fee){
-		this.fee = fee;
-	}
-	
-	public java.math.BigDecimal getFee(){
-		return this.fee;
-	}
-			
-	public void setTenantId(Integer tenantId){
-		this.tenantId = tenantId;
-	}
-	
-	public Integer getTenantId(){
-		return this.tenantId;
-	}
-			
-	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;
-	}
-			
-	@Override
-	public String toString() {
-		return ToStringBuilder.reflectionToString(this);
-	}
+    @ApiModelProperty(value = "乐理编号")
+    private Integer id;
+
+    @ApiModelProperty(value = "乐理等级")
+    private Integer level;
+
+    @ApiModelProperty(value = "乐理费用")
+    private BigDecimal fee;
+
+    private java.util.Date createTime;
+
+    private java.util.Date updateTime;
+
+    private String tenantId;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getLevel() {
+        return level;
+    }
+
+    public void setLevel(Integer level) {
+        this.level = level;
+    }
+
+    public BigDecimal getFee() {
+        return fee;
+    }
+
+    public void setFee(BigDecimal fee) {
+        this.fee = fee;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getTenantId() {
+        return tenantId;
+    }
 
+    public void setTenantId(String tenantId) {
+        this.tenantId = tenantId;
+    }
 }

+ 2 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationService.java

@@ -6,4 +6,6 @@ import com.keao.edu.user.entity.ExamRegistration;
 
 public interface ExamRegistrationService extends BaseService<Long, ExamRegistration> {
 
+   ExamRegistration addRegistration(ExamRegistration examRegistration);
+
 }

+ 32 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java

@@ -5,12 +5,18 @@ import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
+import com.keao.edu.user.dao.ExamCertificationDao;
 import com.keao.edu.user.dao.ExamRegistrationDao;
+import com.keao.edu.user.dao.ExaminationBasicDao;
+import com.keao.edu.user.dao.StudentDao;
+import com.keao.edu.user.entity.ExamCertification;
 import com.keao.edu.user.entity.ExamRegistration;
+import com.keao.edu.user.entity.ExaminationBasic;
 import com.keao.edu.user.service.ExamRegistrationService;
 import com.keao.edu.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -20,6 +26,12 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
 	
 	@Autowired
 	private ExamRegistrationDao examRegistrationDao;
+	@Autowired
+	private StudentDao studentDao;
+	@Autowired
+	private ExamCertificationDao examCertificationDao;
+	@Autowired
+	private ExaminationBasicDao examinationBasicDao;
 
 	@Override
 	public BaseDAO<Long, ExamRegistration> getDAO() {
@@ -51,4 +63,24 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
 
 		return pageInfo;
 	}
+
+    @Override
+	@Transactional(rollbackFor = Exception.class)
+    public ExamRegistration addRegistration(ExamRegistration examRegistration) {
+		examRegistration.setUserId(examRegistration.getStudentId());
+		studentDao.insert(examRegistration);
+		examRegistrationDao.insert(examRegistration);
+
+		ExaminationBasic examinationBasic = examinationBasicDao.get(examRegistration.getExaminationBasicId().longValue());
+		ExamCertification examCertification = new ExamCertification();
+		examCertification.setExaminationBasicId(examRegistration.getExaminationBasicId());
+		examCertification.setStudentId(examRegistration.getStudentId());
+		examCertification.setCardNo(examRegistration.getCardNo());
+		examCertification.setSubjectId(examRegistration.getSubjectId());
+		examCertification.setLevel(examRegistration.getLevel());
+		examCertification.setExamStartTime(examinationBasic.getExpectExamStartTime());
+		examCertification.setExamEndTime(examinationBasic.getExpectExamEndTime());
+		examCertificationDao.insert(examCertification);
+		return examRegistration;
+    }
 }

+ 37 - 14
edu-user/edu-user-server/src/main/resources/config/mybatis/MusicTheoryMapper.xml

@@ -10,59 +10,82 @@
 		<result column="id_" property="id" />
 		<result column="level_" property="level" />
 		<result column="fee_" property="fee" />
-		<result column="tenant_id_" property="tenantId" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
+		<result column="tenant_id_" property="tenantId" />
 	</resultMap>
-	
+
+	<sql id="Base_Column_List">
+        id_, level_, fee_, create_time_, update_time_, tenant_id_
+  </sql>
+
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="MusicTheory" >
-		SELECT * FROM music_theory WHERE id_ = #{id} 
+		SELECT <include refid="Base_Column_List"/> FROM music_theory WHERE id_ = #{id}
 	</select>
 	
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="MusicTheory">
-		SELECT * FROM music_theory ORDER BY id_
+		SELECT <include refid="Base_Column_List"/> FROM music_theory WHERE tenant_id_ = #{tenantId} ORDER BY id_
 	</select>
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.keao.edu.user.entity.MusicTheory" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO music_theory (id_,level_,fee_,tenant_id_,create_time_,update_time_)
-		VALUES(#{id},#{level},#{fee},#{tenantId},NOW(),NOW())
+		INSERT INTO music_theory (id_,level_,fee_,create_time_,update_time_,tenant_id_)
+		VALUES(#{id},#{level},#{fee},NOW(),NOW(),#{tenantId})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.keao.edu.user.entity.MusicTheory">
 		UPDATE music_theory
 		<set>
+			<if test="level != null">
+				level_ = #{level},
+			</if>
 			<if test="id != null">
 				id_ = #{id},
 			</if>
 			<if test="fee != null">
 				fee_ = #{fee},
 			</if>
-			<if test="tenantId != null">
-				tenant_id_ = #{tenantId},
+			<if test="createTime != null">
+				create_time_ = #{createTime},
 			</if>
-			<if test="level != null">
-				level_ = #{level},
+			<if test="tenantId">
+				tenant_id_ = #{tenantId},
 			</if>
-				update_time_ = NOW()
+			update_time_ = NOW()
 		</set> WHERE id_ = #{id}
 	</update>
 	
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
-		DELETE FROM music_theory WHERE id_ = #{id} 
+		DELETE FROM music_theory WHERE id_ = #{id}
 	</delete>
-	
+
+	<sql id="queryCondition">
+		<where>
+			1=1 AND tenant_id_ = #{tenantId}
+			<!--<if test="subjectList!=null">-->
+				<!--AND FIND_IN_SET(#{subjectList}, subject_list_)-->
+			<!--</if>-->
+			<!--<if test="search!=null">-->
+				<!--AND (id_=#{search} OR song_name_ LIKE CONCAT('%', #{search}, '%'))-->
+			<!--</if>-->
+		</where>
+	</sql>
+
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="MusicTheory" parameterType="map">
-		SELECT * FROM music_theory ORDER BY id_ <include refid="global.limit"/>
+		SELECT * FROM music_theory
+		<include refid="queryCondition"/>
+		ORDER BY id_
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM music_theory
+		<include refid="queryCondition"/>
 	</select>
 </mapper>