Browse Source

启用禁用员工账号业务代码开发

潘海瑞 10 months ago
parent
commit
b93a810748

+ 12 - 0
sky-server/src/main/java/com/sky/controller/admin/EmployeeController.java

@@ -101,4 +101,16 @@ public class EmployeeController {
     }
 
 
+    /**
+     * 启用禁用员工账号
+     * @param status
+     * @param id
+     * @return
+     */
+    @PostMapping("/status/{status}")
+    public Result startOrStop(@PathVariable Integer status, Long id){
+        log.info("禁用启用员工账号:{},{}",status,id);
+        employeeService.startOrStop(status,id);
+        return Result.success();
+    }
 }

+ 6 - 0
sky-server/src/main/java/com/sky/mapper/EmployeeMapper.java

@@ -35,4 +35,10 @@ public interface EmployeeMapper {
      * @return
      */
     Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);
+
+    /**
+     * 根据主键动态修改属性
+     * @param employee
+     */
+    void update(Employee employee);
 }

+ 7 - 0
sky-server/src/main/java/com/sky/service/EmployeeService.java

@@ -27,4 +27,11 @@ public interface EmployeeService {
      * @return
      */
     PageResult pageQuery(EmployeePageQueryDTO employeePageQueryDTO);
+
+    /**
+     * 启用禁用员工账号
+     * @param status
+     * @param id
+     */
+    void startOrStop(Integer status, Long id);
 }

+ 19 - 0
sky-server/src/main/java/com/sky/service/impl/EmployeeServiceImpl.java

@@ -107,4 +107,23 @@ public class EmployeeServiceImpl implements EmployeeService {
         return new PageResult(total,records);
     }
 
+    /**
+     * 启用禁用员工账号
+     * @param status
+     * @param id
+     */
+    @Override
+    public void startOrStop(Integer status, Long id) {
+
+        /*Employee employee = new Employee();
+        employee.setStatus(status);
+        employee.setId(id);*/
+
+        Employee employee = Employee.builder()
+                        .status(status)
+                                .id(id)
+                                        .build();
+        employeeMapper.update(employee);
+    }
+
 }

+ 33 - 0
sky-server/src/main/resources/mapper/EmployeeMapper.xml

@@ -11,4 +11,37 @@
         </where>
         order by create_time desc
     </select>
+    <update id="update">
+        update employee
+        <set>
+            <if test="name != null">
+                name = #{name},
+            </if>
+            <if test="username != null">
+                username = #{username},
+            </if>
+            <if test="password != null">
+                password = #{password},
+            </if>
+            <if test="phone != null">
+                phone = #{phone},
+            </if>
+            <if test="sex != null">
+                sex = #{sex},
+            </if>
+            <if test="idNumber != null">
+                id_number = #{idNumber},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime},
+            </if>
+            <if test="updateUser != null">
+                update_user = #{updateUser},
+            </if>
+            <if test="status != null">
+                status = #{status},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
 </mapper>