|
@@ -1,57 +1,59 @@
|
|
|
package org.jeecg.modules.system.app.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLDecoder;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import org.jeecg.common.api.vo.Result;
|
|
|
-import org.jeecg.common.system.query.QueryGenerator;
|
|
|
-import org.jeecg.common.system.query.QueryRuleEnum;
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
-import org.jeecg.modules.system.app.entity.AppInstructor;
|
|
|
-import org.jeecg.modules.system.app.service.IAppInstructorService;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-
|
|
|
-import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
-import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
-import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
+import me.zhyd.oauth.utils.UuidUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.util.PasswordUtil;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.base.service.BaseCommonService;
|
|
|
+import org.jeecg.modules.system.app.entity.AppInstructor;
|
|
|
+import org.jeecg.modules.system.app.service.IAppInstructorService;
|
|
|
+import org.jeecg.modules.system.app.vo.staff.StaffSaveVO;
|
|
|
+import org.jeecg.modules.system.entity.SysDepart;
|
|
|
+import org.jeecg.modules.system.entity.SysUser;
|
|
|
+import org.jeecg.modules.system.service.ISysDepartService;
|
|
|
+import org.jeecg.modules.system.service.ISysUserService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
-import io.swagger.v3.oas.annotations.Operation;
|
|
|
-import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
-import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
- /**
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
* @Description: 教练表
|
|
|
* @Author: jeecg-boot
|
|
|
- * @Date: 2025-07-04
|
|
|
* @Version: V1.0
|
|
|
*/
|
|
|
-@Tag(name="教练表")
|
|
|
+@Tag(name="员工信息")
|
|
|
@RestController
|
|
|
-@RequestMapping("/org/jeecg/modules/app/appInstructor")
|
|
|
+@RequestMapping("/staff/staff")
|
|
|
@Slf4j
|
|
|
public class AppInstructorController extends JeecgController<AppInstructor, IAppInstructorService> {
|
|
|
@Autowired
|
|
|
private IAppInstructorService appInstructorService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
+ private BaseCommonService baseCommonService;
|
|
|
+ @Autowired
|
|
|
+ private ISysDepartService sysDepartService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
@@ -62,7 +64,7 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
* @return
|
|
|
*/
|
|
|
//@AutoLog(value = "教练表-分页列表查询")
|
|
|
- @Operation(summary="教练表-分页列表查询")
|
|
|
+ @Operation(summary="员工信息-分页列表查询")
|
|
|
@GetMapping(value = "/list")
|
|
|
public Result<IPage<AppInstructor>> queryPageList(AppInstructor appInstructor,
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
@@ -79,31 +81,72 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|
|
|
- * @param appInstructor
|
|
|
+ * @param staffSaveVO
|
|
|
* @return
|
|
|
*/
|
|
|
- @AutoLog(value = "教练表-添加")
|
|
|
- @Operation(summary="教练表-添加")
|
|
|
- @RequiresPermissions("org.jeecg.modules.app:nm_instructor:add")
|
|
|
+ @AutoLog(value = "员工信息-添加")
|
|
|
+ @Operation(summary="员工信息-添加")
|
|
|
+ @RequiresPermissions("staff:add")
|
|
|
@PostMapping(value = "/add")
|
|
|
- public Result<String> add(@RequestBody AppInstructor appInstructor) {
|
|
|
+ @Transactional
|
|
|
+ public Result<String> add(@RequestBody StaffSaveVO staffSaveVO) {
|
|
|
+ SysUser user = new SysUser();
|
|
|
+ AppInstructor appInstructor = new AppInstructor();
|
|
|
+ if (StringUtils.isEmpty(staffSaveVO.getSelectedroles())){
|
|
|
+ return Result.error("角色权限为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(staffSaveVO.getSelecteddeparts())){
|
|
|
+ return Result.error("所属部门为空");
|
|
|
+ }
|
|
|
+ if (staffSaveVO.getSelectedroles().indexOf("instructor")==0){
|
|
|
+ if (staffSaveVO.getSelecteddeparts().contains(",")){
|
|
|
+ return Result.error("该角色涉及教练,不允许多部门");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SysDepart departById = sysDepartService.getDepartById(staffSaveVO.getSelecteddeparts());
|
|
|
+ try {
|
|
|
+ BeanUtils.copyProperties(staffSaveVO,user);
|
|
|
+ user.setId(UuidUtils.getUUID());
|
|
|
+ user.setCreateTime(new Date());//设置创建时间
|
|
|
+ String salt = oConvertUtils.randomGen(8);
|
|
|
+ user.setSalt(salt);
|
|
|
+ String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), salt);
|
|
|
+ user.setPassword(passwordEncode);
|
|
|
+ user.setStatus(1);
|
|
|
+ user.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ user.setUserIdentity(CommonConstant.USER_IDENTITY_1);
|
|
|
+ //用户表字段org_code不能在这里设置他的值
|
|
|
+ user.setOrgCode(departById.getOrgCode());
|
|
|
+ // 保存用户走一个service 保证事务
|
|
|
+ sysUserService.saveUser(user, staffSaveVO.getSelectedroles(), staffSaveVO.getSelecteddeparts(), null);
|
|
|
+ baseCommonService.addLog("添加用户,username: " +user.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ return Result.error("添加失败!");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(staffSaveVO,appInstructor);
|
|
|
+ appInstructor.setUserId(user.getId());
|
|
|
+ appInstructor.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
appInstructorService.save(appInstructor);
|
|
|
-
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑
|
|
|
*
|
|
|
- * @param appInstructor
|
|
|
+ * @param staffSaveVO
|
|
|
* @return
|
|
|
*/
|
|
|
- @AutoLog(value = "教练表-编辑")
|
|
|
- @Operation(summary="教练表-编辑")
|
|
|
- @RequiresPermissions("org.jeecg.modules.app:nm_instructor:edit")
|
|
|
+ @AutoLog(value = "员工信息-编辑")
|
|
|
+ @Operation(summary="员工信息-编辑")
|
|
|
+ @RequiresPermissions("staff:edit")
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
- public Result<String> edit(@RequestBody AppInstructor appInstructor) {
|
|
|
- appInstructorService.updateById(appInstructor);
|
|
|
+ public Result<String> edit(@RequestBody StaffSaveVO staffSaveVO) {
|
|
|
+ if (staffSaveVO==null||StringUtils.isEmpty(staffSaveVO.getId())){
|
|
|
+ return Result.error("编辑失败!请选择需要编辑的员工信息。");
|
|
|
+ }
|
|
|
+// sysUserService.findByUserIdStaff(staffSaveVO.getId());
|
|
|
+// appInstructorService.updateById(appInstructor);
|
|
|
return Result.OK("编辑成功!");
|
|
|
}
|
|
|
|
|
@@ -113,9 +156,9 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
- @AutoLog(value = "教练表-通过id删除")
|
|
|
- @Operation(summary="教练表-通过id删除")
|
|
|
- @RequiresPermissions("org.jeecg.modules.app:nm_instructor:delete")
|
|
|
+ @AutoLog(value = "员工信息-通过id删除")
|
|
|
+ @Operation(summary="员工信息-通过id删除")
|
|
|
+ @RequiresPermissions("staff:delete")
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
appInstructorService.removeById(id);
|
|
@@ -128,9 +171,9 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
* @param ids
|
|
|
* @return
|
|
|
*/
|
|
|
- @AutoLog(value = "教练表-批量删除")
|
|
|
- @Operation(summary="教练表-批量删除")
|
|
|
- @RequiresPermissions("org.jeecg.modules.app:nm_instructor:deleteBatch")
|
|
|
+ @AutoLog(value = "员工信息-批量删除")
|
|
|
+ @Operation(summary="员工信息-批量删除")
|
|
|
+ @RequiresPermissions("staff:deleteBatch")
|
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
this.appInstructorService.removeByIds(Arrays.asList(ids.split(",")));
|
|
@@ -144,7 +187,7 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
* @return
|
|
|
*/
|
|
|
//@AutoLog(value = "教练表-通过id查询")
|
|
|
- @Operation(summary="教练表-通过id查询")
|
|
|
+ @Operation(summary="员工信息-通过id查询")
|
|
|
@GetMapping(value = "/queryById")
|
|
|
public Result<AppInstructor> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
AppInstructor appInstructor = appInstructorService.getById(id);
|
|
@@ -160,10 +203,10 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
* @param request
|
|
|
* @param appInstructor
|
|
|
*/
|
|
|
- @RequiresPermissions("org.jeecg.modules.app:nm_instructor:exportXls")
|
|
|
+ @RequiresPermissions("staff:exportXls")
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
public ModelAndView exportXls(HttpServletRequest request, AppInstructor appInstructor) {
|
|
|
- return super.exportXls(request, appInstructor, AppInstructor.class, "教练表");
|
|
|
+ return super.exportXls(request, appInstructor, AppInstructor.class, "员工表");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -173,7 +216,7 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
* @param response
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequiresPermissions("org.jeecg.modules.app:nm_instructor:importExcel")
|
|
|
+ @RequiresPermissions("staff:importExcel")
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
return super.importExcel(request, response, AppInstructor.class);
|