Browse Source

员工管理新增修改接口

weifanli 3 years ago
parent
commit
79982c9c7c

+ 20 - 20
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUser.java

@@ -25,22 +25,22 @@ public class SysUser implements Serializable{
 	private Long id;
 	
 	/** 用户名 */
-	@ApiModelProperty(value = "用户名",required = false)
+	@ApiModelProperty(value = "用户名")
 	private String username;
 
 	/**  */
-	@ApiModelProperty(value = "密码",required = false)
+	@ApiModelProperty(value = "密码")
 	private String password;
 
 	/** 随机盐 */
-	@ApiModelProperty(value = "随机盐",required = false)
+	@ApiModelProperty(value = "随机盐")
 	private String salt;
 
-	@ApiModelProperty(value = "手机号",required = false)
+	@ApiModelProperty(value = "手机号")
 	private String phone;
 
 	/** 头像 */
-	@ApiModelProperty(value = "头像",required = false)
+	@ApiModelProperty(value = "头像")
 	private String avatar;
 
 	/** 创建时间 */
@@ -50,54 +50,54 @@ public class SysUser implements Serializable{
 	private java.util.Date updateTime;
 
 	/** 0-正常,9-锁定 */
-	@ApiModelProperty(value = "0-正常,9-锁定",required = false)
+	@ApiModelProperty(value = "0-正常,9-锁定")
 	private Integer lockFlag;
 
 	/** 0-正常,1-删除 */
-	@ApiModelProperty(value = "0-正常,1-删除",required = false)
+	@ApiModelProperty(value = "0-正常,1-删除")
 	private Boolean delFlag= false;
 
 	/** 微信openid */
-	@ApiModelProperty(value = "微信openid",required = false)
+	@ApiModelProperty(value = "微信openid")
 	private String wxOpenid;
 
 	/** QQ openid */
-	@ApiModelProperty(value = "QQ openid",required = false)
+	@ApiModelProperty(value = "QQ openid")
 	private String qqOpenid;
 
 	/** 用户类型 */
-//	@ApiModelProperty(value = "用户类型",required = false)
+//	@ApiModelProperty(value = "用户类型")
 	//STUDENT("学生"), EDU_TEACHER("教务老师"), TEACHER("指导老师"), SYSTEM("系统內置"), ADMIN("管理员")
 	private String userType;
 
-	@ApiModelProperty(value = "性别0女1男",required = false)
+	@ApiModelProperty(value = "性别0女1男")
 	private Integer gender;
 
-	@ApiModelProperty(value = "民族",required = false)
+	@ApiModelProperty(value = "民族")
 	private String nation;
 
-	@ApiModelProperty(value = "生日",required = false)
+	@ApiModelProperty(value = "生日")
 	private Date birthdate;
 
-	@ApiModelProperty(value = "邮箱",required = false)
+	@ApiModelProperty(value = "邮箱")
 	private String email;
 
-	@ApiModelProperty(value = "融云token",required = false)
+	@ApiModelProperty(value = "融云token")
 	private String imToken;
 
-	@ApiModelProperty(value = "身份证号",required = false)
+	@ApiModelProperty(value = "身份证号")
 	private String idCardNo;
 
-	@ApiModelProperty(value = "真实姓名",required = false)
+	@ApiModelProperty(value = "真实姓名")
 	private String realName;
 
-	@ApiModelProperty(value = "微信号",required = false)
+	@ApiModelProperty(value = "微信号")
 	private String wechatId;
 
-	@ApiModelProperty(value = "是否是超管",required = false)
+	@ApiModelProperty(value = "是否是超管")
 	private Boolean isSuperAdmin = false;
 
-	@ApiModelProperty(value = "用户角色",required = false)
+	@ApiModelProperty(value = "用户角色")
 	private List<Long> roles;
 
 	private String certificateType;

+ 17 - 15
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/EmployeeController.java

@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dao.EmployeeDao;
+import com.yonge.cooleshow.biz.dal.dto.EmployeeDto;
 import com.yonge.cooleshow.biz.dal.dto.search.EmployeeSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
+import com.yonge.cooleshow.biz.dal.vo.EmployeeVo;
 import com.yonge.cooleshow.biz.dal.vo.StudentVo;
 import com.yonge.cooleshow.common.page.QueryInfo;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
@@ -18,6 +20,7 @@ import io.swagger.annotations.ApiOperation;
 
 import java.util.Date;
 
+import org.apache.commons.beanutils.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -26,6 +29,8 @@ import com.yonge.cooleshow.biz.dal.entity.Employee;
 import com.yonge.cooleshow.biz.dal.service.EmployeeService;
 import com.yonge.cooleshow.common.controller.BaseController;
 
+import javax.validation.Valid;
+
 @RequestMapping("employee")
 @Api(tags = "员工管理")
 @RestController
@@ -42,8 +47,8 @@ public class EmployeeController extends BaseController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "id", paramType = "path", dataType = "long", required = true),
     })
