@@ -0,0 +1,72 @@ | |||
package com.hp.user.client.entity; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* 电工证书关联表 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-02 | |||
*/ | |||
public class CertificateVO implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 证书id | |||
*/ | |||
private String certificateId; | |||
/** | |||
* 证书oss | |||
*/ | |||
private String certificateUrl; | |||
/** | |||
* 电工id | |||
*/ | |||
private String electricianId; | |||
/** | |||
* 字典表id | |||
*/ | |||
private String dictionariesId; | |||
public String getCertificateId() { | |||
return certificateId; | |||
} | |||
public void setCertificateId(String certificateId) { | |||
this.certificateId = certificateId; | |||
} | |||
public String getCertificateUrl() { | |||
return certificateUrl; | |||
} | |||
public void setCertificateUrl(String certificateUrl) { | |||
this.certificateUrl = certificateUrl; | |||
} | |||
public String getElectricianId() { | |||
return electricianId; | |||
} | |||
public void setElectricianId(String electricianId) { | |||
this.electricianId = electricianId; | |||
} | |||
public String getDictionariesId() { | |||
return dictionariesId; | |||
} | |||
public void setDictionariesId(String dictionariesId) { | |||
this.dictionariesId = dictionariesId; | |||
} | |||
} |
@@ -0,0 +1,189 @@ | |||
package com.hp.user.client.entity; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* 电工表 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-02 | |||
*/ | |||
public class ElectricianVO implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 电工id | |||
*/ | |||
private String electricianId; | |||
/** | |||
* 关联用户id | |||
*/ | |||
private String userId; | |||
/** | |||
* 服务商id | |||
*/ | |||
private String serviceProviderId; | |||
/** | |||
* 电工姓名 | |||
*/ | |||
private String name; | |||
/** | |||
* 手机号 | |||
*/ | |||
private String phone; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remarks; | |||
/** | |||
* 证书列表 | |||
*/ | |||
private List<CertificateVO> certificateList; | |||
/** | |||
* 电工状态;0:离岗;1:在岗 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private LocalDateTime sysCreateTime; | |||
/** | |||
* 创建者 | |||
*/ | |||
private Long sysCreator; | |||
/** | |||
* 修改时间 | |||
*/ | |||
private LocalDateTime sysUpdateTime; | |||
/** | |||
* 修改者 | |||
*/ | |||
private Long sysUpdater; | |||
/** | |||
* 是否删除,0(default)/1:未删除/删除 | |||
*/ | |||
private Boolean sysDeleted; | |||
public String getElectricianId() { | |||
return electricianId; | |||
} | |||
public void setElectricianId(String electricianId) { | |||
this.electricianId = electricianId; | |||
} | |||
public String getUserId() { | |||
return userId; | |||
} | |||
public void setUserId(String userId) { | |||
this.userId = userId; | |||
} | |||
public String getServiceProviderId() { | |||
return serviceProviderId; | |||
} | |||
public void setServiceProviderId(String serviceProviderId) { | |||
this.serviceProviderId = serviceProviderId; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public String getRemarks() { | |||
return remarks; | |||
} | |||
public void setRemarks(String remarks) { | |||
this.remarks = remarks; | |||
} | |||
public List<CertificateVO> getCertificateList() { | |||
return certificateList; | |||
} | |||
public void setCertificateList(List<CertificateVO> certificateList) { | |||
this.certificateList = certificateList; | |||
} | |||
public Integer getStatus() { | |||
return status; | |||
} | |||
public void setStatus(Integer status) { | |||
this.status = status; | |||
} | |||
public LocalDateTime getSysCreateTime() { | |||
return sysCreateTime; | |||
} | |||
public void setSysCreateTime(LocalDateTime sysCreateTime) { | |||
this.sysCreateTime = sysCreateTime; | |||
} | |||
public Long getSysCreator() { | |||
return sysCreator; | |||
} | |||
public void setSysCreator(Long sysCreator) { | |||
this.sysCreator = sysCreator; | |||
} | |||
public LocalDateTime getSysUpdateTime() { | |||
return sysUpdateTime; | |||
} | |||
public void setSysUpdateTime(LocalDateTime sysUpdateTime) { | |||
this.sysUpdateTime = sysUpdateTime; | |||
} | |||
public Long getSysUpdater() { | |||
return sysUpdater; | |||
} | |||
public void setSysUpdater(Long sysUpdater) { | |||
this.sysUpdater = sysUpdater; | |||
} | |||
public Boolean getSysDeleted() { | |||
return sysDeleted; | |||
} | |||
public void setSysDeleted(Boolean sysDeleted) { | |||
this.sysDeleted = sysDeleted; | |||
} | |||
public String getPhone() { | |||
return phone; | |||
} | |||
public void setPhone(String phone) { | |||
this.phone = phone; | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.ElectricianVO; | |||
import com.hp.user.client.entity.Result; | |||
public interface ElectricianService { | |||
/** | |||
* 创建电工 | |||
* @param electricianVO 电工信息 | |||
* @return | |||
*/ | |||
public Result createElectrician(ElectricianVO electricianVO); | |||
} |
@@ -2,6 +2,7 @@ package com.hp.user.service.controller; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
@@ -46,7 +47,7 @@ public class AuthenticationController { | |||
*/ | |||
@RequestMapping("/register") | |||
@ApiOperation(value = "注册", notes = "注册", httpMethod = "POST") | |||
public void register(AccountVO account) { | |||
public void register(@RequestBody AccountVO account) { | |||
accountService.register(account); | |||
} | |||
@@ -63,7 +64,7 @@ public class AuthenticationController { | |||
@RequestMapping("/wxAuthorization") | |||
@ApiOperation(value = "微信认证登陆", notes = "微信认证登陆", httpMethod = "POST") | |||
public DataResult<AccountVO> wxAuthorization(AccountVO account,String code) { | |||
public DataResult<AccountVO> wxAuthorization(@RequestBody AccountVO account,String code) { | |||
DataResult<AccountVO> result = accountService.wxAuthorization(account,code); | |||
return result; | |||
} | |||
@@ -75,7 +76,7 @@ public class AuthenticationController { | |||
*/ | |||
@RequestMapping("/wxRegister") | |||
@ApiOperation(value = "通过微信注册", notes = "通过微信注册", httpMethod = "POST") | |||
public DataResult<AccountVO> wxRegister(AccountVO account,String verificationCode) { | |||
public DataResult<AccountVO> wxRegister(@RequestBody AccountVO account,String verificationCode) { | |||
DataResult<AccountVO> result = accountService.wxRegister(account, verificationCode); | |||
return result; | |||
} | |||
@@ -1,8 +1,6 @@ | |||
package com.hp.user.service.controller; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
@@ -25,7 +23,7 @@ public class DictionariesController { | |||
* 根据字典类型查询字典 | |||
*/ | |||
@RequestMapping("/queryByType") | |||
@ApiOperation(value = "根据字典类型查询字典", notes = "根据字典类型查询字典", httpMethod = "GET") | |||
@ApiOperation(value = "根据字典类型查询字典", notes = "根据字典类型查询字典", httpMethod = "POST") | |||
public ListResult<DictionariesVO> queryByType(Integer type) { | |||
ListResult<DictionariesVO> result = dictionariesService.queryByType(type); | |||
return result; | |||
@@ -0,0 +1,34 @@ | |||
package com.hp.user.service.controller; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import com.hp.user.client.entity.ElectricianVO; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.ElectricianService; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
@Api(tags="电工") | |||
@RestController | |||
@RequestMapping("/electrician") | |||
public class ElectricianController { | |||
@Autowired | |||
private ElectricianService electricianService; | |||
/** | |||
* 添加电工 | |||
* @param electrician | |||
* @return | |||
*/ | |||
@RequestMapping("/createElectrician") | |||
@ApiOperation(value = "添加电工", notes = "添加电工", httpMethod = "POST") | |||
public Result createElectrician(@RequestBody ElectricianVO electrician) { | |||
return electricianService.createElectrician(electrician); | |||
} | |||
} |
@@ -5,16 +5,16 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import com.hp.user.client.service.MessageService; | |||
import com.hp.user.service.utils.SendSmsUtil; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
/** | |||
* 短信 | |||
* @author yeqid | |||
* | |||
*/ | |||
@Api(value="短信") | |||
@Api(tags="短信") | |||
@RestController | |||
@RequestMapping("/area") | |||
public class MessageController { | |||
@@ -28,6 +28,7 @@ public class MessageController { | |||
* @param phoneNumber | |||
*/ | |||
@RequestMapping("/sendVerificationCode") | |||
@ApiOperation(value = "发送验证码", notes = "发送验证码", httpMethod = "POST") | |||
public void sendVerificationCode(String phoneNumber) { | |||
messageService.sendVerificationCode(phoneNumber); | |||
} | |||
@@ -0,0 +1,24 @@ | |||
package com.hp.user.service.dao; | |||
import com.hp.user.service.entity.Certificate; | |||
import java.util.List; | |||
import org.apache.ibatis.annotations.Param; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import org.apache.ibatis.annotations.Param; | |||
/** | |||
* <p> | |||
* 电工证书关联表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-02 | |||
*/ | |||
public interface CertificateMapper extends BaseMapper<Certificate> { | |||
public void batchInsertCertificate(@Param("certificateList")List<Certificate> certificateList); | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.hp.user.service.dao; | |||
import com.hp.user.service.entity.Electrician; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
/** | |||
* <p> | |||
* 电工表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-02 | |||
*/ | |||
public interface ElectricianMapper extends BaseMapper<Electrician> { | |||
} |
@@ -0,0 +1,46 @@ | |||
package com.hp.user.service.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.io.Serializable; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* <p> | |||
* 电工证书关联表 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-02 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("r_certificate") | |||
public class Certificate implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 证书id | |||
*/ | |||
private String certificateId; | |||
/** | |||
* 证书oss | |||
*/ | |||
private String certificateUrl; | |||
/** | |||
* 电工id | |||
*/ | |||
private String electricianId; | |||
/** | |||
* 字典表id | |||
*/ | |||
private String dictionariesId; | |||
} |
@@ -0,0 +1,86 @@ | |||
package com.hp.user.service.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.time.LocalDateTime; | |||
import java.io.Serializable; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* <p> | |||
* 电工表 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-02 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("tb_electrician") | |||
public class Electrician implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 电工id | |||
*/ | |||
private String electricianId; | |||
/** | |||
* 关联用户id | |||
*/ | |||
private String userId; | |||
/** | |||
* 服务商id | |||
*/ | |||
private String serviceProviderId; | |||
/** | |||
* 电工姓名 | |||
*/ | |||
private String name; | |||
/** | |||
* 手机号 | |||
*/ | |||
private String phone; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remarks; | |||
/** | |||
* 电工状态;0:离岗;1:在岗 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private LocalDateTime sysCreateTime; | |||
/** | |||
* 创建者 | |||
*/ | |||
private Long sysCreator; | |||
/** | |||
* 修改时间 | |||
*/ | |||
private LocalDateTime sysUpdateTime; | |||
/** | |||
* 修改者 | |||
*/ | |||
private Long sysUpdater; | |||
/** | |||
* 是否删除,0(default)/1:未删除/删除 | |||
*/ | |||
private Boolean sysDeleted; | |||
} |
@@ -0,0 +1,77 @@ | |||
package com.hp.user.service.impl; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import com.alibaba.nacos.client.naming.utils.CollectionUtils; | |||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; | |||
import com.hp.user.client.entity.CertificateVO; | |||
import com.hp.user.client.entity.ElectricianVO; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.ElectricianService; | |||
import com.hp.user.service.dao.CertificateMapper; | |||
import com.hp.user.service.dao.ElectricianMapper; | |||
import com.hp.user.service.entity.Certificate; | |||
import com.hp.user.service.entity.Electrician; | |||
@Service | |||
public class ElectricianServiceImpl implements ElectricianService{ | |||
@Autowired | |||
private ElectricianMapper electricianMapper; | |||
@Autowired | |||
private CertificateMapper certificateMapper; | |||
@Override | |||
@Transactional | |||
public Result createElectrician(ElectricianVO electricianVO) { | |||
Result result = new Result(); | |||
try { | |||
String phone = electricianVO.getPhone(); | |||
String name = electricianVO.getName(); | |||
if(StringUtils.isBlank(phone)) { | |||
result.setCode("-1"); | |||
result.setMessage("手机号不能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(name)) { | |||
result.setCode("-1"); | |||
result.setMessage("姓名能为空!"); | |||
return result; | |||
} | |||
Electrician electrician = new Electrician(); | |||
BeanUtils.copyProperties(electricianVO, electrician); | |||
String electricianId = IdWorker.getIdStr(); | |||
electrician.setElectricianId(electricianId); | |||
electricianMapper.insert(electrician); | |||
List<CertificateVO> list = electricianVO.getCertificateList(); | |||
if(!CollectionUtils.isEmpty(list)) { | |||
Certificate certificate; | |||
List<Certificate> newList = new ArrayList<>(); | |||
for(CertificateVO certificateVO : list) { | |||
certificate = new Certificate(); | |||
BeanUtils.copyProperties(certificateVO, certificate); | |||
certificate.setCertificateId(IdWorker.getIdStr()); | |||
certificate.setElectricianId(electricianId); | |||
newList.add(certificate); | |||
} | |||
certificateMapper.batchInsertCertificate(newList); | |||
} | |||
}catch(Exception e) { | |||
result.setCode("-1"); | |||
result.setMessage("系统内部错误"); | |||
throw e; | |||
} | |||
// TODO Auto-generated method stub | |||
return result; | |||
} | |||
} |