Ver código fonte

Merge remote-tracking branch 'origin/master'

Joburgess 5 anos atrás
pai
commit
1e3fb3e056

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SubjectGoodsMapperDao.java

@@ -1,10 +1,12 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.SubjectGoodsDto;
 import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface SubjectGoodsMapperDao extends BaseDAO<Long, SubjectGoodsMapper> {
 
@@ -20,4 +22,18 @@ public interface SubjectGoodsMapperDao extends BaseDAO<Long, SubjectGoodsMapper>
      * @param goodsCategoryId
      */
     void delByGoodsCategoryId(Integer goodsCategoryId);
+
+    /**
+     * COUNT声部关联的商品列表
+     * @param params
+     * @return
+     */
+    int countSubjectGoods(Map<String, Object> params);
+
+    /**
+     * 声部关联的商品列表
+     * @param params
+     * @return
+     */
+    List<SubjectGoodsDto> querySubjectGoods(Map<String, Object> params);
 }

+ 95 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SubjectGoodsDto.java

@@ -0,0 +1,95 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.Goods;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+public class SubjectGoodsDto {
+    @ApiModelProperty(value = "列表编号",required = false)
+    private Integer subjectGoodsMapperId;
+
+    @ApiModelProperty(value = "科目编号",required = false)
+    private Integer subjectId;
+
+    @ApiModelProperty(value = "科目名称",required = false)
+    private String subjectName;
+
+    @ApiModelProperty(value = "商品分类编号",required = false)
+    private Integer goodsCategoryId;
+
+    @ApiModelProperty(value = "商品分类名称",required = false)
+    private String goodsCategoryName;
+
+    private List<Goods> goodsList;
+
+    @ApiModelProperty(value = "乐器列表",required = false)
+    private List<Goods> instrument;
+
+    @ApiModelProperty(value = "辅件列表",required = false)
+    private List<Goods> accessories;
+
+    public List<Goods> getGoodsList() {
+        return goodsList;
+    }
+
+    public void setGoodsList(List<Goods> goodsList) {
+        this.goodsList = goodsList;
+    }
+
+    public Integer getSubjectGoodsMapperId() {
+        return subjectGoodsMapperId;
+    }
+
+    public void setSubjectGoodsMapperId(Integer subjectGoodsMapperId) {
+        this.subjectGoodsMapperId = subjectGoodsMapperId;
+    }
+
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+
+    public Integer getGoodsCategoryId() {
+        return goodsCategoryId;
+    }
+
+    public void setGoodsCategoryId(Integer goodsCategoryId) {
+        this.goodsCategoryId = goodsCategoryId;
+    }
+
+    public String getGoodsCategoryName() {
+        return goodsCategoryName;
+    }
+
+    public void setGoodsCategoryName(String goodsCategoryName) {
+        this.goodsCategoryName = goodsCategoryName;
+    }
+
+    public List<Goods> getInstrument() {
+        return instrument;
+    }
+
+    public void setInstrument(List<Goods> instrument) {
+        this.instrument = instrument;
+    }
+
+    public List<Goods> getAccessories() {
+        return accessories;
+    }
+
+    public void setAccessories(List<Goods> accessories) {
+        this.accessories = accessories;
+    }
+}

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

@@ -1,6 +1,9 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.dto.SubjectGoodsDto;
 import com.ym.mec.biz.dal.entity.GoodsCategory;
+import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface GoodsCategoryService extends BaseService<Integer, GoodsCategory> {
@@ -9,4 +12,18 @@ public interface GoodsCategoryService extends BaseService<Integer, GoodsCategory
      * @param goodsCategory
      */
     void upsetGoodsCategory(GoodsCategory goodsCategory);
+
+    /**
+     * 获取声部默认商品
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<SubjectGoodsDto> querySubjectGoods(GoodsCategoryQueryInfo queryInfo);
+
+    /**
+     * 修改声部关联的默认乐器
+     * @param subjectGoodsMapperId
+     * @param goodsIds
+     */
+    void updateSubjectGoods(Long subjectGoodsMapperId, String goodsIds);
 }

