|
|
@ -1,13 +1,16 @@ |
|
|
|
package com.ccsens.mt.service; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.ccsens.mt.bean.dto.CompeteDto; |
|
|
|
import com.ccsens.mt.bean.po.CompeteCoach; |
|
|
|
import com.ccsens.mt.bean.po.CompeteCompany; |
|
|
|
import com.ccsens.mt.bean.po.CompeteCompanyExample; |
|
|
|
import com.ccsens.mt.bean.vo.ProvinceCompeteVo; |
|
|
|
|
|
|
|
import com.ccsens.mt.persist.dao.CompeteCompanyDao; |
|
|
|
import com.ccsens.mt.persist.mapper.CompeteCoachMapper; |
|
|
|
import com.ccsens.mt.persist.mapper.CompeteCompanyMapper; |
|
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
@ -31,8 +34,7 @@ public class ProvinceService implements IProvinceService{ |
|
|
|
@Resource |
|
|
|
private Snowflake snowflake; |
|
|
|
@Resource |
|
|
|
CompeteCompanyMapper competeCompanyMapper; |
|
|
|
|
|
|
|
private CompeteCoachMapper competeCoachMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public ProvinceCompeteVo.CompeteOverview getOverview(CompeteDto.CompeteTime param, Long userId) { |
|
|
@ -51,7 +53,7 @@ public class ProvinceService implements IProvinceService{ |
|
|
|
//判断当前单位id是否为空,
|
|
|
|
Long companyid = param.getCompanyId(); |
|
|
|
CompeteCompany competeCompany = new CompeteCompany(); |
|
|
|
ProvinceCompeteVo.CompeteCompany competeCompany1 =null; |
|
|
|
ProvinceCompeteVo.CompeteCompany competeCompany1 =new ProvinceCompeteVo.CompeteCompany(); |
|
|
|
//单位id为空,新增
|
|
|
|
if (ObjectUtil.isNull(companyid)){ |
|
|
|
Long id = snowflake.nextId(); |
|
|
@ -62,15 +64,16 @@ public class ProvinceService implements IProvinceService{ |
|
|
|
competeCompany.setContactsPhone(param.getContactsPhone()); |
|
|
|
competeCompany.setLeaderNum(param.getGuideNum()); |
|
|
|
competeCompany.setJoinNum(param.getPlayerNum()); |
|
|
|
competeCompanyMapper.insertSelective(competeCompany); |
|
|
|
CompeteCompanyExample competeCompanyExample = new CompeteCompanyExample(); |
|
|
|
competeCompanyExample.createCriteria().andIdEqualTo(companyid); |
|
|
|
competeCompany1 = (ProvinceCompeteVo.CompeteCompany) competeCompanyMapper.selectByExample(competeCompanyExample); |
|
|
|
competeCompanyDao.insertSelective(competeCompany); |
|
|
|
competeCompany1.setCompanyName(competeCompany.getName()); |
|
|
|
competeCompany1.setPlayerNum(competeCompany.getJoinNum()); |
|
|
|
competeCompany1.setGuideNum(competeCompany.getLeaderNum()); |
|
|
|
competeCompany1.setContactsPhone(competeCompany.getContactsPhone()); |
|
|
|
competeCompany1.setContactsName(competeCompany.getContactsName()); |
|
|
|
competeCompany1.setCoachNum(competeCompany.getCoachNum()); |
|
|
|
}else { |
|
|
|
//不为空,根据单位id查出来修改 判断传进来的参数是否为空 为空则跳过 不为空则修改
|
|
|
|
CompeteCompanyExample competeCompanyExample = new CompeteCompanyExample(); |
|
|
|
competeCompanyExample.createCriteria().andIdEqualTo(companyid); |
|
|
|
competeCompany = (CompeteCompany) competeCompanyMapper.selectByExample(competeCompanyExample); |
|
|
|
competeCompany = competeCompanyDao.selectByPrimaryKey(companyid); |
|
|
|
if (ObjectUtil.isNotNull(param.getCoachNum())){ |
|
|
|
competeCompany.setCoachNum(param.getCoachNum()); |
|
|
|
} |
|
|
@ -89,14 +92,70 @@ public class ProvinceService implements IProvinceService{ |
|
|
|
if (ObjectUtil.isNotNull(param.getPlayerNum())) { |
|
|
|
competeCompany.setJoinNum(param.getPlayerNum()); |
|
|
|
} |
|
|
|
competeCompanyMapper.updateByPrimaryKeySelective(competeCompany); |
|
|
|
competeCompanyExample.createCriteria().andIdEqualTo(competeCompany.getId()); |
|
|
|
competeCompany1 = (ProvinceCompeteVo.CompeteCompany) competeCompanyMapper.selectByExample(competeCompanyExample); |
|
|
|
competeCompanyDao.updateByPrimaryKey(competeCompany); |
|
|
|
competeCompany1.setCompanyName(competeCompany.getName()); |
|
|
|
competeCompany1.setPlayerNum(competeCompany.getJoinNum()); |
|
|
|
competeCompany1.setGuideNum(competeCompany.getLeaderNum()); |
|
|
|
competeCompany1.setContactsPhone(competeCompany.getContactsPhone()); |
|
|
|
competeCompany1.setContactsName(competeCompany.getContactsName()); |
|
|
|
competeCompany1.setCoachNum(competeCompany.getCoachNum()); |
|
|
|
} |
|
|
|
return competeCompany1; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ProvinceCompeteVo.CompeteCompanyCoach queryCoach(CompeteDto.CompeteCompany param) { |
|
|
|
Long company = param.getCompanyId(); |
|
|
|
CompeteCoach competeCoach = competeCoachMapper.selectByPrimaryKey(company); |
|
|
|
if (ObjectUtil.isNull(competeCoach)){ |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
ProvinceCompeteVo.CompeteCompanyCoach competeCompanyCoach = new ProvinceCompeteVo.CompeteCompanyCoach(); |
|
|
|
if (competeCoach.getIdentity() == 0){ |
|
|
|
//给领队赋值
|
|
|
|
competeCompanyCoach.setCoachName(competeCoach.getName()); |
|
|
|
competeCompanyCoach.setCoachId(competeCoach.getId()); |
|
|
|
competeCompanyCoach.setGender(competeCoach.getGender()); |
|
|
|
competeCompanyCoach.setPhone(competeCoach.getPhone()); |
|
|
|
}else { |
|
|
|
competeCompanyCoach.setGuideName(competeCoach.getName()); |
|
|
|
competeCompanyCoach.setCoachId(competeCoach.getId()); |
|
|
|
competeCompanyCoach.setGender(competeCoach.getGender()); |
|
|
|
competeCompanyCoach.setPhone(competeCoach.getPhone()); |
|
|
|
} |
|
|
|
return competeCompanyCoach; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveCoach(CompeteDto.AddCoach param) { |
|
|
|
CompeteCoach competeCoach = new CompeteCoach(); |
|
|
|
Long companyId = param.getCompanyId(); |
|
|
|
competeCoach.setCompanyId(companyId); |
|
|
|
Long cpachId = param.getCpachId(); |
|
|
|
competeCoach.setId(cpachId); |
|
|
|
int identity = param.getIdentity(); |
|
|
|
competeCoach.setIdentity((byte) identity); |
|
|
|
String name = param.getName(); |
|
|
|
competeCoach.setName(name); |
|
|
|
int gender = param.getGender(); |
|
|
|
competeCoach.setGender((byte) gender); |
|
|
|
String phone = param.getPhone(); |
|
|
|
competeCoach.setPhone(phone); |
|
|
|
String idCard = param.getIdCard(); |
|
|
|
competeCoach.setIdCard(idCard); |
|
|
|
Long idPhoto = param.getIdPhoto(); |
|
|
|
competeCoach.setIdPhoto(idPhoto); |
|
|
|
Long coachCertificate = param.getCoachCertificate(); |
|
|
|
competeCoach.setCoachCertificate(coachCertificate); |
|
|
|
competeCoachMapper.insertSelective(competeCoach); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void deleteCoach(CompeteDto.AddCoach param) { |
|
|
|
Long cpachId = param.getCpachId(); |
|
|
|
CompeteCoach competeCoach = competeCoachMapper.selectByPrimaryKey(cpachId); |
|
|
|
competeCoachMapper.deleteByPrimaryKey(competeCoach.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|