Commit 1f76630d by qwmqiuwenmin

fix

parent 95194de3
...@@ -32,5 +32,11 @@ public interface DepartmentApiService { ...@@ -32,5 +32,11 @@ public interface DepartmentApiService {
* @return * @return
*/ */
HaobanResponse del(String departmentId); HaobanResponse del(String departmentId);
/**
* 根据关联id 获取部门
* @param departId
* @return
*/
DepartmentDTO selectByRelatedId(String departId);
} }
...@@ -22,4 +22,6 @@ public interface DepartmentMapper { ...@@ -22,4 +22,6 @@ public interface DepartmentMapper {
List<TabHaobanDepartment> listByParentId(@Param("parentId")String parentId); List<TabHaobanDepartment> listByParentId(@Param("parentId")String parentId);
int selectMaxSort(@Param("parentDepartmentId")String parentDepartmentId); int selectMaxSort(@Param("parentDepartmentId")String parentDepartmentId);
TabHaobanDepartment selectByRelatedId(@Param("relatedId")String relatedId);
} }
\ No newline at end of file
...@@ -17,4 +17,6 @@ public interface DepartmentService { ...@@ -17,4 +17,6 @@ public interface DepartmentService {
void del(String departmentId); void del(String departmentId);
TabHaobanDepartment selectByRelatedId(String relatedId);
} }
...@@ -101,4 +101,10 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -101,4 +101,10 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
return hr; return hr;
} }
@Override
public DepartmentDTO selectByRelatedId(String relatedId) {
TabHaobanDepartment tab = departmentService.selectByRelatedId(relatedId);
return EntityUtil.changeEntityByJSON(DepartmentDTO.class, tab);
}
} }
...@@ -69,4 +69,10 @@ public class DepartmentServiceImpl implements DepartmentService { ...@@ -69,4 +69,10 @@ public class DepartmentServiceImpl implements DepartmentService {
} }
@Override
public TabHaobanDepartment selectByRelatedId(String relatedId) {
return mapper.selectByRelatedId(relatedId);
}
} }
...@@ -199,4 +199,12 @@ ...@@ -199,4 +199,12 @@
where parent_department_id = #{parentDepartmentId,jdbcType=VARCHAR} where parent_department_id = #{parentDepartmentId,jdbcType=VARCHAR}
and status_flag = 1 and status_flag = 1
</select> </select>
<select id="selectByRelatedId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_department
where related_id = #{relatedId,jdbcType=VARCHAR}
and status_flag = 1
</select>
</mapper> </mapper>
\ No newline at end of file
package com.gic.haoban.manage.web.controller; package com.gic.haoban.manage.web.controller;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -8,19 +9,26 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -8,19 +9,26 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.DepartmentService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.Constant; import com.gic.haoban.base.api.common.Constant;
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.DepartmentDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService; import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.DepartmentAddQO; import com.gic.haoban.manage.web.qo.DepartmentAddQO;
import com.gic.haoban.manage.web.qo.DepartmentDelQO;
import com.gic.haoban.manage.web.qo.DepartmentEditQO; import com.gic.haoban.manage.web.qo.DepartmentEditQO;
@RestController @RestController
public class DepartmentContoller extends WebBaseController{ public class DepartmentContoller extends WebBaseController{
@Autowired @Autowired
private DepartmentApiService departmentApiService; private DepartmentApiService departmentApiService;
@Autowired
private DepartmentService departmentService;
@Autowired
private StoreService storeService;
@RequestMapping("department-list") @RequestMapping("department-list")
public HaobanResponse departmentList(String parentId) { public HaobanResponse departmentList(String parentId) {
...@@ -107,6 +115,7 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -107,6 +115,7 @@ public class DepartmentContoller extends WebBaseController{
department.setDepartmentName(departmentAddQO.getDepartmentName()); department.setDepartmentName(departmentAddQO.getDepartmentName());
department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId()); department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId());
department.setIsStore(0); department.setIsStore(0);
department.setIsStore(departmentAddQO.getStoreFlag());
department.setLevel(dto.getLevel() + 1); department.setLevel(dto.getLevel() + 1);
HaobanResponse hr = departmentApiService.add(department); HaobanResponse hr = departmentApiService.add(department);
if(hr.getErrorCode() != 1) { if(hr.getErrorCode() != 1) {
...@@ -151,6 +160,40 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -151,6 +160,40 @@ public class DepartmentContoller extends WebBaseController{
} }
@RequestMapping("unbind-department-list")
public HaobanResponse unbindDepartmentList(String departmentId,String enterpriseId) {
List<String> list = new ArrayList<String>();
list.add(departmentId);
List<com.gic.enterprise.api.dto.DepartmentDTO> departmentList = departmentService.getDeptmentByPids(list);
List<StoreDTO> storeList = storeService.listStoreByStoreGroupId(departmentId);
List<DepartmentDTO> dtoList = new ArrayList<DepartmentDTO>();
for (com.gic.enterprise.api.dto.DepartmentDTO departmentDTO : departmentList) {
DepartmentDTO dto = departmentApiService.selectByRelatedId(departmentDTO.getDepartId());
if(dto == null) {
DepartmentDTO unBindDTO = new DepartmentDTO();
unBindDTO.setRelatedId(departmentDTO.getDepartId());
unBindDTO.setIsStore(0);
unBindDTO.setDepartmentName(departmentDTO.getDepartName());
dtoList.add(unBindDTO);
}
}
for (StoreDTO storeDTO : storeList) {
DepartmentDTO dto = departmentApiService.selectByRelatedId(storeDTO.getStoreId());
if(dto == null) {
DepartmentDTO unBindDTO = new DepartmentDTO();
unBindDTO.setRelatedId(storeDTO.getStoreId());
unBindDTO.setIsStore(0);
unBindDTO.setDepartmentName(storeDTO.getStoreName());
dtoList.add(unBindDTO);
}
}
return resultResponse(HaoBanErrCode.ERR_1,dtoList);
}
private void handler(String sonDepartment, String parentId) { private void handler(String sonDepartment, String parentId) {
if(StringUtils.isNotBlank(sonDepartment)) { if(StringUtils.isNotBlank(sonDepartment)) {
List<DepartmentAddQO> list = JSONArray.parseArray(sonDepartment, DepartmentAddQO.class); List<DepartmentAddQO> list = JSONArray.parseArray(sonDepartment, DepartmentAddQO.class);
...@@ -172,7 +215,9 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -172,7 +215,9 @@ public class DepartmentContoller extends WebBaseController{
department.setDepartmentName(departmentAddQO.getDepartmentName()); department.setDepartmentName(departmentAddQO.getDepartmentName());
department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId()); department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId());
department.setIsStore(0); department.setIsStore(0);
department.setIsStore(departmentAddQO.getStoreFlag());
department.setLevel(dto.getLevel() + 1); department.setLevel(dto.getLevel() + 1);
department.setRelatedId(departmentAddQO.getRelatedId());
HaobanResponse hr = departmentApiService.add(department); HaobanResponse hr = departmentApiService.add(department);
if(hr.getErrorCode() != 1) { if(hr.getErrorCode() != 1) {
continue; continue;
......
...@@ -12,6 +12,10 @@ public class DepartmentAddQO implements Serializable { ...@@ -12,6 +12,10 @@ public class DepartmentAddQO implements Serializable {
private String sonDepartment; private String sonDepartment;
private Integer storeFlag;
private String relatedId;
public String getDepartmentName() { public String getDepartmentName() {
return departmentName; return departmentName;
} }
...@@ -44,6 +48,22 @@ public class DepartmentAddQO implements Serializable { ...@@ -44,6 +48,22 @@ public class DepartmentAddQO implements Serializable {
this.departmentId = departmentId; this.departmentId = departmentId;
} }
public Integer getStoreFlag() {
return storeFlag;
}
public void setStoreFlag(Integer storeFlag) {
this.storeFlag = storeFlag;
}
public String getRelatedId() {
return relatedId;
}
public void setRelatedId(String relatedId) {
this.relatedId = relatedId;
}
} }
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