+ 43 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsCategoryServiceImpl.java

@@ -2,16 +2,23 @@ package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.GoodsCategoryDao;
 import com.ym.mec.biz.dal.dao.SubjectGoodsMapperDao;
+import com.ym.mec.biz.dal.dto.SubjectGoodsDto;
+import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.GoodsCategory;
+import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
+import com.ym.mec.biz.dal.enums.GoodsType;
+import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;
 import com.ym.mec.biz.service.GoodsCategoryService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
 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.*;
+import java.util.stream.Collectors;
 
 @Service
 public class GoodsCategoryServiceImpl extends BaseServiceImpl<Integer, GoodsCategory>  implements GoodsCategoryService {
@@ -41,4 +48,38 @@ public class GoodsCategoryServiceImpl extends BaseServiceImpl<Integer, GoodsCate
 		List<Integer> subjectIds = goodsCategory.getSubjectIds();
 		subjectGoodsMapperDao.batchAdd(goodsCategory.getId(),subjectIds);
 	}
+
+	@Override
+	public PageInfo<SubjectGoodsDto> querySubjectGoods(GoodsCategoryQueryInfo queryInfo) {
+		PageInfo<SubjectGoodsDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<SubjectGoodsDto> dataList = null;
+		int count = subjectGoodsMapperDao.countSubjectGoods(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = subjectGoodsMapperDao.querySubjectGoods(params);
+			dataList.forEach(e->{
+				e.setInstrument(e.getGoodsList().stream().filter(goods -> goods.getType() == GoodsType.INSTRUMENT).collect(Collectors.toList()));
+				e.setAccessories(e.getGoodsList().stream().filter(goods -> goods.getType() == GoodsType.ACCESSORIES).collect(Collectors.toList()));
+				e.setGoodsList(null);
+			});
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+
+	@Override
+	public void updateSubjectGoods(Long subjectGoodsMapperId, String goodsIds) {
+		SubjectGoodsMapper subjectGoodsMapper = new SubjectGoodsMapper();
+		subjectGoodsMapper.setId(subjectGoodsMapperId);
+		subjectGoodsMapper.setGoodsIdList(goodsIds);
+		subjectGoodsMapper.setUpdateTime(new Date());
+		subjectGoodsMapperDao.update(subjectGoodsMapper);
+	}
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -427,7 +427,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 //新增user
                 sysUser = new SysUser();
                 sysUser.setPhone(studentRegistration.getParentsPhone());
-                sysUser.setRealName(studentRegistration.getName());
+                sysUser.setRealName(studentRegistration.getParentsName());
                 sysUser.setUsername(studentRegistration.getName());
                 sysUser.setGender(studentRegistration.getGender());
                 sysUser.setUserType(SysUserType.STUDENT);

+ 22 - 2
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -132,13 +132,33 @@
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="Goods" parameterType="map">
         SELECT g.*,gc.name_ goods_category_name_ FROM goods g
-        LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_ ORDER BY g.id_
+        LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_
+        <include refid="queryGoodsPageSql"/>
+        ORDER BY g.id_
         <include refid="global.limit"/>
     </select>
 
+    <sql id="queryGoodsPageSql">
+        <where>
+            <if test="goodsCategoryId != null">
+                g.goods_category_id_ = #{goodsCategoryId}
+            </if>
+            <if test="isNew != null">
+                g.is_new_ = #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+            <if test="isTop != null">
+                g.is_top_ = #{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+            <if test="status != null">
+                g.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+        </where>
+    </sql>
+
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM goods
+		SELECT COUNT(*) FROM goods g
+        <include refid="queryGoodsPageSql"/>
 	</select>
 
     <select id="findGoodsBySubId" resultMap="Goods">

+ 2 - 5
mec-biz/src/main/resources/config/mybatis/StudentManageDao.xml

@@ -118,12 +118,9 @@
     </update>
 
     <select id="findStudentsByOrganId" resultMap="studentManageListDto">
-        SELECT su.id_ user_id_,su.username_ real_name_,su.gender_,
-        MAX(sr.parents_name_) parents_name_,MAX(sr.parents_phone_) parents_phone_
+        SELECT su.id_ user_id_,su.username_ real_name_,su.gender_,su.phone_ parents_phone_,su.real_name_ parents_name_
         FROM sys_user su
-        LEFT JOIN student_registration sr ON su.id_ = sr.user_id_
         <include refid="findStudentsByOrganIdSql"/>
-        GROUP BY su.id_
         ORDER BY su.create_time_ DESC
         <include refid="global.limit"/>
     </select>
@@ -137,7 +134,7 @@
                 AND su.username_ LIKE CONCAT('%',#{studentName},'%')
             </if>
             <if test="search != null and search != ''">
-                AND (sr.parents_name_ LIKE CONCAT('%',#{search},'%') OR sr.parents_phone_ LIKE CONCAT('%',#{search},'%'))
+                AND (su.phone_ LIKE CONCAT('%',#{search},'%') OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
             </if>
         </where>
     </sql>

+ 24 - 0
mec-biz/src/main/resources/config/mybatis/SubjectGoodsMapperMapper.xml

@@ -83,4 +83,28 @@
     <select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM subject_goods_mapper
 	</select>
+    <select id="countSubjectGoods" resultType="java.lang.Integer">
+        SELECT COUNT(sgm.id_) FROM subject_goods_mapper sgm
+    </select>
+    <select id="querySubjectGoods" resultMap="querySubjectGoodsMap">
+        SELECT sgc.*,g.type_ goods_type_,g.name_ goods_name_,g.id_ goods_id_ FROM
+        (SELECT s.name_ subject_name_,s.id_ subject_id_,gc.id_ goods_category_id_,gc.name_ goods_category_name_,
+        sgm.goods_id_list_,sgm.id_ subject_goods_mapper_id_
+        FROM subject_goods_mapper sgm
+        LEFT JOIN `subject` s ON s.id_ = sgm.subject_id_
+        LEFT JOIN goods_category gc ON gc.id_ = sgm.goods_category_id_ <include refid="global.limit"/>) sgc
+        LEFT JOIN goods g ON FIND_IN_SET(g.id_,sgc.goods_id_list_)
+    </select>
+    <resultMap id="querySubjectGoodsMap" type="com.ym.mec.biz.dal.dto.SubjectGoodsDto">
+        <result property="subjectName" column="subject_name_"/>
+        <result property="subjectGoodsMapperId" column="subject_goods_mapper_id_"/>
+        <result property="subjectId" column="subject_id_"/>
+        <result property="goodsCategoryId" column="goods_category_id_"/>
+        <result property="goodsCategoryName" column="goods_category_name_"/>
+        <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
+            <result property="id" column="goods_id_"/>
+            <result property="name" column="goods_name_"/>
+            <result property="type" column="goods_type_"/>
+        </collection>
+    </resultMap>
 </mapper>

+ 15 - 0
mec-web/src/main/java/com/ym/mec/web/controller/GoodsCategoryController.java

@@ -41,4 +41,19 @@ public class GoodsCategoryController extends BaseController {
     public Object queryPage(GoodsCategoryQueryInfo queryInfo) {
         return succeed(goodsCategoryService.queryPage(queryInfo));
     }
+
+    @ApiOperation(value = "分页查询科目默认商品")
+    @GetMapping("/querySubjectGoods")
+    @PreAuthorize("@pcs.hasPermissions('category/querySubjectGoods')")
+    public Object querySubjectGoods(GoodsCategoryQueryInfo queryInfo) {
+        return succeed(goodsCategoryService.querySubjectGoods(queryInfo));
+    }
+
+    @ApiOperation(value = "修改科目默认商品")
+    @PostMapping("/updateSubjectGoods")
+    @PreAuthorize("@pcs.hasPermissions('category/updateSubjectGoods')")
+    public Object updateSubjectGoods(Long subjectGoodsMapperId,String goodsIds) {
+        goodsCategoryService.updateSubjectGoods(subjectGoodsMapperId,goodsIds);
+        return succeed();
+    }
 }