浏览代码

Merge branch 'master' of https://gitee.com/zouxuan/mec

yonge 5 年之前
父节点
当前提交
3dd0aa1f73

+ 12 - 12
mec-web/src/main/java/com/ym/mec/web/controller/SubjectController.java

@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
+import java.util.List;
 
 @RequestMapping("subject")
 @Api(tags = "科目服务")
@@ -21,11 +22,7 @@ public class SubjectController extends BaseController {
     @ApiOperation(value = "新增科目")
     @PostMapping("/add")
     public Object add(@RequestBody Subject subject){
-        Subject subjectByCode = subjectService.findByCode(subject.getCode());
-        if(subjectByCode != null){
-            return failed("科目编号已存在,请核查");
-        }
-        subjectService.insert(subject);
+        subjectService.addSubject(subject);
         return succeed();
     }
 
@@ -39,15 +36,18 @@ public class SubjectController extends BaseController {
     @ApiOperation(value = "修改科目")
     @PutMapping("/update")
     public Object update(@RequestBody Subject subject){
-        Subject subjectByCode = subjectService.findByCode(subject.getCode());
-        if(subjectByCode != null && !subjectByCode.getId().equals(subject.getId())){
-            return failed("科目编号已存在,请核查");
-        }
         subject.setUpdateTime(new Date());
         subjectService.update(subject);
         return succeed();
     }
 
+    @ApiOperation(value = "批量修改科目")
+    @PutMapping("/batchUpdate")
+    public Object batchUpdate(@RequestBody List<Subject> subjects){
+        subjectService.batchUpdate(subjects);
+        return succeed();
+    }
+
     @ApiOperation(value = "根据科目编号查询科目")
     @GetMapping("/get/{id}")
     public Object get(@ApiParam(value = "科目编号", required = true) @PathVariable("id") Integer id){
@@ -67,9 +67,9 @@ public class SubjectController extends BaseController {
     }
 
     @ApiOperation(value = "通过乐团编号查询乐团科目规划")
-    @PostMapping("/querySubByMusicGroupId")
+    @GetMapping("/querySubByMusicGroupId")
     @ApiImplicitParams({ @ApiImplicitParam(name = "musicGroupId", value = "乐团编号", required = true, dataType = "Integer")})
-    public Object findSubByMusicGroupId(@RequestBody Integer musicGroupId){
+    public Object findSubByMusicGroupId(@RequestParam Integer musicGroupId){
         return succeed(subjectService.findSubByMusicGroupId(musicGroupId));
     }
 
@@ -83,7 +83,7 @@ public class SubjectController extends BaseController {
     @ApiOperation(value = "通过乐团编号获取声部列表以及声部报名、缴费、计划人数")
     @GetMapping("/findSubApplyDetail")
     @ApiImplicitParams({ @ApiImplicitParam(name = "musicGroupId", value = "乐团编号", required = true, dataType = "Integer")})
-    public Object findSubApplyDetail(@RequestBody Integer musicGroupId){
+    public Object findSubApplyDetail(@RequestParam Integer musicGroupId){
         return succeed(subjectService.findSubApplyDetail(musicGroupId));
     }
 }

+ 48 - 3
mec-web/src/main/java/com/ym/mec/web/dal/entity/Organization.java

@@ -4,6 +4,7 @@ import com.ym.mec.web.dal.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -23,10 +24,10 @@ public class Organization {
 	private Integer code;
 	
 	/** 创建时间 */
-	private java.util.Date createTime;
+	private Date createTime;
 	
 	/** 修改时间 */
-	private java.util.Date updateTime;
+	private Date updateTime;
 	
 	/** 是否删除  -1:已删除  0:正常 */
 	@ApiModelProperty(value = "是否删除  1:已删除  0:正常",required = false)
@@ -36,6 +37,18 @@ public class Organization {
 	@ApiModelProperty(value = "父节点编号",required = false)
 	private Integer parentOrganId;
 
+	@ApiModelProperty(value = "成立日期",required = false)
+	private Date registerDate;
+
+	@ApiModelProperty(value = "联系人",required = false)
+	private String linkman;
+
+	@ApiModelProperty(value = "联系方式",required = false)
+	private String mobile;
+
+	@ApiModelProperty(value = "地址",required = false)
+	private String address;
+
 	@ApiModelProperty(value = "子节点列表",required = false)
 	private List<Organization> organizations;
 
@@ -102,7 +115,39 @@ public class Organization {
 	public Integer getParentOrganId(){
 		return this.parentOrganId;
 	}
-			
+
+	public Date getRegisterDate() {
+		return registerDate;
+	}
+
+	public void setRegisterDate(Date registerDate) {
+		this.registerDate = registerDate;
+	}
+
+	public String getLinkman() {
+		return linkman;
+	}
+
+	public void setLinkman(String linkman) {
+		this.linkman = linkman;
+	}
+
+	public String getMobile() {
+		return mobile;
+	}
+
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
+	}
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 12 - 0
mec-web/src/main/java/com/ym/mec/web/service/SubjectService.java

@@ -52,4 +52,16 @@ public interface SubjectService extends BaseService<Integer, Subject> {
      * @return
      */
     List<SubjectApplyDetailDto> findSubApplyDetail(Integer musicGroupId);
+
+    /**
+     * 新增科目树状结构
+     * @param subject
+     */
+    void addSubject(Subject subject);
+
+    /**
+     * 批量修改声部
+     * @param subjects
+     */
+    void batchUpdate(List<Subject> subjects);
 }

+ 27 - 1
mec-web/src/main/java/com/ym/mec/web/service/impl/SubjectServiceImpl.java

@@ -12,9 +12,10 @@ import com.ym.mec.web.dal.page.SubjectQueryInfo;
 import com.ym.mec.web.service.SubjectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
-import java.util.stream.Collectors;
 
 @Service
 public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject>  implements SubjectService {
@@ -67,6 +68,31 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject>  imple
 		return subApplyDetail;
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void addSubject(Subject subject) {
+		subjectDao.insert(subject);
+		List<Subject> subjects = subject.getSubjects();
+		if(subjects != null && subjects.size() > 0){
+			subjects.forEach(e->{
+				e.setParentSubjectId(subject.getId());
+				subjectDao.insert(e);
+			});
+		}
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void batchUpdate(List<Subject> subjects) {
+		if(subjects != null && subjects.size() > 0){
+			Date date = new Date();
+			subjects.forEach(e->{
+				e.setUpdateTime(date);
+				subjectDao.update(e);
+			});
+		}
+	}
+
 	private Subject getTree(Subject sub,YesOrNoEnum yesOrNoEnum){
 		//得到根节点对象
 		//获取子节点list

+ 18 - 2
mec-web/src/main/resources/config/mybatis/OrganizationMapper.xml

@@ -14,6 +14,10 @@
         <result column="update_time_" property="updateTime"/>
         <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="parent_organ_id_" property="parentOrganId"/>
+        <result column="register_date_" property="registerDate"/>
+        <result column="linkman_" property="linkman"/>
+        <result column="mobile_" property="mobile"/>
+        <result column="address_" property="address"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -34,8 +38,8 @@
         SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
         </selectKey>
         -->
-        INSERT INTO organization (id_,name_,code_,create_time_,update_time_,del_flag_,parent_organ_id_)
-        VALUES(#{id},#{name},#{code},now(),now(),#{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{parentOrganId})
+        INSERT INTO organization (id_,name_,code_,create_time_,update_time_,del_flag_,parent_organ_id_,register_date_,linkman_,mobile_,address_)
+        VALUES(#{id},#{name},#{code},now(),now(),#{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{parentOrganId},#{registerDate},#{linkman},#{mobile},#{address})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -57,6 +61,18 @@
             <if test="name != null">
                 name_ = #{name},
             </if>
+            <if test="registerDate != null">
+                register_date_ = #{registerDate},
+            </if>
+            <if test="linkman != null">
+                linkman_ = #{linkman},
+            </if>
+            <if test="mobile != null">
+                mobile_ = #{mobile},
+            </if>
+            <if test="address != null">
+                address_ = #{address},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>

+ 0 - 5
mec-web/src/main/resources/config/mybatis/StudentCourseHomeworkReplyMapper.xml

@@ -28,11 +28,6 @@
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.ym.mec.web.dal.entity.StudentCourseHomeworkReply" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
-        <!--
-        <selectKey resultClass="int" keyProperty="id" >
-        SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
-        </selectKey>
-        -->
         INSERT INTO student_course_homework_reply
         (id_,student_course_homework_id_,user_id_,content_,create_time_,parent_id_)
         VALUES(#{id},#{studentCourseHomeworkId},#{userId},#{content},now(),#{parentId})

+ 1 - 1
mec-web/src/main/resources/config/mybatis/SubjectMapper.xml

@@ -63,7 +63,7 @@
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
-		DELETE FROM subject WHERE id_ = #{id} 
+		DELETE FROM subject WHERE id_ = #{id} AND parent_subject_id_ = #{id}
 	</delete>
 
     <!-- 分页查询 -->