-    public HttpResponseResult<Employee> detail(@PathVariable("id") Long id){
-        Employee detail = employeeService.detail(id);
+    public HttpResponseResult<EmployeeVo> detail(@PathVariable("id") Long id){
+        EmployeeVo detail = employeeService.detail(id);
         return succeed(detail);
     }
 
@@ -53,41 +58,38 @@ public class EmployeeController extends BaseController {
     @ApiOperation(value = "查询分页", notes = "传入student")
     @PostMapping("/page")
     @PreAuthorize("@pcs.hasPermissions('employee/page')")
-    public HttpResponseResult<PageInfo<Employee>> page(@RequestBody EmployeeSearch query) {
+    public HttpResponseResult<PageInfo<EmployeeVo>> page(@RequestBody EmployeeSearch query) {
         query.setSort("id_");
-        IPage<Employee> pages = employeeService.selectPage(PageUtil.getPage(query), query);
+        IPage<EmployeeVo> pages = employeeService.selectPage(PageUtil.getPage(query), query);
         return succeed(PageUtil.pageInfo(pages));
     }
 
     @ApiOperation(value = "新增员工")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('employee/add')")
-    public Object add(@RequestBody Employee employee) throws Exception {
+    public HttpResponseResult<EmployeeDto> add(@Valid @RequestBody EmployeeDto employee) throws Exception {
         employee.setCreateTime(new Date());
         employee.setUpdateTime(new Date());
-        employeeService.add(employee);
-        return succeed();
+        return employeeService.addEmployee(employee);
     }
 
     @ApiOperation(value = "修改员工")
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('employee/update')")
-    public Object update(@RequestBody Employee employee) throws Exception{
+    public HttpResponseResult<EmployeeDto> update(@Valid @RequestBody EmployeeDto employee) throws Exception{
         employee.setUpdateTime(new Date());
-        employeeService.updateEmployee(employee);
-        return succeed();
+        return employeeService.updateEmployee(employee);
     }
 
     @ApiOperation(value = "获取用户信息")
     @GetMapping("/queryUserInfo")
-    public Object apiQueryUserInfo() {
+    public HttpResponseResult<EmployeeVo> apiQueryUserInfo() {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if(sysUser != null && sysUser.getId() != null){
             Employee employee = employeeService.get(sysUser.getId());
-            employee.setRoles(employeeDao.queryUserRole(sysUser.getId()));
-            employee.setContactAddress(employee.getContactAddress());
-
-            return succeed(employee);
+            EmployeeVo employeeVo = new EmployeeVo().buildVo(employee);
+            employeeVo.setRoleIds(employeeDao.queryUserRole(sysUser.getId()));
+            return succeed(employeeVo);
         }
         return failed("获取用户信息失败");
     }

+ 4 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/EmployeeDao.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.yonge.cooleshow.biz.dal.dto.search.EmployeeSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
+import com.yonge.cooleshow.biz.dal.vo.EmployeeVo;
 import com.yonge.cooleshow.biz.dal.vo.StudentVo;
 import org.apache.ibatis.annotations.Param;
 
@@ -22,7 +23,7 @@ public interface EmployeeDao extends BaseDAO<Long, Employee> {
      * @updateTime 2022/3/25 13:36
      * @return: com.yonge.cooleshow.biz.dal.entity.Employee
      */
-    Employee detail(@Param("id") Long id);
+    EmployeeVo detail(@Param("id") Long id);
     /***
      * 平台用户管理分页查询
      * @author liweifan
@@ -31,7 +32,7 @@ public interface EmployeeDao extends BaseDAO<Long, Employee> {
      * @updateTime 2022/4/6 13:58
      * @return: java.util.List<com.yonge.cooleshow.biz.dal.entity.Employee>
      */
-    List<Employee> selectPage(@Param("page") IPage page, @Param("param") EmployeeSearch employeeSearch);
+    List<EmployeeVo> selectPage(@Param("page") IPage page, @Param("param") EmployeeSearch employeeSearch);
 
     /***
      * 插入用户表
@@ -64,7 +65,7 @@ public interface EmployeeDao extends BaseDAO<Long, Employee> {
      * @param id
      * @param roleIds
      */
-    void batchAddEmployeeRole(@Param("userId") Long id, @Param("roleIds") List<Integer> roleIds);
+    void batchAddEmployeeRole(@Param("userId") Long id, @Param("roleIds") List<Long> roleIds);
 
     /***
      * 通过手机号查询用户

+ 95 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/EmployeeDto.java

@@ -0,0 +1,95 @@
+package com.yonge.cooleshow.biz.dal.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.yonge.cooleshow.biz.dal.entity.Employee;
+import com.yonge.cooleshow.biz.dal.enums.GenderEnum;
+import com.yonge.cooleshow.biz.dal.enums.UserLockFlag;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.beanutils.BeanUtils;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022-04-06 16:18:03
+ */
+@ApiModel(value = "EmployeeDto对象", description = "员工表数据传输对象")
+public class EmployeeDto extends Employee{
+    private static final long serialVersionUID = 1L;
+
+    @NotBlank(message = "用户姓名不能为空")
+    @ApiModelProperty("昵称")
+    private String username;
+    @NotNull(message = "性别不能为空")
+    @ApiModelProperty(value = "性别 0女 1男")
+    private GenderEnum gender;
+    @NotBlank(message = "手机号不能为空")
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+    @NotNull(message = "入职时间不能为空")
+    @ApiModelProperty("入职时间 ")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private Date entryDate;
+    @NotNull(message = "角色不能为空")
+    @ApiModelProperty(value = "角色id列表")
+    private List<Long> roleIds;
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public GenderEnum getGender() {
+        return gender;
+    }
+
+    public void setGender(GenderEnum gender) {
+        this.gender = gender;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public List<Long> getRoleIds() {
+        return roleIds;
+    }
+
+    public void setRoleIds(List<Long> roleIds) {
+        this.roleIds = roleIds;
+    }
+
+    @Override
+    public Date getEntryDate() {
+        return entryDate;
+    }
+
+    @Override
+    public void setEntryDate(Date entryDate) {
+        this.entryDate = entryDate;
+    }
+
+    public EmployeeDto toEmployeeDto(Employee employee){
+        try {
+            BeanUtils.copyProperties(this,employee);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return this;
+    }
+
+}

+ 56 - 65
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/Employee.java

@@ -1,63 +1,66 @@
 package com.yonge.cooleshow.biz.dal.entity;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.io.Serializable;
 import java.util.Date;
-import java.util.List;
-
-import com.yonge.cooleshow.auth.api.entity.SysUser;
-import com.yonge.cooleshow.biz.dal.enums.JobNatureEnum;
-import com.yonge.cooleshow.biz.dal.enums.YesOrNoEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import org.springframework.format.annotation.DateTimeFormat;
 
 /**
- * 对应数据库表(employee):
+ * 员工表
  */
-public class Employee extends SysUser {
-
+@TableName("employee")
+@ApiModel(value = "Employee对象", description = "员工表")
+public class Employee implements Serializable {
+	private static final long serialVersionUID = 1L;
+	@TableId(value = "user_id_", type = IdType.AUTO)
 	private Long userId;
-
-	@ApiModelProperty(value = "工作性质(兼职、全职)",required = false)
-	private JobNatureEnum jobNature;
-
-	@ApiModelProperty(value = "是否试用期(1-是 0-否)",required = false)
-	private YesOrNoEnum isProbationPeriod;
-
-	@ApiModelProperty(value = "学历",required = false)
+	@ApiModelProperty("工作性质(兼职、全职) ")
+	@TableField(value = "job_nature_")
+	private String jobNature;
+	@ApiModelProperty("是否试用期(1-是 0-否) ")
+	@TableField(value = "is_probation_period_")
+	private String isProbationPeriod;
+	@ApiModelProperty("学历 ")
+	@TableField(value = "education_background_")
 	private String educationBackground;
-
-	@ApiModelProperty(value = "毕业学校",required = false)
+	@ApiModelProperty("毕业学校 ")
+	@TableField(value = "graduate_school_")
 	private String graduateSchool;
-
-	@ApiModelProperty(value = "技术职称",required = false)
+	@ApiModelProperty("技术职称 ")
+	@TableField(value = "technical_titles_")
 	private String technicalTitles;
-
-	@ApiModelProperty(value = "入职时间",required = false)
-	private java.util.Date entryDate;
-
-	@ApiModelProperty(value = "更新时间",required = false)
+	@ApiModelProperty("入职时间 ")
+	@TableField(value = "entry_date_")
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
-	private java.util.Date updateTime;
-
-	@ApiModelProperty(value = "创建时间",required = false)
+	private Date entryDate;
+	@TableField(value = "create_time_")
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
-	private java.util.Date createTime;
-
-	@ApiModelProperty(value = "介绍",required = false)
+	private Date createTime;
+	@TableField(value = "update_time_")
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+	private Date updateTime;
+	@ApiModelProperty("介绍 ")
+	@TableField(value = "introduction_")
 	private String introduction;
-
-	@ApiModelProperty(value = "离职日期",required = false)
-	private java.util.Date demissionDate;
-
-	@ApiModelProperty(value = "联系地址",required = false)
+	@ApiModelProperty("离职日期 ")
+	@TableField(value = "demission_date_")
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+	private Date demissionDate;
+	@ApiModelProperty("联系地址 ")
+	@TableField(value = "contact_address_")
 	private String contactAddress;
 
-	@ApiModelProperty(value = "角色id列表",required = false)
-	private List<Integer> roleIds;
-
 	public Long getUserId() {
 		return userId;
 	}
@@ -66,19 +69,19 @@ public class Employee extends SysUser {
 		this.userId = userId;
 	}
 
-	public JobNatureEnum getJobNature() {
+	public String getJobNature() {
 		return jobNature;
 	}
 
-	public void setJobNature(JobNatureEnum jobNature) {
+	public void setJobNature(String jobNature) {
 		this.jobNature = jobNature;
 	}
 
-	public YesOrNoEnum getIsProbationPeriod() {
+	public String getIsProbationPeriod() {
 		return isProbationPeriod;
 	}
 
-	public void setIsProbationPeriod(YesOrNoEnum isProbationPeriod) {
+	public void setIsProbationPeriod(String isProbationPeriod) {
 		this.isProbationPeriod = isProbationPeriod;
 	}
 
@@ -114,26 +117,22 @@ public class Employee extends SysUser {
 		this.entryDate = entryDate;
 	}
 
-	@Override
-	public Date getUpdateTime() {
-		return updateTime;
-	}
-
-	@Override
-	public void setUpdateTime(Date updateTime) {
-		this.updateTime = updateTime;
-	}
-
-	@Override
 	public Date getCreateTime() {
 		return createTime;
 	}
 
-	@Override
 	public void setCreateTime(Date createTime) {
 		this.createTime = createTime;
 	}
 
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
 	public String getIntroduction() {
 		return introduction;
 	}
@@ -157,12 +156,4 @@ public class Employee extends SysUser {
 	public void setContactAddress(String contactAddress) {
 		this.contactAddress = contactAddress;
 	}
-
-	public List<Integer> getRoleIds() {
-		return roleIds;
-	}
-
-	public void setRoleIds(List<Integer> roleIds) {
-		this.roleIds = roleIds;
-	}
-}
+}

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TeacherAuthEntryRecord.java

@@ -80,7 +80,7 @@ public class TeacherAuthEntryRecord implements Serializable {
 	@TableField(value = "teacher__certificate_")
     private String teacherCertificate;
 
-    @ApiModelProperty("老师认证审核状态 1、审核中 2、通过 3、不通过 ")
+    @ApiModelProperty("老师认证审核状态 UNPAALY、未申请 DOING、审核中 PASS、通过 UNPASS、不通过")
 	@TableField(value = "teacher_auth_status_")
     private AuthStatusEnum teacherAuthStatus;
     /** 

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TeacherAuthMusicianRecord.java

@@ -33,7 +33,7 @@ public class TeacherAuthMusicianRecord implements Serializable {
 	@TableField(value = "user_id_")
     private Long userId;
 
-    @ApiModelProperty("老师认证审核状态 1、审核中 2、通过 3、不通过 ")
+    @ApiModelProperty("老师认证审核状态 UNPAALY、未申请 DOING、审核中 PASS、通过 UNPASS、不通过")
 	@TableField(value = "teacher_auth_status_")
     private AuthStatusEnum teacherAuthStatus;
     /** 

+ 7 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/EmployeeService.java

@@ -5,10 +5,13 @@ import java.util.List;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yonge.cooleshow.auth.api.entity.SysRole;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.dto.EmployeeDto;
 import com.yonge.cooleshow.biz.dal.dto.search.EmployeeSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
 import com.yonge.cooleshow.biz.dal.entity.Employee;
+import com.yonge.cooleshow.biz.dal.vo.EmployeeVo;
 import com.yonge.cooleshow.biz.dal.vo.StudentVo;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.page.QueryInfo;
 import com.yonge.cooleshow.common.page.PageInfo;
 import com.yonge.cooleshow.common.service.BaseService;
@@ -21,7 +24,7 @@ public interface EmployeeService extends BaseService<Long, Employee> {
      * @updateTime 2022/3/25 11:52
      * @return: com.yonge.cooleshow.biz.dal.entity.Employee
      */
-    Employee detail(Long id);
+    EmployeeVo detail(Long id);
     /***
      * 分页查询
      * @author liweifan
@@ -30,18 +33,18 @@ public interface EmployeeService extends BaseService<Long, Employee> {
      * @updateTime 2022/4/6 13:56
      * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.yonge.cooleshow.biz.dal.entity.Employee>
      */
-    IPage<Employee> selectPage(IPage<Employee> page, EmployeeSearch employeeSearch);
+    IPage<EmployeeVo> selectPage(IPage<EmployeeVo> page, EmployeeSearch employeeSearch);
     /**
      * 新增员工
      * @param employee
      */
-    void add(Employee employee) throws Exception;
+    HttpResponseResult<EmployeeDto> addEmployee(EmployeeDto employee) throws Exception;
 
     /**
      * 修改员工信息
      * @param employee
      */
-    void updateEmployee(Employee employee) throws Exception;
+    HttpResponseResult<EmployeeDto> updateEmployee(EmployeeDto employee) throws Exception;
 
     /***
      * 通过手机号查询用户

+ 49 - 18
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/EmployeeServiceImpl.java

@@ -1,17 +1,22 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
+import java.util.Date;
 import java.util.List;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.auth.api.enums.SysUserType;
+import com.yonge.cooleshow.biz.dal.dto.EmployeeDto;
 import com.yonge.cooleshow.biz.dal.dto.search.EmployeeSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
+import com.yonge.cooleshow.biz.dal.vo.EmployeeVo;
 import com.yonge.cooleshow.biz.dal.vo.StudentVo;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.page.QueryInfo;
 import com.yonge.cooleshow.common.page.PageInfo;
+import io.swagger.models.auth.In;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,42 +43,68 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Long, Employee> impleme
     }
 
     @Override
-    public Employee detail(Long id) {
+    public EmployeeVo detail(Long id) {
         return employeeDao.detail(id);
     }
 
     @Override
-    public IPage<Employee> selectPage(IPage<Employee> page, EmployeeSearch employeeSearch) {
+    public IPage<EmployeeVo> selectPage(IPage<EmployeeVo> page, EmployeeSearch employeeSearch) {
         return page.setRecords(employeeDao.selectPage(page, employeeSearch));
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void add(Employee employee) throws Exception {
-        SysUser sysUser = new SysUser();
-        BeanUtils.copyProperties(sysUser,employee);
-        sysUser.setUserType(SysUserType.SYSTEM.getCode());
-        //初始密码,手机号后6位
-        String password = sysUser.getPhone().substring(sysUser.getPhone().length() - 6);
-        sysUser.setPassword(new BCryptPasswordEncoder().encode(password));
-        employeeDao.insertSysUser(sysUser);
+    public HttpResponseResult<EmployeeDto> addEmployee(EmployeeDto param) throws Exception {
+        SysUser sysUser = employeeDao.querySysUserByPhone(param.getPhone());
+        if (sysUser == null) {
+            sysUser = new SysUser();
+            BeanUtils.copyProperties(sysUser, param);
+            sysUser.setUserType(SysUserType.SYSTEM.getCode());
+            //初始密码,手机号后6位
+            String password = sysUser.getPhone().substring(sysUser.getPhone().length() - 6);
+            sysUser.setPassword(new BCryptPasswordEncoder().encode(password));
+            sysUser.setCreateTime(new Date());
+            sysUser.setUpdateTime(new Date());
+            employeeDao.insertSysUser(sysUser);
+        } else {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (null != employee || sysUser.getUserType().indexOf(SysUserType.SYSTEM.getCode()) > 0) {
+                return HttpResponseResult.failed("该手机号对应用户已经是员工");
+            }
+            sysUser.setUserType(SysUserType.SYSTEM.getCode() + "," + sysUser.getUserType());
+            sysUser.setUpdateTime(new Date());
+            employeeDao.updateSysUser(sysUser);
+        }
+        List<Long> roles = employeeDao.queryUserRole(sysUser.getId());
+        param.getRoleIds().removeAll(roles);
         //新增角色
-        employeeDao.batchAddEmployeeRole(sysUser.getId(),employee.getRoleIds());
+        employeeDao.batchAddEmployeeRole(sysUser.getId(), param.getRoleIds());
         //新增员工表
-        employee.setUserId(sysUser.getId());
-        employeeDao.insert(employee);
+        param.setUserId(sysUser.getId());
+        employeeDao.insert(param);
+        return HttpResponseResult.succeed(param);
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void updateEmployee(Employee employee) throws Exception {
-        SysUser sysUser = new SysUser();
-        BeanUtils.copyProperties(sysUser,employee);
-        sysUser.setId(employee.getUserId());
+    public HttpResponseResult<EmployeeDto> updateEmployee(EmployeeDto param) throws Exception {
+        SysUser sysUser = employeeDao.querySysUserById(param.getUserId());
+        Employee employee = employeeDao.get(sysUser.getId());
+        if(null == sysUser || null == employee){
+            return HttpResponseResult.failed("未找到用户");
+        }
+        SysUser oldPhoneUser = employeeDao.querySysUserByPhone(param.getPhone());
+        if (null != oldPhoneUser && !oldPhoneUser.getId().equals(sysUser.getId())) {
+            return HttpResponseResult.failed("手机号已经有用户使用");
+        }
+        BeanUtils.copyProperties(sysUser, param);
         employeeDao.updateSysUser(sysUser);
 
         employeeDao.delEmployeeRole(employee.getUserId());
-        employeeDao.batchAddEmployeeRole(employee.getUserId(),employee.getRoleIds());
+        employeeDao.batchAddEmployeeRole(employee.getUserId(), param.getRoleIds());
+
+        employeeDao.update(param);
+        return HttpResponseResult.succeed(param);
     }
 
     @Override

+ 78 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/EmployeeVo.java

@@ -0,0 +1,78 @@
+package com.yonge.cooleshow.biz.dal.vo;
+
+import com.yonge.cooleshow.biz.dal.entity.Employee;
+import com.yonge.cooleshow.biz.dal.enums.GenderEnum;
+import com.yonge.cooleshow.biz.dal.enums.UserLockFlag;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.beanutils.BeanUtils;
+
+import java.util.List;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022-04-06 16:04:57
+ */
+@ApiModel(value = "EmployeeVo对象", description = "员工表查询视图对象")
+public class EmployeeVo extends Employee {
+    private static final long serialVersionUID = 1L;
+    @ApiModelProperty("昵称")
+    private String username;
+    @ApiModelProperty(value = "性别 0女 1男")
+    private GenderEnum gender;
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+    @ApiModelProperty(value = "0-正常,9-锁定")
+    private UserLockFlag lockFlag;
+    @ApiModelProperty(value = "角色id列表")
+    private List<Long> roleIds;
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public GenderEnum getGender() {
+        return gender;
+    }
+
+    public void setGender(GenderEnum gender) {
+        this.gender = gender;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public UserLockFlag getLockFlag() {
+        return lockFlag;
+    }
+
+    public void setLockFlag(UserLockFlag lockFlag) {
+        this.lockFlag = lockFlag;
+    }
+
+    public List<Long> getRoleIds() {
+        return roleIds;
+    }
+
+    public void setRoleIds(List<Long> roleIds) {
+        this.roleIds = roleIds;
+    }
+
+    public EmployeeVo buildVo(Employee employee) {
+        try {
+            BeanUtils.copyProperties(this, employee);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return this;
+    }
+}

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherHomeVo.java

@@ -34,9 +34,9 @@ public class TeacherHomeVo implements Serializable {
     private Integer expTime;
     @ApiModelProperty("未上课时")
     private Integer unExpTime;
-    @ApiModelProperty("老师入驻状态 0、未申请  1、审核中 2、通过 3、不通过 ")
+    @ApiModelProperty("老师入驻状态 0、未申请  UNPAALY、未申请 DOING、审核中 PASS、通过 UNPASS、不通过")
     private AuthStatusEnum entryStatus;
-    @ApiModelProperty("音乐人审核状态  0、未申请 1、审核中 2、通过 3、不通过 ")
+    @ApiModelProperty("音乐人审核状态  0、未申请 UNPAALY、未申请 DOING、审核中 PASS、通过 UNPASS、不通过")
     private AuthStatusEnum musicianAuthStatus;
     @ApiModelProperty("是否有直播权限 0 否 1 是")
     private YesOrNoEnum liveFlag;

+ 2 - 3
cooleshow-user/user-biz/src/main/resources/config/mybatis/EmployeeMapper.xml

@@ -60,7 +60,7 @@
         , t.contact_address_ as "contactAddress"
         </sql>
 
-    <select id="detail" resultType="com.yonge.cooleshow.biz.dal.entity.Employee">
+    <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.EmployeeVo">
         SELECT
             <include refid="baseColumns" />,
             username_ as username,
@@ -71,7 +71,7 @@
         where t.user_id_ = #{id}
     </select>
 
-    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.entity.Employee">
+    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.EmployeeVo">
         SELECT
             <include refid="baseColumns" />,
             u.username_ as username,
@@ -259,7 +259,6 @@
     </select>
 
 
-
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="Employee">
 		SELECT * FROM employee WHERE user_id_ = #{userId}