diff --git a/pom.xml b/pom.xml index 2465e44..b2694f2 100644 --- a/pom.xml +++ b/pom.xml @@ -129,17 +129,17 @@ - - io.springfox - springfox-boot-starter - ${swagger.version} - - - io.swagger - swagger-models - - - + + + + + + + + + + + diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index ce384b4..6c036eb 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -16,7 +16,20 @@ - + + org.projectlombok + lombok + + + cn.hutool + hutool-all + 5.8.23 + + + com.github.xiaoymin + knife4j-openapi2-spring-boot-starter + 4.4.0 + org.springframework.boot @@ -25,17 +38,17 @@ - - io.springfox - springfox-boot-starter - + + + + - - io.swagger - swagger-models - 1.6.2 - + + + + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index e3c56ee..9c6972d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -3,6 +3,11 @@ package com.ruoyi; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.Environment; + +import java.net.InetAddress; +import java.net.UnknownHostException; /** * 启动程序 @@ -14,17 +19,21 @@ public class RuoYiApplication { public static void main(String[] args) { - // System.setProperty("spring.devtools.restart.enabled", "false"); - SpringApplication.run(RuoYiApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); + ConfigurableApplicationContext application = SpringApplication.run(RuoYiApplication.class, args); + Environment env = application.getEnvironment(); + String ip; + try { + ip = InetAddress.getLocalHost().getHostAddress(); + } catch (UnknownHostException e) { + throw new RuntimeException(e); + } + String port = env.getProperty("server.port"); + String path = env.getProperty("server.servlet.context-path"); + path = path.isEmpty() ? "" : path; + System.out.println("\n----------------------------------------------------------\n\t" + + "Application is running! Access URLs:\n\t" + + "swagger-ui: http://localhost:" + port + path + "doc.html\n\t" + + "swagger-ui: http://" + ip + ":" + port + path + "doc.html\n\t" + + "----------------------------------------------------------"); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitOtherConcatController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitOtherConcatController.java new file mode 100644 index 0000000..d58ab0f --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitOtherConcatController.java @@ -0,0 +1,104 @@ +package com.ruoyi.tc.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.tc.domain.UnitOtherConcat; +import com.ruoyi.tc.service.UnitOtherConcatService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +/** + * 单位其他联系人(unit_other_contact)控制层 + * @author du + * @since 2024/11/13 14:50 + */ +@RestController +@RequestMapping("/unit/otherConcat") +@Api(tags = "单位其他联系人控制层") +public class UnitOtherConcatController extends BaseController { + /** + * 服务对象 + */ + @Resource + private UnitOtherConcatService unitOtherConcatService; + + /** + * 根据unit_id查询该单位所有数据 + * + * @param unitId 查询unit_id + * @return 所有数据 + */ +// @PreAuthorize("@ss.hasAnyRoles('admin')") + @ApiOperation(value = "根据unit_id查询该单位所有数据", response = UnitOtherConcat.class) + @GetMapping("/selectAll/{unitId}") + public AjaxResult selectAll(@PathVariable Long unitId) { + return success(unitOtherConcatService.lambdaQuery().eq(UnitOtherConcat::getUnitId,unitId).list()); + } + + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @ApiOperation(value = "通过主键查询单条数据", response = UnitOtherConcat.class) + @GetMapping("/{id}") + public AjaxResult selectOne(@PathVariable Serializable id) { + return success(unitOtherConcatService.getById(id)); + } + + /** + * 新增数据 + * + * @param u 实体对象 + * @return 新增结果 + */ +// @PreAuthorize("@ss.hasAnyRoles('admin')") + @ApiOperation(value = "新增数据") + @PostMapping + public AjaxResult insert(@Valid @RequestBody UnitOtherConcat u) { + return success(unitOtherConcatService.save(u)); + } + + + /** + * 修改数据 + * + * @param u 实体对象 + * @return 修改结果 + */ +// @PreAuthorize("@ss.hasAnyRoles('admin')") + @ApiOperation(value = "修改数据") + @PostMapping("/edit") + public AjaxResult update(@RequestBody UnitOtherConcat u) { + return success(unitOtherConcatService.updateById(u)); + } + + /** + * 删除数据 + * + * @param ids 主键结合 + * @return 删除结果 + */ +// @PreAuthorize("@ss.hasAnyRoles('admin')") + @ApiOperation(value = "删除数据") + @PostMapping("/ids") + public AjaxResult delete(Long[] ids) { + return success(unitOtherConcatService.removeBatchByIds(Arrays.asList(ids))); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/domain/UnitOtherConcat.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/domain/UnitOtherConcat.java new file mode 100644 index 0000000..def8cc2 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/domain/UnitOtherConcat.java @@ -0,0 +1,77 @@ +package com.ruoyi.tc.domain; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * 单位其他联系人(unit_other_contact)实体类 + * @author du + * @since 2024/11/13 14:44 + */ +@Data +@ApiModel("单位其他联系人") +@TableName(value = "unit_other_contact") +public class UnitOtherConcat implements Serializable { + + @TableId(type = IdType.AUTO,value = "id") + private Long id; + + @ApiModelProperty("单位id") + @NotNull + private Long unitId; + + @ApiModelProperty("其他联系人姓名") + private String qtlxrxm; + + @ApiModelProperty("其他联系人联系方式") + private String qtlxrlxfs; + + @ApiModelProperty("其他联系人邮箱") + private String qtlxryx; + + @ApiModelProperty("其他联系人职务职称") + private String qtlxrzwzc; + + /** + * 创建者 + */ + @ApiModelProperty("创建者") + @TableField(fill = FieldFill.INSERT) + private String createBy; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新者 + */ + @ApiModelProperty("更新者") + @TableField(fill = FieldFill.UPDATE) + private String updateBy; + + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") + @TableField(fill = FieldFill.UPDATE) + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + private String remark; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitOtherConcatMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitOtherConcatMapper.java new file mode 100644 index 0000000..f0d7407 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitOtherConcatMapper.java @@ -0,0 +1,16 @@ +package com.ruoyi.tc.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.tc.domain.UnitOtherConcat; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 单位其他联系人(unit_other_contact)数据层 + * @author ruoyi + */ +public interface UnitOtherConcatMapper extends BaseMapper +{ +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitOtherConcatService.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitOtherConcatService.java new file mode 100644 index 0000000..b4d43f6 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitOtherConcatService.java @@ -0,0 +1,13 @@ +package com.ruoyi.tc.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.tc.domain.UnitOtherConcat; + +/** + * 单位其他联系人(unit_other_contact)业务层 + * @author du + * @since 2024/11/13 14:55 + */ +public interface UnitOtherConcatService extends IService { +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitOtherConcatServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitOtherConcatServiceImpl.java new file mode 100644 index 0000000..d00609d --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitOtherConcatServiceImpl.java @@ -0,0 +1,16 @@ +package com.ruoyi.tc.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.tc.domain.UnitOtherConcat; +import com.ruoyi.tc.mapper.UnitOtherConcatMapper; +import com.ruoyi.tc.service.UnitOtherConcatService; +import org.springframework.stereotype.Service; + +/** + * 单位其他联系人(unit_other_contact)业务处理层 + * @author du + * @since 2024/11/13 14:58 + */ +@Service +public class UnitOtherConcatServiceImpl extends ServiceImpl implements UnitOtherConcatService { +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java index cd8abd6..5a83d5d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -62,17 +62,17 @@ public class SysProfileController extends BaseController LoginUser loginUser = getLoginUser(); SysUser currentUser = loginUser.getUser(); currentUser.setNickName(user.getNickName()); - currentUser.setEmail(user.getEmail()); - currentUser.setPhonenumber(user.getPhonenumber()); - currentUser.setSex(user.getSex()); - if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) - { - return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在"); - } - if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) - { - return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在"); - } +// currentUser.setEmail(user.getEmail()); +// currentUser.setPhonenumber(user.getPhonenumber()); +// currentUser.setSex(user.getSex()); +// if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) +// { +// return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在"); +// } +// if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) +// { +// return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在"); +// } if (userService.updateUserProfile(currentUser) > 0) { // 更新缓存用户信息 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 11790f9..ab7b5bd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -1,46 +1,40 @@ package com.ruoyi.web.controller.system; -import java.util.List; -import java.util.stream.Collectors; -import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang3.ArrayUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.entity.Unit; +import com.ruoyi.common.core.domain.request.UnitRequest; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.system.service.ISysDeptService; -import com.ruoyi.system.service.ISysPostService; -import com.ruoyi.system.service.ISysRoleService; -import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.system.service.*; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.stream.Collectors; /** * 用户信息 - * + * * @author ruoyi */ @RestController @RequestMapping("/system/user") -public class SysUserController extends BaseController -{ +public class SysUserController extends BaseController { @Autowired private ISysUserService userService; @@ -53,44 +47,62 @@ public class SysUserController extends BaseController @Autowired private ISysPostService postService; + @Resource + private UnitService unitService; + /** * 获取用户列表 */ @PreAuthorize("@ss.hasPermi('system:user:list')") @GetMapping("/list") - public TableDataInfo list(SysUser user) - { + public TableDataInfo list(SysUser user) { startPage(); List list = userService.selectUserList(user); return getDataTable(list); } - @Log(title = "用户管理", businessType = BusinessType.EXPORT) + @Log(title = "用户单位管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:user:export')") @PostMapping("/export") - public void export(HttpServletResponse response, SysUser user) - { - List list = userService.selectUserList(user); - ExcelUtil util = new ExcelUtil(SysUser.class); - util.exportExcel(response, list, "用户数据"); + public void export(HttpServletResponse response, UnitRequest unit) { +// List list = userService.selectUserList(user); +// ExcelUtil util = new ExcelUtil(SysUser.class); +// util.exportExcel(response, list, "用户数据"); + List list = unitService.selectUnitList(unit); + ExcelUtil util = new ExcelUtil<>(Unit.class); + util.exportExcel(response, list, "单位数据"); } - @Log(title = "用户管理", businessType = BusinessType.IMPORT) + @Log(title = "用户单位管理", businessType = BusinessType.IMPORT) @PreAuthorize("@ss.hasPermi('system:user:import')") @PostMapping("/importData") - public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception - { - ExcelUtil util = new ExcelUtil(SysUser.class); - List userList = util.importExcel(file.getInputStream()); - String operName = getUsername(); - String message = userService.importUser(userList, updateSupport, operName); - return success(message); + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { +// ExcelUtil util = new ExcelUtil(SysUser.class); +// List userList = util.importExcel(file.getInputStream()); +// String operName = getUsername(); +// String message = userService.importUser(userList, updateSupport, operName); + ExcelUtil util = new ExcelUtil<>(Unit.class); + List list = util.importExcel(file.getInputStream()); + unitService.saveBatch(list); + for (Unit x : list) { + SysUser user = new SysUser(); + user.setUserName(x.getUserName()); + user.setPassword(SecurityUtils.encryptPassword(x.getUserName().substring(x.getUserName().length() - 6))); + user.setNickName(x.getNickName()); + SysUser u = userService.selectUserByUserName(x.getUserName()); + if (StringUtils.isNull(u)) { + userService.insertUser(user); + Long[] roles = new Long[]{100L}; + userService.insertUserAuth(user.getUserId(), roles); + } + //未做修改 + } + return success(); } @PostMapping("/importTemplate") - public void importTemplate(HttpServletResponse response) - { - ExcelUtil util = new ExcelUtil(SysUser.class); + public void importTemplate(HttpServletResponse response) { + ExcelUtil util = new ExcelUtil<>(Unit.class); util.importTemplateExcel(response, "用户数据"); } @@ -98,21 +110,21 @@ public class SysUserController extends BaseController * 根据用户编号获取详细信息 */ @PreAuthorize("@ss.hasPermi('system:user:query')") - @GetMapping(value = { "/", "/{userId}" }) - public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) - { + @GetMapping(value = {"/", "/{userId}"}) + public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) { AjaxResult ajax = AjaxResult.success(); - if (StringUtils.isNotNull(userId)) - { + if (StringUtils.isNotNull(userId)) { userService.checkUserDataScope(userId); SysUser sysUser = userService.selectUserById(userId); ajax.put(AjaxResult.DATA_TAG, sysUser); ajax.put("postIds", postService.selectPostListByUserId(userId)); ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); + ajax.put("unit", unitService.lambdaQuery().eq(Unit::getUserName,sysUser.getUserName()).one()); } List roles = roleService.selectRoleAll(); ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); ajax.put("posts", postService.selectPostAll()); + ajax.put("posts", postService.selectPostAll()); return ajax; } @@ -122,23 +134,26 @@ public class SysUserController extends BaseController @PreAuthorize("@ss.hasPermi('system:user:add')") @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@Validated @RequestBody SysUser user) - { + public AjaxResult add(@Validated @RequestBody SysUser user) { deptService.checkDeptDataScope(user.getDeptId()); roleService.checkRoleDataScope(user.getRoleIds()); - if (!userService.checkUserNameUnique(user)) - { + if (!userService.checkUserNameUnique(user)) { return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); } - else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) - { - return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); - } - else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) - { - return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + if (!unitService.lambdaQuery().eq(Unit::getUserName, user.getUserName()).list().isEmpty()) { + return error("新增用户'" + user.getUserName() + "'已存在单位!"); } - user.setCreateBy(getUsername()); + //新增单位到单位信息表 + unitService.save(user.getUnitInfo()); +// else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) +// { +// return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); +// } +// else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) +// { +// return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); +// } +// user.setCreateBy(getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); return toAjax(userService.insertUser(user)); } @@ -149,25 +164,27 @@ public class SysUserController extends BaseController @PreAuthorize("@ss.hasPermi('system:user:edit')") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@Validated @RequestBody SysUser user) - { + public AjaxResult edit(@Validated @RequestBody SysUser user) { userService.checkUserAllowed(user); userService.checkUserDataScope(user.getUserId()); deptService.checkDeptDataScope(user.getDeptId()); roleService.checkRoleDataScope(user.getRoleIds()); - if (!userService.checkUserNameUnique(user)) - { + if (!userService.checkUserNameUnique(user)) { return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); } - else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) - { - return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); - } - else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) - { - return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + if (!unitService.lambdaQuery().eq(Unit::getUserName, user.getUserName()).list().isEmpty()) { + return error("修改用户'" + user.getUserName() + "'已存在单位!"); } - user.setUpdateBy(getUsername()); + unitService.updateById(user.getUnitInfo()); +// else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) +// { +// return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); +// } +// else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) +// { +// return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); +// } +// user.setUpdateBy(getUsername()); return toAjax(userService.updateUser(user)); } @@ -177,10 +194,8 @@ public class SysUserController extends BaseController @PreAuthorize("@ss.hasPermi('system:user:remove')") @Log(title = "用户管理", businessType = BusinessType.DELETE) @DeleteMapping("/{userIds}") - public AjaxResult remove(@PathVariable Long[] userIds) - { - if (ArrayUtils.contains(userIds, getUserId())) - { + public AjaxResult remove(@PathVariable Long[] userIds) { + if (ArrayUtils.contains(userIds, getUserId())) { return error("当前用户不能删除"); } return toAjax(userService.deleteUserByIds(userIds)); @@ -192,12 +207,11 @@ public class SysUserController extends BaseController @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/resetPwd") - public AjaxResult resetPwd(@RequestBody SysUser user) - { + public AjaxResult resetPwd(@RequestBody SysUser user) { userService.checkUserAllowed(user); userService.checkUserDataScope(user.getUserId()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - user.setUpdateBy(getUsername()); +// user.setUpdateBy(getUsername()); return toAjax(userService.resetPwd(user)); } @@ -207,11 +221,10 @@ public class SysUserController extends BaseController @PreAuthorize("@ss.hasPermi('system:user:edit')") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysUser user) - { + public AjaxResult changeStatus(@RequestBody SysUser user) { userService.checkUserAllowed(user); userService.checkUserDataScope(user.getUserId()); - user.setUpdateBy(getUsername()); +// user.setUpdateBy(getUsername()); return toAjax(userService.updateUserStatus(user)); } @@ -220,8 +233,7 @@ public class SysUserController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:user:query')") @GetMapping("/authRole/{userId}") - public AjaxResult authRole(@PathVariable("userId") Long userId) - { + public AjaxResult authRole(@PathVariable("userId") Long userId) { AjaxResult ajax = AjaxResult.success(); SysUser user = userService.selectUserById(userId); List roles = roleService.selectRolesByUserId(userId); @@ -236,8 +248,7 @@ public class SysUserController extends BaseController @PreAuthorize("@ss.hasPermi('system:user:edit')") @Log(title = "用户管理", businessType = BusinessType.GRANT) @PutMapping("/authRole") - public AjaxResult insertAuthRole(Long userId, Long[] roleIds) - { + public AjaxResult insertAuthRole(Long userId, Long[] roleIds) { userService.checkUserDataScope(userId); roleService.checkRoleDataScope(roleIds); userService.insertUserAuth(userId, roleIds); @@ -249,8 +260,7 @@ public class SysUserController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:user:list')") @GetMapping("/deptTree") - public AjaxResult deptTree(SysDept dept) - { + public AjaxResult deptTree(SysDept dept) { return success(deptService.selectDeptTreeList(dept)); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java index 0b94245..48cb5f5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -1,125 +1,125 @@ -package com.ruoyi.web.core.config; - -import java.util.ArrayList; -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import com.ruoyi.common.config.RuoYiConfig; -import io.swagger.annotations.ApiOperation; -import io.swagger.models.auth.In; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.ApiKey; -import springfox.documentation.service.AuthorizationScope; -import springfox.documentation.service.Contact; -import springfox.documentation.service.SecurityReference; -import springfox.documentation.service.SecurityScheme; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.Docket; - -/** - * Swagger2的接口配置 - * - * @author ruoyi - */ -@Configuration -public class SwaggerConfig -{ - /** 系统基础配置 */ - @Autowired - private RuoYiConfig ruoyiConfig; - - /** 是否开启swagger */ - @Value("${swagger.enabled}") - private boolean enabled; - - /** 设置请求的统一前缀 */ - @Value("${swagger.pathMapping}") - private String pathMapping; - - /** - * 创建API - */ - @Bean - public Docket createRestApi() - { - return new Docket(DocumentationType.OAS_30) - // 是否启用Swagger - .enable(enabled) - // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) - .apiInfo(apiInfo()) - // 设置哪些接口暴露给Swagger展示 - .select() - // 扫描所有有注解的api,用这种方式更灵活 - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - // 扫描指定包中的swagger注解 - // .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) - // 扫描所有 .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build() - /* 设置安全模式,swagger可以设置访问token */ - .securitySchemes(securitySchemes()) - .securityContexts(securityContexts()) - .pathMapping(pathMapping); - } - - /** - * 安全模式,这里指定token通过Authorization头请求头传递 - */ - private List securitySchemes() - { - List apiKeyList = new ArrayList(); - apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); - return apiKeyList; - } - - /** - * 安全上下文 - */ - private List securityContexts() - { - List securityContexts = new ArrayList<>(); - securityContexts.add( - SecurityContext.builder() - .securityReferences(defaultAuth()) - .operationSelector(o -> o.requestMappingPattern().matches("/.*")) - .build()); - return securityContexts; - } - - /** - * 默认的安全上引用 - */ - private List defaultAuth() - { - AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); - AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; - authorizationScopes[0] = authorizationScope; - List securityReferences = new ArrayList<>(); - securityReferences.add(new SecurityReference("Authorization", authorizationScopes)); - return securityReferences; - } - - /** - * 添加摘要信息 - */ - private ApiInfo apiInfo() - { - // 用ApiInfoBuilder进行定制 - return new ApiInfoBuilder() - // 设置标题 - .title("标题:若依管理系统_接口文档") - // 描述 - .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") - // 作者信息 - .contact(new Contact(ruoyiConfig.getName(), null, null)) - // 版本 - .version("版本号:" + ruoyiConfig.getVersion()) - .build(); - } -} +//package com.ruoyi.web.core.config; +// +//import java.util.ArrayList; +//import java.util.List; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import com.ruoyi.common.config.RuoYiConfig; +//import io.swagger.annotations.ApiOperation; +//import io.swagger.models.auth.In; +//import springfox.documentation.builders.ApiInfoBuilder; +//import springfox.documentation.builders.PathSelectors; +//import springfox.documentation.builders.RequestHandlerSelectors; +//import springfox.documentation.service.ApiInfo; +//import springfox.documentation.service.ApiKey; +//import springfox.documentation.service.AuthorizationScope; +//import springfox.documentation.service.Contact; +//import springfox.documentation.service.SecurityReference; +//import springfox.documentation.service.SecurityScheme; +//import springfox.documentation.spi.DocumentationType; +//import springfox.documentation.spi.service.contexts.SecurityContext; +//import springfox.documentation.spring.web.plugins.Docket; +// +///** +// * Swagger2的接口配置 +// * +// * @author ruoyi +// */ +//@Configuration +//public class SwaggerConfig +//{ +// /** 系统基础配置 */ +// @Autowired +// private RuoYiConfig ruoyiConfig; +// +// /** 是否开启swagger */ +// @Value("${swagger.enabled}") +// private boolean enabled; +// +// /** 设置请求的统一前缀 */ +// @Value("${swagger.pathMapping}") +// private String pathMapping; +// +// /** +// * 创建API +// */ +// @Bean +// public Docket createRestApi() +// { +// return new Docket(DocumentationType.OAS_30) +// // 是否启用Swagger +// .enable(enabled) +// // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) +// .apiInfo(apiInfo()) +// // 设置哪些接口暴露给Swagger展示 +// .select() +// // 扫描所有有注解的api,用这种方式更灵活 +// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) +// // 扫描指定包中的swagger注解 +// // .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) +// // 扫描所有 .apis(RequestHandlerSelectors.any()) +// .paths(PathSelectors.any()) +// .build() +// /* 设置安全模式,swagger可以设置访问token */ +// .securitySchemes(securitySchemes()) +// .securityContexts(securityContexts()) +// .pathMapping(pathMapping); +// } +// +// /** +// * 安全模式,这里指定token通过Authorization头请求头传递 +// */ +// private List securitySchemes() +// { +// List apiKeyList = new ArrayList(); +// apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); +// return apiKeyList; +// } +// +// /** +// * 安全上下文 +// */ +// private List securityContexts() +// { +// List securityContexts = new ArrayList<>(); +// securityContexts.add( +// SecurityContext.builder() +// .securityReferences(defaultAuth()) +// .operationSelector(o -> o.requestMappingPattern().matches("/.*")) +// .build()); +// return securityContexts; +// } +// +// /** +// * 默认的安全上引用 +// */ +// private List defaultAuth() +// { +// AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); +// AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; +// authorizationScopes[0] = authorizationScope; +// List securityReferences = new ArrayList<>(); +// securityReferences.add(new SecurityReference("Authorization", authorizationScopes)); +// return securityReferences; +// } +// +// /** +// * 添加摘要信息 +// */ +// private ApiInfo apiInfo() +// { +// // 用ApiInfoBuilder进行定制 +// return new ApiInfoBuilder() +// // 设置标题 +// .title("标题:若依管理系统_接口文档") +// // 描述 +// .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") +// // 作者信息 +// .contact(new Contact(ruoyiConfig.getName(), null, null)) +// // 版本 +// .version("版本号:" + ruoyiConfig.getVersion()) +// .build(); +// } +//} diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index bcfad3e..96d9d2f 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://39.101.188.84:3307/tc-asset-verification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: password + password: Admin123@ # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index c777ac1..bf132e2 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -1,7 +1,7 @@ # 项目相关配置 ruoyi: # 名称 - name: RuoYi + name: 太仓资产核查 # 版本 version: 3.8.8 # 版权年份 @@ -16,7 +16,7 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8080 + port: 9015 servlet: # 应用的访问路径 context-path: / @@ -64,7 +64,7 @@ spring: devtools: restart: # 热部署开关 - enabled: true + enabled: false # redis 配置 redis: # 地址 @@ -98,7 +98,8 @@ token: expireTime: 30 # MyBatis配置 -mybatis: +# mybatis-plus配置 +mybatis-plus: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 @@ -113,11 +114,9 @@ pagehelper: params: count=countSql # Swagger配置 -swagger: - # 是否开启swagger - enabled: true - # 请求前缀 - pathMapping: /dev-api +knife4j: + # production: true + enable: true # 防止XSS攻击 xss: diff --git a/ruoyi-admin/src/main/resources/mapper/UnitOtherConcat.xml b/ruoyi-admin/src/main/resources/mapper/UnitOtherConcat.xml new file mode 100644 index 0000000..fbbbbb8 --- /dev/null +++ b/ruoyi-admin/src/main/resources/mapper/UnitOtherConcat.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 56c3f81..b90e1d7 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -16,6 +16,20 @@ + + org.projectlombok + lombok + + + com.github.xiaoymin + knife4j-openapi2-spring-boot-starter + 4.4.0 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.3.1 + diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java index 0d69d39..d06cf97 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java @@ -18,6 +18,12 @@ import com.ruoyi.common.utils.poi.ExcelHandlerAdapter; @Target(ElementType.FIELD) public @interface Excel { + + /** + * 导出时在excel中排序 + */ + public boolean required() default false; + /** * 导出时在excel中排序 */ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java index c33d912..46dc687 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java @@ -37,17 +37,28 @@ public class SysUser extends BaseEntity @Excel(name = "用户名称") private String nickName; - /** 用户邮箱 */ - @Excel(name = "用户邮箱") - private String email; - /** 手机号码 */ - @Excel(name = "手机号码", cellType = ColumnType.TEXT) - private String phonenumber; + public Unit getUnitInfo() { + return unitInfo; + } + + public void setUnitInfo(Unit unitInfo) { + this.unitInfo = unitInfo; + } - /** 用户性别 */ - @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") - private String sex; + private Unit unitInfo; + +// /** 用户邮箱 */ +// @Excel(name = "用户邮箱") +// private String email; +// +// /** 手机号码 */ +// @Excel(name = "手机号码", cellType = ColumnType.TEXT) +// private String phonenumber; + +// /** 用户性别 */ +// @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") +// private String sex; /** 用户头像 */ private String avatar; @@ -154,38 +165,38 @@ public class SysUser extends BaseEntity this.userName = userName; } - @Email(message = "邮箱格式不正确") - @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { - return email; - } - - public void setEmail(String email) - { - this.email = email; - } - - @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") - public String getPhonenumber() - { - return phonenumber; - } - - public void setPhonenumber(String phonenumber) - { - this.phonenumber = phonenumber; - } - - public String getSex() - { - return sex; - } - - public void setSex(String sex) - { - this.sex = sex; - } +// @Email(message = "邮箱格式不正确") +// @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") +// public String getEmail() +// { +// return email; +// } +// +// public void setEmail(String email) +// { +// this.email = email; +// } +// +// @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") +// public String getPhonenumber() +// { +// return phonenumber; +// } +// +// public void setPhonenumber(String phonenumber) +// { +// this.phonenumber = phonenumber; +// } + +// public String getSex() +// { +// return sex; +// } +// +// public void setSex(String sex) +// { +// this.sex = sex; +// } public String getAvatar() { @@ -304,20 +315,20 @@ public class SysUser extends BaseEntity .append("deptId", getDeptId()) .append("userName", getUserName()) .append("nickName", getNickName()) - .append("email", getEmail()) - .append("phonenumber", getPhonenumber()) - .append("sex", getSex()) +// .append("email", getEmail()) +// .append("phonenumber", getPhonenumber()) +// .append("sex", getSex()) .append("avatar", getAvatar()) .append("password", getPassword()) .append("status", getStatus()) .append("delFlag", getDelFlag()) .append("loginIp", getLoginIp()) .append("loginDate", getLoginDate()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) +// .append("createBy", getCreateBy()) +// .append("createTime", getCreateTime()) +// .append("updateBy", getUpdateBy()) +// .append("updateTime", getUpdateTime()) +// .append("remark", getRemark()) .append("dept", getDept()) .toString(); } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/Unit.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/Unit.java new file mode 100644 index 0000000..4de9017 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/Unit.java @@ -0,0 +1,205 @@ +package com.ruoyi.common.core.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.Valid; +import java.io.Serializable; +import java.util.Date; + +/** + * 单位信息 + * @author du + * @since 2024/11/13 9:13 + */ +@Data +@ApiModel("单位信息") +@TableName(value = "unit_info") +public class Unit implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO,value = "id") + private Long id; + + @ApiModelProperty("单位名称/用户昵称") + @Excel(name = "单位名称*",required = true) + private String nickName; + + @ApiModelProperty("单位简称") + @Excel(name = "单位简称") + private String dwjc; + + @ApiModelProperty("所属区域-省") + @Excel(name = "所属区域-省*") + private String ssqyprovince; + + @ApiModelProperty("所属区域-市") + @Excel(name = "所属区域-市") + private String ssqycity; + + @ApiModelProperty("所属区域-县") + @Excel(name = "所属区域-区(县)") + private String ssqycounty; + + @ApiModelProperty("所属监管单位") + private String ssjgdw; + + @ApiModelProperty("上级单位") + @Excel(name = "上级单位") + private String sjdw; + + @ApiModelProperty("单位详细地址") + @Excel(name = "单位详细地址") + private String dwxxdz; + + @ApiModelProperty("所属行业") + @Excel(name = "所属行业",dictType="sshy",comboReadDict = true) + private Integer sshy; + + @ApiModelProperty("单位类型") + @Excel(name = "单位类型",dictType="dwlx",comboReadDict = true ) + private Integer dwlx; + + @ApiModelProperty("单位标签(多个标签逗号隔开)") + @Excel(name = "单位标签(多个标签逗号隔开)") + private String dwbq; + + @ApiModelProperty("单位角色") + @Excel(name = "单位角色",dictType="dwjs",comboReadDict = true) + private Integer dwjs; + + @ApiModelProperty("统一社会信用代码/用户账号") + @Excel(name = "统一社会信用代码",required = true) + private String userName; + + @ApiModelProperty("是否关基单位") + @Excel(name="是否关基单位",dictType="gjdw",comboReadDict = true) + private Integer gjdw; + + @ApiModelProperty("日常运营负责部门") + private String rcyyfzbm; + + @ApiModelProperty("单位负责人姓名") + @Excel(name="单位负责人") + private String dwfzrxm; + + @ApiModelProperty("单位负责人联系方式") + @Excel(name="单位负责人联系方式") + private String dwfzrlxfs; + + @ApiModelProperty("单位负责人邮箱") + @Excel(name="单位负责人邮箱") + private String dwfzryx; + + @ApiModelProperty("单位负责人职务职称") + @Excel(name="单位负责人职务职称") + private String dwfzrzwzc; + + @ApiModelProperty("分管负责人姓名") + @Excel(name="分管负责人") + private String fgfzrxm; + + @ApiModelProperty("分管负责人联系方式") + @Excel(name="分管负责人联系方式") + private String fgfzrlxfs; + + @ApiModelProperty("分管负责人邮箱") + @Excel(name="分管负责人邮箱") + private String fgfzryx; + + @ApiModelProperty("分管负责人职务职称") + @Excel(name="分管负责人职务职称") + private String fgfzrzwzc; + + @ApiModelProperty("部门负责人姓名") + @Excel(name="部门负责人") + private String bmfzrxm; + + @ApiModelProperty("部门负责人联系方式") + @Excel(name="部门负责人联系方式") + private String bmfzrlxfs; + + @ApiModelProperty("部门负责人邮箱") + @Excel(name="部门负责人邮箱") + private String bmfzryx; + + @ApiModelProperty("部门负责人职务职称") + @Excel(name="部门负责人职务职称") + private String bmfzrzwzc; + + @ApiModelProperty("第一联系人姓名") + @Excel(name="第一联系人") + private String dylxrxm; + + @ApiModelProperty("第一联系人联系方式") + @Excel(name="第一联系人联系方式") + private String dylxrlxfs; + + @ApiModelProperty("第一联系人邮箱") + @Excel(name="第一联系人邮箱") + private String dylxryx; + + @ApiModelProperty("第一联系人职务职称") + @Excel(name="第一联系人职务职称") + private String dylxrzwzc; + + @ApiModelProperty("检查信息") + private String jcxx; + + @ApiModelProperty("官网") + @Excel(name = "官网") + private String gw; + + @ApiModelProperty("地图位置-经度") + @Excel(name = "地图位置-经度") + private String dtjd; + + @ApiModelProperty("地图位置-纬度") + @Excel(name = "地图位置-纬度") + private String dtwd; + + @ApiModelProperty("单位直属性质") + @Excel(name = "单位直属性质", dictType="dwzsxz",comboReadDict = true) + private Integer dwzsxz; + + /** + * 创建者 + */ + @ApiModelProperty("创建者") + @TableField(fill = FieldFill.INSERT) + private String createBy; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新者 + */ + @ApiModelProperty("更新者") + @TableField(fill = FieldFill.UPDATE) + private String updateBy; + + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") + @TableField(fill = FieldFill.UPDATE) + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + @ApiModelProperty("备注") + @Excel(name = "备注") + private String remark; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/request/UnitRequest.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/request/UnitRequest.java new file mode 100644 index 0000000..1eea4c4 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/request/UnitRequest.java @@ -0,0 +1,23 @@ +package com.ruoyi.common.core.domain.request; + +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 单位信息查询请求类 + * @author du + * @since 2024/11/13 16:52 + */ +@Data +public class UnitRequest { + + @ApiModelProperty("统一社会信用代码") + private String userName; + + @ApiModelProperty("单位名称") + private String nickName; + + @ApiModelProperty("单位类型,传字典数字") + private Integer dwlx; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 6882111..2e7e157 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -24,6 +24,8 @@ import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.exception.ServiceException; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.reflect.FieldUtils; @@ -415,6 +417,12 @@ public class ExcelUtil // 从map中得到对应列的field. Field field = (Field) entry.getValue()[0]; Excel attr = (Excel) entry.getValue()[1]; + boolean rq = attr.required(); + if(rq){ + if(StringUtils.isNull(val) || StringUtils.isEmpty(val.toString())) { + throw new ServiceException("第"+i+"行"+attr.name()+"单元格必填项未填写,请正确填写!"); + } + } // 取得类型,并根据对象类型设置值. Class fieldType = field.getType(); if (String.class == fieldType) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java index e30fe74..62877b5 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java @@ -6,6 +6,11 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import javax.sql.DataSource; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import org.apache.ibatis.io.VFS; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionFactoryBean; @@ -26,7 +31,7 @@ import com.ruoyi.common.utils.StringUtils; /** * Mybatis支持*匹配扫描包 - * + * * @author ruoyi */ @Configuration @@ -113,20 +118,27 @@ public class MyBatisConfig return resources.toArray(new Resource[resources.size()]); } - @Bean - public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception - { - String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage"); - String mapperLocations = env.getProperty("mybatis.mapperLocations"); - String configLocation = env.getProperty("mybatis.configLocation"); - typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage); - VFS.addImplClass(SpringBootVFS.class); - - final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); - sessionFactory.setDataSource(dataSource); - sessionFactory.setTypeAliasesPackage(typeAliasesPackage); - sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ","))); - sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation)); - return sessionFactory.getObject(); - } +// @Bean +// public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception +// { +// String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage"); +// String mapperLocations = env.getProperty("mybatis.mapperLocations"); +// String configLocation = env.getProperty("mybatis.configLocation"); +// typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage); +// VFS.addImplClass(SpringBootVFS.class); +// +// final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); +// sessionFactory.setDataSource(dataSource); +// sessionFactory.setTypeAliasesPackage(typeAliasesPackage); +// sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ","))); +// sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation)); +// return sessionFactory.getObject(); +// } +@Bean +public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); + return interceptor; +} } \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyMetaObjectHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyMetaObjectHandler.java new file mode 100644 index 0000000..a852b32 --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyMetaObjectHandler.java @@ -0,0 +1,62 @@ +package com.ruoyi.framework.config; + + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.Objects; + +/** + * 自动注入 + * + * @author wu + * @since 2023/5/4 10:16 + */ +@Component +public class MyMetaObjectHandler implements MetaObjectHandler { + + @Override + public void insertFill(MetaObject metaObject) { + // 获取当前登录用户 + + String userName = null; + Long userId = null; + try { + LoginUser loginUser = SecurityUtils.getLoginUser(); + userName = loginUser.getUser().getNickName(); + userId = SecurityUtils.getUserId(); + } catch (Exception ignored) { + } + if (!Objects.equals(userName, "")) { + this.strictInsertFill(metaObject, "createBy", String.class, userName); + } + if (userId != null) { + this.strictInsertFill(metaObject, "createId", Long.class, userId); + } + this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); + } + + @Override + public void updateFill(MetaObject metaObject) { + // 获取当前登录用户 + String userName = null; + Long userId = null; + try { + LoginUser loginUser = SecurityUtils.getLoginUser(); + userName = loginUser.getUser().getNickName(); + userId = SecurityUtils.getUserId(); + } catch (Exception ignored) { + } + if (userId != null) { + this.strictUpdateFill(metaObject, "updateId", Long.class, userId); + } + if (!Objects.equals(userName, "")) { + this.strictUpdateFill(metaObject, "updateBy", String.class, userName); + } + this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index b04beff..62ff071 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -115,7 +115,8 @@ public class SecurityConfig // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() - // 除上面外的所有请求全部需要鉴权认证 + .antMatchers("/system/user/**").permitAll() + // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated(); }) // 添加Logout filter diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index c86acea..2d263f8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -109,19 +109,19 @@ public interface SysUserMapper */ public SysUser checkUserNameUnique(String userName); - /** - * 校验手机号码是否唯一 - * - * @param phonenumber 手机号码 - * @return 结果 - */ - public SysUser checkPhoneUnique(String phonenumber); - - /** - * 校验email是否唯一 - * - * @param email 用户邮箱 - * @return 结果 - */ - public SysUser checkEmailUnique(String email); +// /** +// * 校验手机号码是否唯一 +// * +// * @param phonenumber 手机号码 +// * @return 结果 +// */ +// public SysUser checkPhoneUnique(String phonenumber); +// +// /** +// * 校验email是否唯一 +// * +// * @param email 用户邮箱 +// * @return 结果 +// */ +// public SysUser checkEmailUnique(String email); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UnitMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UnitMapper.java new file mode 100644 index 0000000..ba418e7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UnitMapper.java @@ -0,0 +1,24 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.entity.Unit; +import com.ruoyi.common.core.domain.request.UnitRequest; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 单位信息(unit_info)表数据层 + * @author du + * @since 2024/11/13 15:04 + */ +public interface UnitMapper extends BaseMapper { + + /** + * 根据条件查询所有单位列表 + * + * @param a 用户信息 + * @return 用户信息集合信息 + */ + List selectUnitList(@Param("req") UnitRequest a); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index e438b57..8672aa1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -74,21 +74,21 @@ public interface ISysUserService */ public boolean checkUserNameUnique(SysUser user); - /** - * 校验手机号码是否唯一 - * - * @param user 用户信息 - * @return 结果 - */ - public boolean checkPhoneUnique(SysUser user); - - /** - * 校验email是否唯一 - * - * @param user 用户信息 - * @return 结果 - */ - public boolean checkEmailUnique(SysUser user); +// /** +// * 校验手机号码是否唯一 +// * +// * @param user 用户信息 +// * @return 结果 +// */ +// public boolean checkPhoneUnique(SysUser user); +// +// /** +// * 校验email是否唯一 +// * +// * @param user 用户信息 +// * @return 结果 +// */ +// public boolean checkEmailUnique(SysUser user); /** * 校验用户是否允许操作 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/UnitService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/UnitService.java new file mode 100644 index 0000000..fb67077 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/UnitService.java @@ -0,0 +1,24 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.entity.Unit; +import com.ruoyi.common.core.domain.request.UnitRequest; + +import java.util.List; + +/** + * 单位信息(unit_info)表业务层 + * @author du + * @since 2024/11/13 15:02 + */ +public interface UnitService extends IService { + + /** + * 根据条件查询所有单位列表 + * + * @param unit 用户信息 + * @return 用户信息集合信息 + */ + List selectUnitList(UnitRequest unit); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 3f4dba2..a0ce61d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -180,41 +180,41 @@ public class SysUserServiceImpl implements ISysUserService return UserConstants.UNIQUE; } - /** - * 校验手机号码是否唯一 - * - * @param user 用户信息 - * @return - */ - @Override - public boolean checkPhoneUnique(SysUser user) - { - Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); - SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; - } - - /** - * 校验email是否唯一 - * - * @param user 用户信息 - * @return - */ - @Override - public boolean checkEmailUnique(SysUser user) - { - Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); - SysUser info = userMapper.checkEmailUnique(user.getEmail()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; - } +// /** +// * 校验手机号码是否唯一 +// * +// * @param user 用户信息 +// * @return +// */ +// @Override +// public boolean checkPhoneUnique(SysUser user) +// { +// Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); +// SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); +// if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) +// { +// return UserConstants.NOT_UNIQUE; +// } +// return UserConstants.UNIQUE; +// } +// +// /** +// * 校验email是否唯一 +// * +// * @param user 用户信息 +// * @return +// */ +// @Override +// public boolean checkEmailUnique(SysUser user) +// { +// Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); +// SysUser info = userMapper.checkEmailUnique(user.getEmail()); +// if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) +// { +// return UserConstants.NOT_UNIQUE; +// } +// return UserConstants.UNIQUE; +// } /** * 校验用户是否允许操作 @@ -505,7 +505,7 @@ public class SysUserServiceImpl implements ISysUserService deptService.checkDeptDataScope(user.getDeptId()); String password = configService.selectConfigByKey("sys.user.initPassword"); user.setPassword(SecurityUtils.encryptPassword(password)); - user.setCreateBy(operName); +// user.setCreateBy(operName); userMapper.insertUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); @@ -517,7 +517,7 @@ public class SysUserServiceImpl implements ISysUserService checkUserDataScope(u.getUserId()); deptService.checkDeptDataScope(user.getDeptId()); user.setUserId(u.getUserId()); - user.setUpdateBy(operName); +// user.setUpdateBy(operName); userMapper.updateUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 更新成功"); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UnitServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UnitServiceImpl.java new file mode 100644 index 0000000..1483781 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UnitServiceImpl.java @@ -0,0 +1,31 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.entity.Unit; +import com.ruoyi.common.core.domain.request.UnitRequest; +import com.ruoyi.system.mapper.UnitMapper; +import com.ruoyi.system.service.UnitService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 单位信息(unit_info)表业务处理层 + * @author du + * @since 2024/11/13 15:02 + */ +@Service +public class UnitServiceImpl extends ServiceImpl implements UnitService { + + + /** + * 根据条件查询所有单位列表 + * + * @param unit 用户信息 + * @return 用户信息集合信息 + */ + @Override + public List selectUnitList(UnitRequest unit) { + return baseMapper.selectUnitList(unit); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 5814cd3..0414553 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -9,9 +9,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - + + + @@ -23,10 +23,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + - + + + @@ -47,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, + select u.user_id, u.dept_id, u.user_name, u.nick_name, u.avatar, u.password, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status from sys_user u @@ -55,11 +63,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join sys_user_role ur on u.user_id = ur.user_id left join sys_role r on r.role_id = ur.role_id - + @@ -134,13 +134,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1 - - - + + + + + + + insert into sys_user( @@ -148,10 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" dept_id, user_name, nick_name, - email, avatar, - phonenumber, - sex, password, status, create_by, @@ -162,10 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{deptId}, #{userName}, #{nickName}, - #{email}, #{avatar}, - #{phonenumber}, - #{sex}, #{password}, #{status}, #{createBy}, @@ -180,9 +174,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" dept_id = #{deptId}, user_name = #{userName}, nick_name = #{nickName}, - email = #{email}, - phonenumber = #{phonenumber}, - sex = #{sex}, avatar = #{avatar}, password = #{password}, status = #{status}, diff --git a/ruoyi-system/src/main/resources/mapper/system/UnitMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UnitMapper.xml new file mode 100644 index 0000000..ca5ba26 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/UnitMapper.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file