Commit 73d40d8a by qwmqiuwenmin

fix

parent 1db08d6c
...@@ -2,6 +2,8 @@ package com.gic.haoban.manage.api.service; ...@@ -2,6 +2,8 @@ package com.gic.haoban.manage.api.service;
import java.util.List; import java.util.List;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.MaterialCategoryDTO; import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO; import com.gic.haoban.manage.api.dto.MaterialDTO;
...@@ -19,4 +21,12 @@ public interface MaterialApiService { ...@@ -19,4 +21,12 @@ public interface MaterialApiService {
List<MaterialDTO> listMaterialByCategoryId(String categoryId); List<MaterialDTO> listMaterialByCategoryId(String categoryId);
void insertCategory(MaterialDTO materialDTO);
MaterialDTO selectMaterialById(String materialId);
void editCategory(MaterialDTO materialDTO);
Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId, Integer materialType,BasePageInfo pageInfo);
} }
package com.gic.haoban.manage.service.dao.mapper; package com.gic.haoban.manage.service.dao.mapper;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.TabHaobanMaterial; import com.gic.haoban.manage.service.entity.TabHaobanMaterial;
import com.github.pagehelper.Page;
public interface TabHaobanMaterialMapper { public interface TabHaobanMaterialMapper {
int deleteByPrimaryKey(String materialId); int deleteByPrimaryKey(String materialId);
...@@ -16,4 +19,6 @@ public interface TabHaobanMaterialMapper { ...@@ -16,4 +19,6 @@ public interface TabHaobanMaterialMapper {
int updateByPrimaryKey(TabHaobanMaterial record); int updateByPrimaryKey(TabHaobanMaterial record);
TabHaobanMaterial listMaterialByCategoryId(String categoryId); TabHaobanMaterial listMaterialByCategoryId(String categoryId);
Page<TabHaobanMaterial> listMaterial(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("keyword")String keyword, @Param("categoryId")String categoryId, @Param("materialType")Integer materialType);
} }
\ No newline at end of file
...@@ -8,4 +8,13 @@ public interface MaterialService { ...@@ -8,4 +8,13 @@ public interface MaterialService {
List<MaterialDTO> listMaterialByCategoryId(String categoryId); List<MaterialDTO> listMaterialByCategoryId(String categoryId);
void insertCategory(MaterialDTO materialDTO);
MaterialDTO selectMaterialById(String materialId);
void edit(MaterialDTO materialDTO);
com.github.pagehelper.Page listMaterial(String wxEnterpriseId, String keyword, String categoryId,
Integer materialType);
} }
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.MaterialDTO; import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanMaterialMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanMaterialMapper;
import com.gic.haoban.manage.service.entity.TabHaobanMaterial;
import com.gic.haoban.manage.service.service.MaterialService; import com.gic.haoban.manage.service.service.MaterialService;
import com.github.pagehelper.Page;
@Service @Service
public class MaterialServiceImpl implements MaterialService { public class MaterialServiceImpl implements MaterialService {
...@@ -21,4 +25,30 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -21,4 +25,30 @@ public class MaterialServiceImpl implements MaterialService {
return EntityUtil.changeEntityListByJSON(MaterialDTO.class, mapper.listMaterialByCategoryId(categoryId)); return EntityUtil.changeEntityListByJSON(MaterialDTO.class, mapper.listMaterialByCategoryId(categoryId));
} }
@Override
public void insertCategory(MaterialDTO materialDTO) {
materialDTO.setCreateTime(new Date());
materialDTO.setUpdateTime(materialDTO.getCreateTime());
materialDTO.setStatusFlag(1);
materialDTO.setMaterialId(StringUtil.randomUUID());
mapper.insert(EntityUtil.changeEntityByJSON(TabHaobanMaterial.class, materialDTO));
}
@Override
public MaterialDTO selectMaterialById(String materialId) {
return EntityUtil.changeEntityByJSON(MaterialDTO.class, mapper.selectByPrimaryKey(materialId));
}
@Override
public void edit(MaterialDTO materialDTO) {
materialDTO.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(EntityUtil.changeEntityByJSON(TabHaobanMaterial.class, materialDTO));
}
@Override
public Page<TabHaobanMaterial> listMaterial(String wxEnterpriseId, String keyword, String categoryId, Integer materialType) {
return mapper.listMaterial(wxEnterpriseId,keyword,categoryId,materialType);
}
} }
...@@ -5,11 +5,16 @@ import java.util.List; ...@@ -5,11 +5,16 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.MaterialCategoryDTO; import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO; import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.service.MaterialApiService; import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.service.service.MaterialCategoryService; import com.gic.haoban.manage.service.service.MaterialCategoryService;
import com.gic.haoban.manage.service.service.MaterialService; import com.gic.haoban.manage.service.service.MaterialService;
import com.github.pagehelper.PageHelper;
@Service @Service
public class MaterialApiServiceImpl implements MaterialApiService { public class MaterialApiServiceImpl implements MaterialApiService {
...@@ -62,4 +67,27 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -62,4 +67,27 @@ public class MaterialApiServiceImpl implements MaterialApiService {
return materialService.listMaterialByCategoryId(categoryId); return materialService.listMaterialByCategoryId(categoryId);
} }
@Override
public void insertCategory(MaterialDTO materialDTO) {
materialService.insertCategory(materialDTO);
}
@Override
public MaterialDTO selectMaterialById(String materialId) {
return materialService.selectMaterialById(materialId);
}
@Override
public void editCategory(MaterialDTO materialDTO) {
materialService.edit(materialDTO);
}
@Override
public Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId,
Integer materialType,BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
return PageUtil.changePageHelperToCurrentPage(materialService.listMaterial(wxEnterpriseId,keyword,categoryId,materialType),MaterialDTO.class);
}
} }
...@@ -229,4 +229,12 @@ ...@@ -229,4 +229,12 @@
where category_id = #{categoryId,jdbcType=VARCHAR} where category_id = #{categoryId,jdbcType=VARCHAR}
and status_flag = 1 and status_flag = 1
</select> </select>
<select id="listMaterial" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from tab_haoban_material
where status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -8,11 +8,17 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -8,11 +8,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.HaobanResponse; import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.MaterialCategoryDTO; import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO; import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.service.MaterialApiService; import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.LoginVO;
@RestController @RestController
public class MaterialController extends WebBaseController{ public class MaterialController extends WebBaseController{
...@@ -26,6 +32,9 @@ public class MaterialController extends WebBaseController{ ...@@ -26,6 +32,9 @@ public class MaterialController extends WebBaseController{
*/ */
@RequestMapping("/mateial-add-category") @RequestMapping("/mateial-add-category")
public HaobanResponse materialAddCategory(MaterialCategoryDTO materialCategoryDTO) { public HaobanResponse materialAddCategory(MaterialCategoryDTO materialCategoryDTO) {
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
materialCategoryDTO.setWxEnterpriseId(wxEnterpriseId);
String categoryName = materialCategoryDTO.getCategoryName(); String categoryName = materialCategoryDTO.getCategoryName();
String categoryParentId = materialCategoryDTO.getCategoryParentId(); String categoryParentId = materialCategoryDTO.getCategoryParentId();
if(StringUtils.isAnyBlank(categoryParentId,categoryName)){ if(StringUtils.isAnyBlank(categoryParentId,categoryName)){
...@@ -92,6 +101,100 @@ public class MaterialController extends WebBaseController{ ...@@ -92,6 +101,100 @@ public class MaterialController extends WebBaseController{
materialApiService.editCategory(dto); materialApiService.editCategory(dto);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
/**
* 素材新增
* @return
*/
@RequestMapping("/material-add")
public HaobanResponse materialAdd(MaterialDTO materialDTO) {
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
materialDTO.setWxEnterpriseId(wxEnterpriseId);
StaffDTO staff = login.getStaffDTO();
materialDTO.setStaffId(staff.getStaffId());
materialDTO.setStaffName(staff.getStaffName());
String materialTitle = materialDTO.getMaterialTitle();
String categoryId = materialDTO.getCategoryId();
Integer categoryType = materialDTO.getMaterialType();
if(StringUtils.isAnyBlank(categoryId,materialTitle)){
return resultResponse(HaoBanErrCode.ERR_2);
}
if(categoryType == null){
return resultResponse(HaoBanErrCode.ERR_2);
}
materialApiService.insertCategory(materialDTO);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 素材修改
* @return
*/
@RequestMapping("/material-eidt")
public HaobanResponse materialEdit(MaterialDTO materialDTO) {
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
StaffDTO staff = login.getStaffDTO();
materialDTO.setStaffId(staff.getStaffId());
materialDTO.setStaffName(staff.getStaffName());
String materialId = materialDTO.getMaterialId();
MaterialDTO dto = materialApiService.selectMaterialById(materialId);
if(dto == null){
return resultResponse(HaoBanErrCode.ERR_2);
}
materialApiService.editCategory(materialDTO);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 素材删除
* @return
*/
@RequestMapping("/material-del")
public HaobanResponse materialEdit(String materialIds) {
if(StringUtils.isBlank(materialIds)){
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] stringArr = materialIds.split(",");
for (String materialId : stringArr) {
MaterialDTO dto = materialApiService.selectMaterialById(materialId);
if(dto == null){
continue;
}
dto.setStatusFlag(0);
materialApiService.editCategory(dto);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 素材查询
* @return
*/
@RequestMapping("/material-list")
public HaobanResponse materialList(String wxEnterpriseId,String keyword,String categoryId,Integer materialType,BasePageInfo pageInfo) {
Page<MaterialDTO> page = materialApiService.listMaterial(wxEnterpriseId,keyword,categoryId,materialType,pageInfo);
return resultResponse(HaoBanErrCode.ERR_1,page);
}
/**
* 素材批量转移
* @return
*/
@RequestMapping("/material-batch")
public HaobanResponse materialBatch(String materialIds,String categoryId) {
String[] stringArr = materialIds.split(",");
for (String materialId : stringArr) {
MaterialDTO dto = materialApiService.selectMaterialById(materialId);
if(dto == null){
continue;
}
dto.setCategoryId(categoryId);;
materialApiService.editCategory(dto);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
} }
...@@ -93,6 +93,8 @@ public enum HaoBanErrCode { ...@@ -93,6 +93,8 @@ public enum HaoBanErrCode {
ERR_10017(10017,"存在素材不能删除"), ERR_10017(10017,"存在素材不能删除"),
ERR_10018(10018,"素材不存在"),
ERR_100015(100015,"暂存部门不能删除"), ERR_100015(100015,"暂存部门不能删除"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment