Commit 1f181461 by fudahua

接口初始化

parent e84e40b6
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
public class StaffClerkInfoDTO implements Serializable{
private String staffClerkRelationId;
private String staffId;
private String wxEnterpriseId;
private String wxUserId;
private String enterpriseId;
private String enterpriseName;
private String storeId;
private String storeName;
private String clerkId;
private String clerkName;
private String clerkCode;
private Integer statusFlag;
private Date createTime;
private Date updateTime;
private String clerkPhoneNumber;
private static final long serialVersionUID = 1L;
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getClerkName() {
return clerkName;
}
public void setClerkName(String clerkName) {
this.clerkName = clerkName;
}
public String getClerkPhoneNumber() {
return clerkPhoneNumber;
}
public void setClerkPhoneNumber(String clerkPhoneNumber) {
this.clerkPhoneNumber = clerkPhoneNumber;
}
public String getStaffClerkRelationId() {
return staffClerkRelationId;
}
public void setStaffClerkRelationId(String staffClerkRelationId) {
this.staffClerkRelationId = staffClerkRelationId == null ? null : staffClerkRelationId.trim();
}
public String getStaffId() {
return staffId;
}
public void setStaffId(String staffId) {
this.staffId = staffId == null ? null : staffId.trim();
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId == null ? null : wxEnterpriseId.trim();
}
public String getWxUserId() {
return wxUserId;
}
public void setWxUserId(String wxUserId) {
this.wxUserId = wxUserId == null ? null : wxUserId.trim();
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId == null ? null : enterpriseId.trim();
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId == null ? null : storeId.trim();
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId == null ? null : clerkId.trim();
}
public String getClerkCode() {
return clerkCode;
}
public void setClerkCode(String clerkCode) {
this.clerkCode = clerkCode == null ? null : clerkCode.trim();
}
public Integer getStatusFlag() {
return statusFlag;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
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;
}
}
......@@ -3,6 +3,8 @@ package com.gic.haoban.manage.api.service;
import java.util.List;
import java.util.Set;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.StaffClerkInfoDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
public interface StaffClerkRelationApiService {
......@@ -11,4 +13,17 @@ public interface StaffClerkRelationApiService {
List<StaffClerkRelationDTO> listBindCodeByStaffId(List<String> enterpriseIdList, String staffId);
/**
* 根据staffid 获取列表
* @param staffId
* @return
*/
List<StaffClerkInfoDTO> listBindDetailByStaffId(String staffId);
/**
* 绑定
* @return
*/
public ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO);
}
......@@ -23,4 +23,28 @@ public interface TabHaobanStaffClerkRelationMapper {
List<TabHaobanStaffClerkRelation> listBindCode(@Param("enterpriseId")String enterpriseId, @Param("clerkCodeList")Set<String> clerkCodeList);
List<TabHaobanStaffClerkRelation> listBindCodeByStaffId(@Param("enterpriseIdList")List<String> enterpriseIdList, @Param("staffId")String staffId);
/**
* 改变状态 格局clerkId
* @param clerkId
* @param status
* @return
*/
public int changeStatusByClerkId(@Param("clerkId") String clerkId,@Param("status") Integer status);
/**
* 更新信息
* @param record
* @return
*/
int updateByClerkId(TabHaobanStaffClerkRelation record);
/**
* 格局clerkId 查询staffClerkRelation
*
* @param clerkId
* @param wxEnterpriseId
* @return
*/
TabHaobanStaffClerkRelation getBindByClerkId(@Param("clerkId") String clerkId,@Param("wxEnterpriseId") String wxEnterpriseId);
}
\ No newline at end of file
......@@ -32,4 +32,12 @@ public interface StaffClerkRelationService {
*/
public boolean updateByClerkId(StaffClerkRelationDTO dto);
/**
* 查询绑定根据clerkId
* @param clerkId
* @param wxEnterpriseId
* @return
*/
public StaffClerkRelationDTO getBindByClerkId(String clerkId,String wxEnterpriseId);
}
package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Set;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.ToolUtil;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import javafx.scene.control.Tab;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -14,6 +22,8 @@ import com.gic.haoban.manage.service.service.StaffClerkRelationService;
@Service
public class StaffClerkRelationServiceImpl implements StaffClerkRelationService {
private static final Logger logger= LoggerFactory.getLogger(StaffClerkRelationServiceImpl.class);
@Autowired
private TabHaobanStaffClerkRelationMapper mapper;
@Override
......@@ -27,16 +37,34 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
@Override
public boolean delBind(String clerkId) {
return false;
int i = mapper.changeStatusByClerkId(clerkId, 0);
return i>=0;
}
@Override
public boolean bind(StaffClerkRelationDTO dto) {
return false;
dto.setStaffClerkRelationId(ToolUtil.randomUUID());
dto.setStatusFlag(1);
dto.setCreateTime(new Date());
dto.setUpdateTime(new Date());
int insert = mapper.insert(EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, dto));
return insert>0;
}
@Override
public boolean updateByClerkId(StaffClerkRelationDTO dto) {
return false;
if (StringUtils.isAnyBlank(dto.getClerkCode(),dto.getClerkId(),dto.getStoreId())) {
logger.info("操作不对:{}", JSONObject.toJSONString(dto));
return false;
}
int i = mapper.updateByClerkId(EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, dto));
return i>=0;
}
@Override
public StaffClerkRelationDTO getBindByClerkId(String clerkId, String wxEnterpriseId) {
TabHaobanStaffClerkRelation relation = mapper.getBindByClerkId(clerkId, wxEnterpriseId);
return EntityUtil.changeEntityByJSON(StaffClerkRelationDTO.class,relation);
}
}
package com.gic.haoban.manage.service.service.out.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.StaffClerkInfoDTO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,6 +27,16 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
@Autowired
private StaffClerkRelationService staffClerkRelatinService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private ClerkService clerkService;
@Autowired
private StoreService storeService;
@Override
public List<StaffClerkRelationDTO> listBindCode(String enterpriseId, Set<String> clerkCodeList) {
return staffClerkRelatinService.listBindCode(enterpriseId,clerkCodeList);
......@@ -24,4 +46,62 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
return staffClerkRelatinService.listBindCodeByStaffId(enterpriseIdList,staffId);
}
@Override
public List<StaffClerkInfoDTO> listBindDetailByStaffId(String staffId) {
List<StaffClerkRelationDTO> list = staffClerkRelatinService.listBindCodeByStaffId(null, staffId);
if (CollectionUtils.isEmpty(list)) {
return null;
}
List<StaffClerkInfoDTO> infoDTOS = EntityUtil.changeEntityListByJSON(StaffClerkInfoDTO.class, list);
Map<String,String> nameMap=new HashMap<>();
infoDTOS.forEach(infoDTO->{
//企业
if (!nameMap.containsKey(infoDTO.getEnterpriseId())) {
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(infoDTO.getEnterpriseId());
if (null != enterpriseDTO) {
nameMap.put(infoDTO.getEnterpriseId(),enterpriseDTO.getEnterpriseName());
}else{
nameMap.put(infoDTO.getEnterpriseId(),"未知商户");
}
}
//门店店员名称
if (!nameMap.containsKey(infoDTO.getClerkId())) {
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(infoDTO.getClerkId());
if (null != clerkDTO) {
nameMap.put(infoDTO.getClerkId(),clerkDTO.getClerkName());
nameMap.put(infoDTO.getStoreId(),clerkDTO.getStoreName());
}else{
nameMap.put(infoDTO.getEnterpriseId(),"未知店员");
}
}
//门店店员名称
if (!nameMap.containsKey(infoDTO.getStoreId())) {
StoreDTO storeDTO = storeService.getStore(infoDTO.getStoreId());
if (null != storeDTO) {
nameMap.put(infoDTO.getStoreId(),storeDTO.getStoreName());
}else{
nameMap.put(infoDTO.getStoreId(),"未知门店");
}
}
infoDTO.setClerkName(nameMap.get(infoDTO.getClerkId()));
infoDTO.setStoreName(nameMap.get(infoDTO.getStoreId()));
infoDTO.setEnterpriseName(nameMap.get(infoDTO.getEnterpriseId()));
});
return infoDTOS;
}
@Override
public ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO) {
ServiceResponse<Object> response = new ServiceResponse<>();
StaffClerkRelationDTO relationDTO = staffClerkRelatinService.getBindByClerkId(staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getWxEnterpriseId());
if (null!=relationDTO) {
response.setCode(2);
response.setMessage("已经被绑定,不能绑定");
return response;
}
staffClerkRelatinService.bind(staffClerkRelationDTO);
return response;
}
}
......@@ -8,10 +8,12 @@ import com.gic.commons.util.BeanUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.service.pojo.BinlogBasePojo;
import com.gic.haoban.manage.service.pojo.ClerkSyncPojo;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.listener.MessageListener;
import java.util.ArrayList;
......@@ -32,6 +34,8 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
private final String CLERK = "tab_gic_clerk";
@Autowired
private StaffClerkRelationService staffClerkRelationService;
@Override
......@@ -44,7 +48,18 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
BinlogBasePojo pojo = binlogChange(record.value());
logger.info("binlog数据:{}", JSONObject.toJSONString(pojo));
if (record.value().getTableName().equals(CLERK)) {
dealClerk((ClerkSyncPojo)pojo);
}
}
private void dealClerk(ClerkSyncPojo syncPojo) {
GicRecordType gicRecordType = GicRecordType.valueOf(syncPojo.getRecordType());
if(gicRecordType.equals(GicRecordType.DELETE)){
staffClerkRelationService.delBind(syncPojo.getClerkId());
}else if (gicRecordType.equals(GicRecordType.INSERT)) {
}
}
private BinlogBasePojo binlogChange(GicRecord record) {
......
......@@ -179,9 +179,36 @@
from tab_haoban_staff_clerk_relation
where staff_id = #{staffId,jdbcType=VARCHAR}
and status_flag = 1
<if test="enterpriseIdList!=null && enterpriseIdList.size>0">
and enterprise_id in
<foreach collection="enterpriseIdList" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
</select>
<update id="changeStatusByClerkId" >
update tab_haoban_staff_clerk_relation
set
status_flag = #{status},
update_time = now()
where clerk_id = #{clerkId,jdbcType=VARCHAR} and status!=#{status}
</update>
<update id="updateByClerkId" parameterType="com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation" >
update tab_haoban_staff_clerk_relation
set
store_id = #{storeId,jdbcType=VARCHAR},
clerk_code = #{clerkCode,jdbcType=VARCHAR},
update_time = now()
where clerk_id = #{clerkId,jdbcType=VARCHAR}
</update>
<select id="getBindByClerkId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_staff_clerk_relation
where clerk_id = #{clerkId,jdbcType=VARCHAR} and wx_enterprise_id=#{wxEnterpriseId} and status=1
</select>
</mapper>
\ No newline at end of file
......@@ -5,6 +5,10 @@ import java.util.List;
import javax.servlet.http.Cookie;
import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -25,16 +29,6 @@ import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.PageResult;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.StaffEditJsonQO;
......@@ -63,6 +57,12 @@ public class StaffController extends WebBaseController{
private ClerkService clerkService;
@Autowired
private StoreService storeService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@RequestMapping("staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO,String departmentIds){
......@@ -266,5 +266,84 @@ public class StaffController extends WebBaseController{
}
return resultResponse(HaoBanErrCode.ERR_1,staffVO);
}
/**
* 成员关联关系接口
* @param staffId
* @return
*/
@RequestMapping("staff-clerk-relation")
public HaobanResponse staffClerkList(String staffId){
StaffDTO staff = staffApiService.selectById(staffId);
if(staff == null) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
List<StaffClerkInfoDTO> retList = staffClerkRelationApiService.listBindDetailByStaffId(staffId);
return resultResponse(HaoBanErrCode.ERR_1,retList);
}
/**
* 成员关联关系搜索接口
* @param search
* @return
*/
@RequestMapping("search-clerk-relation")
public HaobanResponse staffClerkSearch(String search){
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
if (null == wxEnterpriseId) {
return resultResponse(HaoBanErrCode.ERR_4);
}
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtil.isEmpty(list)) {
return resultResponse(HaoBanErrCode.ERR_10010);
}
List<String> phoneList = clerkService.queryClerkEnterpriseByPhoneNumber(search);
if (CollectionUtils.isNotEmpty(phoneList)) {
// clerkService.
}
return resultResponse(HaoBanErrCode.ERR_1);
//todo 还没好
}
/**
* 新建关联
* @param staffId
* @return
*/
@RequestMapping("add-clerk-relation")
public HaobanResponse staffClerkSearch(String staffId,String clerkId){
if (StringUtils.isAnyBlank(staffId,clerkId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
StaffDTO staffDTO = staffApiService.selectById(staffId);
if (null == staffDTO) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
if (null == clerkDTO) {
return resultResponse(HaoBanErrCode.ERR_5);
}
StaffClerkRelationDTO relationDTO = new StaffClerkRelationDTO();
relationDTO.setClerkCode(clerkDTO.getClerkCode());
relationDTO.setClerkId(clerkId);
relationDTO.setStaffId(staffId);
relationDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
relationDTO.setStoreId(clerkDTO.getStoreId());
relationDTO.setWxEnterpriseId(staffDTO.getWxEnterpriseId());
relationDTO.setWxUserId(staffDTO.getWxUserId());
ServiceResponse response = staffClerkRelationApiService.bindStaffClerk(relationDTO);
logger.info("返回信息:{}", JSONObject.toJSONString(response));
if (response.getCode()==1) {
return resultResponse(HaoBanErrCode.ERR_1);
}else{
HaoBanErrCode errDefine = HaoBanErrCode.ERR_DEFINE;
errDefine.setMsg(response.getMessage());
return resultResponse(errDefine);
}
}
}
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