六位验证码生成方式重写,BUG冲突解决

This commit is contained in:
syruan 2023-12-15 21:04:09 +08:00
parent bff82919e2
commit 2998d5d53a
17 changed files with 404 additions and 112 deletions

View File

@ -19,6 +19,7 @@ import lombok.Data;
@ApiModel(description = "领料任务详细表lease_apply_details")
@Data
public class LeaseApplyDetails implements Serializable {
@ApiModelProperty(value = "")
private Integer id;

View File

@ -50,6 +50,9 @@ public class MaType extends BaseEntity {
@ApiModelProperty(value = "租赁单价")
private String leasePrice;
@ApiModelProperty(value = "外部价格")
private String rentPrice;
/** 原价 */
@ApiModelProperty(value = "原价")
private String buyPrice;
@ -120,7 +123,7 @@ public class MaType extends BaseEntity {
/** 图片路径 */
@ApiModelProperty(value = "图片路径")
private String photoUrl;
private String photoUrl = "https://zlpt-1259760603.cos.ap-nanjing.myqcloud.com/zhcc/bg2.jpg";
/** 文档名称 */
@ApiModelProperty(value = "文档名称")
@ -233,6 +236,14 @@ public class MaType extends BaseEntity {
return payPrice;
}
public String getRentPrice() {
return rentPrice;
}
public void setRentPrice(String rentPrice) {
this.rentPrice = rentPrice;
}
public void setPayPrice(String payPrice) {
this.payPrice = payPrice;
}

View File

@ -42,7 +42,7 @@ public interface RemoteUserService
/**
* 发送短信
*/
@PostMapping("/sms/sendCode")
@PostMapping("/sms/codeLogin")
public R<Boolean> sendCode(@RequestParam("phone") String phone);
/**

View File

@ -1,7 +1,9 @@
package com.bonus.sgzb.auth.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.bonus.sgzb.system.api.RemoteUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.bonus.sgzb.auth.form.LoginBody;
@ -15,6 +17,8 @@ import com.bonus.sgzb.common.security.service.TokenService;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.system.api.model.LoginUser;
import java.util.Map;
/**
* token 控制
*
@ -29,6 +33,9 @@ public class TokenController
@Autowired
private SysLoginService sysLoginService;
@Resource
private RemoteUserService remoteUserService;
@PostMapping("login")
public R<?> login(@RequestBody LoginBody form) {
// 用户登录
@ -39,28 +46,27 @@ public class TokenController
@PostMapping("sendCode")
public R<?> sendCode(@RequestBody LoginBody form) {
// 用户登录
LoginUser userInfo = sysLoginService.loginCode(form.getPhone(), form.getCode());
// 获取登录token
return R.ok(tokenService.createToken(userInfo));
R<Boolean> sendState = remoteUserService.sendCode(form.getPhone());
return sendState;
}
@PostMapping("checkCode")
public R<?> checkCode(@RequestBody LoginBody form) {
// 校验验证码
boolean result = sysLoginService.checkCode(form.getPhone(), form.getCode());
if (result) {
return R.ok(null, "验证码正确");
LoginUser loginUser = sysLoginService.loginCode(form.getPhone(), form.getCode());
if (StringUtils.isNotNull(loginUser)) {
// 创建token
Map<String, Object> tokenMap = tokenService.createToken(loginUser);
return R.ok(loginUser);
} else {
return R.fail(null, "验证码错误");
}
return R.fail("短信验证码错误");
}
@DeleteMapping("logout")
public R<?> logout(HttpServletRequest request)
{
public R<?> logout(HttpServletRequest request) {
String token = SecurityUtils.getToken(request);
if (StringUtils.isNotEmpty(token))
{
if (StringUtils.isNotEmpty(token)) {
String username = JwtUtils.getUserName(token);
// 删除用户缓存记录
AuthUtil.logoutByToken(token);
@ -71,11 +77,9 @@ public class TokenController
}
@PostMapping("refresh")
public R<?> refresh(HttpServletRequest request)
{
public R<?> refresh(HttpServletRequest request) {
LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser))
{
if (StringUtils.isNotNull(loginUser)) {
// 刷新令牌有效期
tokenService.refreshToken(loginUser);
return R.ok();
@ -84,8 +88,7 @@ public class TokenController
}
@PostMapping("register")
public R<?> register(@RequestBody RegisterBody registerBody)
{
public R<?> register(@RequestBody RegisterBody registerBody) {
// 用户注册
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
return R.ok();

View File

@ -70,26 +70,22 @@ public class SysLoginService
// 查询用户信息
R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
{
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
throw new ServiceException("登录用户:" + username + " 不存在");
}
if (R.FAIL == userResult.getCode())
{
if (R.FAIL == userResult.getCode()) {
throw new ServiceException(userResult.getMsg());
}
LoginUser userInfo = userResult.getData();
SysUser user = userResult.getData().getSysUser();
if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
{
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
{
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
}

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.base.controller;
import com.bonus.sgzb.base.api.domain.MaMachine;
import com.bonus.sgzb.base.mapper.MaMachineMapper;
import com.bonus.sgzb.base.service.MaMachineService;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
@ -26,18 +27,29 @@ public class MaMachineController extends BaseController {
@Autowired
private MaMachineService maMachineService;
@Autowired
private MaMachineMapper maMachineMapper;
@Log(title = "根据条件查询机具设备", businessType = BusinessType.QUERY)
@GetMapping("/getMaMachineList")
public AjaxResult getMaMachineList(MaMachine maMachine) {
List<MaMachine> list = maMachineMapper.getMaMachineList(maMachine);
return success(list);
}
/**
* 根据条件进行查询机具设备管理
*/
@ApiOperation(value = "根据条件进行查询机具设备管理")
@GetMapping("/getMachine")
public TableDataInfo getMaMachine(MaMachine maMachine)
{
public TableDataInfo getMaMachine(MaMachine maMachine) {
startPage();
List<MaMachine> list = maMachineService.getMaMachine(maMachine);
return getDataTable(list);
}
/**
* 新增机具设备管理
*/

View File

@ -1,9 +1,13 @@
package com.bonus.sgzb.base.controller;
import com.bonus.sgzb.base.api.domain.MaType;
import com.bonus.sgzb.base.domain.vo.TreeSelect;
import com.bonus.sgzb.base.mapper.MaTypeMapper;
import com.bonus.sgzb.base.service.ITypeService;
import com.bonus.sgzb.common.core.constant.HttpStatus;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
@ -11,7 +15,10 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 工机具类型管理控制层
@ -24,6 +31,9 @@ public class MaTypeController extends BaseController {
@Autowired
private ITypeService iTypeService;
@Resource
private MaTypeMapper maTypeMapper;
/**
* 根据类型名称查询类型
@ -31,54 +41,132 @@ public class MaTypeController extends BaseController {
*/
@ApiOperation(value = "根据类型名称查询类型")
@GetMapping("/getMaTypeList")
public AjaxResult getMaTypeList(String typeName){
return AjaxResult.success(iTypeService.getMaTypeList(typeName));
public AjaxResult getMaTypeList(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId){
List<TreeSelect> maTypeList = iTypeService.getMaTypeList(typeName, parentId);
return AjaxResult.success(maTypeList);
}
@ApiOperation(value = "工器具类型")
@GetMapping("/equipmentType")
public AjaxResult equipmentType(@RequestParam(required = false) Long typeId,
@RequestParam(required = false) String typeName){
List<MaType> listByMaType = iTypeService.getEquipmentType(typeId,typeName);
return success(listByMaType);
@ApiOperation(value = "获取机具设备的具体规格")
@GetMapping(value = "/selectMaTypeTreeByLevel")
public AjaxResult selectMaTypeTreeByLevel(@RequestParam(value = "typeId") String typeId) {
List<MaType> maTypeList = maTypeMapper.selectMaTypeTreeByLevel(typeId);
return AjaxResult.success(maTypeList);
}
/**
* 获取规格层级为3的设备列表
* @return 结果
*/
@ApiOperation(value = "获取规格层级的设备列表")
@GetMapping("/selectMaTypeListByLevelIndex")
public AjaxResult selectMaTypeListByLevelIndex(@RequestParam(value = "level", required = false) Integer level, @RequestParam(value = "type") Integer type, @RequestParam(value = "parentId", required = false) Integer parentId){
if (type == null) { return AjaxResult.error("参数错误,类型不能为空"); }
if (type == 0) {
// 查询全部机具类型
if (level == 0 || level == 1) {
// 查询全部等级一级
List<TreeSelect> treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null));
return AjaxResult.success(treeSelectList);
}
if (level == 2) {
// 查询二级
return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString()));
// List<TreeSelect> treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString()));
//
// // 遍历剔除不符合的三级规格
// for (TreeSelect treeSelect : treeSelectList) {
// List<TreeSelect> children = treeSelect.getChildren();
// if (children != null) {
// for (TreeSelect child : children) {
// List<TreeSelect> grandChildren = child.getChildren();
// if (grandChildren!= null) {
// grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId)));
// }
// }
// }
// }
// return AjaxResult.success(treeSelectList);
}
}
if (type == 1) {
// 查询施工机具
List<TreeSelect> treeSelectList;
if (level != 2) {
treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null));
return AjaxResult.success(treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 1L)).collect(Collectors.toList()));
} else {
return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString()));
// treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString()));
// // 先过滤出施工机具
// treeSelectList = treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 1L)).collect(Collectors.toList());
// // 再过滤出不符合的三级规格
// if (!treeSelectList.isEmpty()) {
// for (TreeSelect treeSelect : treeSelectList) {
// List<TreeSelect> children = treeSelect.getChildren();
// if (children != null) {
// for (TreeSelect child : children) {
// List<TreeSelect> grandChildren = child.getChildren();
// if (grandChildren != null) {
// grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId)));
// }
//
// }
// }
// }
// }
// return AjaxResult.success(treeSelectList);
}
}
if (type == 2) {
List<TreeSelect> treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null));
treeSelectList = treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 2L)).collect(Collectors.toList());
// 查询安全工器具
if (level == 2) {
return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString()));
// if (!treeSelectList.isEmpty()) {
// for (TreeSelect treeSelect : treeSelectList) {
// List<TreeSelect> children = treeSelect.getChildren();
// if (children != null) {
// for (TreeSelect child : children) {
// List<TreeSelect> grandChildren = child.getChildren();
// if (grandChildren != null) {
// grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId)));
// }
// }
// }
// }
// }
}
return AjaxResult.success(treeSelectList);
}
return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(null));
}
/**
* 根据左列表类型id查询右表格
* @param typeId
* @return
*/
@ApiOperation(value = "根据左列表类型id查询右表格")
@GetMapping("/getListByMaType")
public AjaxResult getListByMaType(@RequestParam(required = false) Long typeId,
@RequestParam(required = false) String typeName){
List<MaType> listByMaType = iTypeService.getListByParentId(typeId,typeName);
return success(listByMaType);
public TableDataInfo getListByMaType(@RequestParam(required = false) Long typeId,
@RequestParam(required = false) String typeName,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) Integer pageNum){
if(typeId==null){
return null;
}
List<MaType> listByMaType = iTypeService.getListByMaType(typeId, typeName);
TableDataInfo rspData = new TableDataInfo();
rspData.setTotal(listByMaType.size());
rspData.setCode(HttpStatus.SUCCESS);
listByMaType = listByMaType.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
rspData.setRows(listByMaType);
rspData.setMsg("查询成功");
// /**
// * 根据左列表类型id查询右表格
// * @param typeId
// * @return
// */
// @ApiOperation(value = "根据左列表类型id查询右表格")
// @GetMapping("/getListByMaType")
// public TableDataInfo getListByMaType(@RequestParam(required = false) Long typeId,
// @RequestParam(required = false) String typeName,
// @RequestParam(required = false) Integer pageSize,
// @RequestParam(required = false) Integer pageNum){
// if(typeId==null){
// return null;
// }
// List<MaType> listByMaType = iTypeService.getListByMaType(typeId, typeName);
// TableDataInfo rspData = new TableDataInfo();
// rspData.setTotal(listByMaType.size());
// rspData.setCode(HttpStatus.SUCCESS);
// listByMaType = listByMaType.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
// rspData.setRows(listByMaType);
// rspData.setMsg("查询成功");
//
// return rspData;
// }
return rspData;
}
/**
* 获取机具类型管理ma_type详细信息

View File

@ -16,6 +16,9 @@ public class MaHouse extends BaseEntity {
@ApiModelProperty(value= "仓库ID")
private Long houseId;
@ApiModelProperty(value= "等级")
private Integer level;
/** 工程项目名称 */
@ApiModelProperty(value="工程项目名称")
private String houseName;
@ -75,6 +78,14 @@ public class MaHouse extends BaseEntity {
/** 子部门 */
private List<MaHouse> children = new ArrayList<MaHouse>();
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Long getHouseId() {
return houseId;
}

View File

@ -23,6 +23,10 @@ public class TreeSelect implements Serializable
/** 节点名称 */
private String label;
private Integer level;
private Long parentId;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
@ -34,6 +38,7 @@ public class TreeSelect implements Serializable
public TreeSelect(MaHouse maHouse)
{
this.level = maHouse.getLevel();
this.id = maHouse.getDeptId();
this.label = maHouse.getHouseName();
this.children = maHouse.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
@ -41,11 +46,23 @@ public class TreeSelect implements Serializable
public TreeSelect(MaType maType)
{
this.parentId = maType.getParentId();
this.level = Integer.valueOf(maType.getLevel());
this.id = maType.getTypeId();
this.label = maType.getTypeName();
this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Long getId()
{
return id;
@ -56,6 +73,14 @@ public class TreeSelect implements Serializable
this.id = id;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getLabel()
{
return label;

View File

@ -1,12 +1,16 @@
package com.bonus.sgzb.base.mapper;
import com.bonus.sgzb.base.api.domain.MaMachine;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface MaMachineMapper {
public List<MaMachine> getMaMachine(MaMachine maMachine);
public List<MaMachine> getMaMachineList(MaMachine maMachine);
public int maMachineAdd(MaMachine maMachine);
public int remove(Long[] maIds);

View File

@ -1,9 +1,10 @@
package com.bonus.sgzb.base.mapper;
import com.bonus.sgzb.base.domain.MaPropSet;
import com.bonus.sgzb.base.api.domain.MaType;
import com.bonus.sgzb.base.domain.MaPropSet;
import com.bonus.sgzb.base.domain.MaTypeKeeper;
import com.bonus.sgzb.base.domain.MaTypeRepair;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -13,9 +14,9 @@ import java.util.List;
*
* @author ruoyi
*/
@Mapper
public interface MaTypeMapper {
List<MaType> selectMaTypeList(String typeName);
/**
@ -65,8 +66,12 @@ public interface MaTypeMapper {
MaType selectTypeByTypeId(long typeId);
List<MaType> selectMaTypeTree();
List<MaType> selectMaTypeTree(String parentId);
List<MaType> getListByParentId(@Param("typeId") Long typeId, @Param("typeName") String typeName);
List<MaType> getListByParentId(@org.apache.ibatis.annotations.Param("typeId") Long typeId, @Param("typeName") String typeName);
List<MaType> selectMaTypeTreeByLevel(String id);
List<MaType> selectMaTypeListByLevelNotFour(String parentId);
}

View File

@ -10,7 +10,7 @@ import java.util.List;
*/
public interface ITypeService {
List<TreeSelect> getMaTypeList(String typeName);
List<TreeSelect> getMaTypeList(String typeName, String parentId);
List<MaType> getListByMaType(Long typeId,String typeName);

View File

@ -150,10 +150,11 @@ public class MaTypeServiceImpl implements ITypeService {
}
@Override
public List<TreeSelect> getMaTypeList(String typeName) {
List<MaType> maTypes = maTypeMapper.selectMaTypeTree();
public List<TreeSelect> getMaTypeList(String typeName, String parentId) {
List<MaType> maTypes = maTypeMapper.selectMaTypeTree(parentId);
List<TreeSelect> treeSelectList = buildDeptTreeSelect(maTypes);
//如果没有查询到那么返回空
return buildDeptTreeSelect(maTypes);
return treeSelectList;
}
/**

View File

@ -116,6 +116,82 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="getMaMachineList" parameterType="com.bonus.sgzb.base.api.domain.MaMachine" resultMap="MaMachineResult">
select ma_id, type_id, ma_code, pre_code, ma_status, qr_code, buy_price, ma_vender, out_fac_time, out_fac_code,
assets_code, check_man, this_check_time, next_check_time, gps_code, rfid_code, erp_code, transfer_code,
in_out_num, buy_task, own_house ,company_id
from ma_machine
<where>
<if test="maId != null and maId != ''">
AND ma_id = #{maId}
</if>
<if test="typeId != null and typeId != ''">
AND type_id = #{typeId}
</if>
<if test="maCode != null and maCode != ''">
AND ma_code = #{maCode}
</if>
<if test="preCode != null and preCode != ''">
AND pre_code = #{preCode}
</if>
<if test="maStatus != null and maStatus != ''">
and ma_status = #{maStatus}
</if>
<if test="qrCode != null and qrCode != ''">
and qr_code = #{qrCode}
</if>
<if test="buyPrice != null and buyPrice != ''">
and buy_price = #{buyPrice}
</if>
<if test="maVender != null and maVender != ''">
and ma_vender = #{maVender}
</if>
<if test="outFacTime != null and outFacTime != ''">
and out_fac_time = #{outFacTime}
</if>
<if test="outFacCode != null and outFacCode != ''">
and out_fac_code = #{outFacCode}
</if>
<if test="assetsCode != null and assetsCode != ''">
and assets_code = #{assetsCode}
</if>
<if test="remark != null and remark != ''">
and check_man = #{remark}
</if>
<if test="thisCheckTime != null and thisCheckTime != ''">
and this_check_time = #{thisCheckTime}
</if>
<if test="nextCheckTime != null and nextCheckTime != ''">
and next_check_time = #{nextCheckTime}
</if>
<if test="gpsCode != null and gpsCode != ''">
and gps_code = #{gpsCode}
</if>
<if test="rfidCode != null and rfidCode != ''">
and rfid_code = #{rfidCode}
</if>
<if test="erpCode != null and erpCode != ''">
and erp_code = #{erpCode}
</if>
<if test="transferCode != null and transferCode != ''">
and transfer_code = #{transferCode}
</if>
<if test="inOutNum != null and inOutNum != ''">
and in_out_num = #{inOutNum}
</if>
<if test="buyTask != null and buyTask != ''">
and buy_task = #{buyTask}
</if>
<if test="ownHouse != null and ownHouse != ''">
and own_house = #{ownHouse}
</if>
<if test="companyId != null and companyId != ''">
and company_id = #{companyId}
</if>
</where>
</select>
<insert id="maMachineAdd" parameterType="com.bonus.sgzb.base.api.domain.MaMachine">
insert into ma_machine (
<if test="typeId != null and typeId != '' ">type_id,</if>
@ -203,5 +279,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMaMachine"/>
where ma_id = #{maId}
</select>
</mapper>

View File

@ -10,9 +10,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" />
<result property="num" column="num" />
<result property="unitId" column="unit_id" />
<result property="unitName" column="unit_name" />
<result property="manageType" column="manage_type" />
<result property="leasePrice" column="lease_price" />
<result property="rentPrice" column="rent_price" />
<result property="buyPrice" column="buy_price" />
<result property="payPrice" column="pay_price" />
<result property="level" column="level" />
@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectMaTypeVo">
select type_id, type_name, parent_id, status, num, unit_id, unit_name, manage_type, lease_price, buy_price, pay_price, level, rated_load, test_load, holding_time, warn_num, del_flag, create_by, create_time, remark, company_id
select type_id, type_name, parent_id, status, num, unit_id, manage_type, lease_price, buy_price, pay_price, level, rated_load, test_load, holding_time, warn_num, del_flag, create_by, create_time, remark, company_id
from ma_type
</sql>
@ -44,7 +44,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status,</if>
<if test="num != null">num,</if>
<if test="unitId != null">unit_id,</if>
<if test="unitName != null">unit_name,</if>
<if test="manageType != null">manage_type,</if>
<if test="leasePrice != null">lease_price,</if>
<if test="buyPrice != null">buy_price,</if>
@ -70,7 +69,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if>
<if test="num != null">#{num},</if>
<if test="unitId != null">#{unitId},</if>
<if test="unitName != null">#{unitName},</if>
<if test="manageType != null">#{manageType},</if>
<if test="leasePrice != null">#{leasePrice},</if>
<if test="buyPrice != null">#{buyPrice},</if>
@ -124,7 +122,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status = #{status},</if>
<if test="num != null">num = #{num},</if>
<if test="unitId != null">unit_id = #{unitId},</if>
<if test="unitName != null">unit_name = #{unitName},</if>
<if test="manageType != null">manage_type = #{manageType},</if>
<if test="leasePrice != null">lease_price = #{leasePrice},</if>
<if test="buyPrice != null">buy_price = #{buyPrice},</if>
@ -152,8 +149,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectMaTypeList" parameterType="String" resultMap="MaTypeResult">
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.unit_name, m.manage_type,
m.lease_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type,
m.lease_price, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
su.user_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
@ -165,10 +162,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join (select * from ma_type_file where file_type = '2') mtf2 on m.type_id = mtf2.type_id
left join ma_type_keeper mtk on mtf.type_id = mtk.type_id
left join sys_user su on mtk.user_id = su.user_id
where m.status = '0'
<where>
m.status = '0'
<if test="typeName != null and typeName !=''">
AND type_name like concat('%',#{typeName},'%')
</if>
</where>
</select>
<select id="selectTypeList" resultType="com.bonus.sgzb.base.api.domain.MaType">
@ -251,8 +250,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="selectMaTypeByTypeId" resultMap="MaTypeResult">
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.unit_name, m.manage_type,
m.lease_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type,
m.lease_price, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
su.user_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
@ -284,13 +283,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where type_id = #{typeId}
</select>
<select id="selectMaTypeTree" resultMap="MaTypeResult">
<select id="selectMaTypeTree" resultMap="MaTypeResult" parameterType="java.lang.String">
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type,
m.lease_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.lease_price, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id
from ma_type m
WHERE level != 4 and m.status = '0'
<where>
level != 4 and m.status = '0'
</where>
</select>
<select id="getListByParentId" resultMap="MaTypeResult">
@ -312,4 +313,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND type_name like concat('%',#{typeName},'%')
</if>
</select>
<select id="selectMaTypeTreeByLevel" resultMap="MaTypeResult" parameterType="java.lang.String">
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type,
m.lease_price, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id
from ma_type m
<where>
m.level = '4' and m.parent_id = #{id,jdbcType=VARCHAR}
</where>
</select>
<select id="selectMaTypeListByLevelNotFour" resultMap="MaTypeResult">
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type,
m.lease_price, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id
from ma_type m
<where>
m.level != 4
<if test="_parameter!= null and _parameter != ''">
and m.parent_id = #{parentId}
</if>
</where>
</select>
</mapper>

View File

@ -130,8 +130,7 @@ public class SysUserController extends BaseController
*/
@InnerAuth
@GetMapping("/info/{username}")
public R<LoginUser> info(@PathVariable("username") String username)
{
public R<LoginUser> info(@PathVariable("username") String username) {
SysUser sysUser = userService.selectUserByUserName(username);
if (StringUtils.isNull(sysUser))
{

View File

@ -2,6 +2,7 @@ package com.bonus.sgzb.system.service.impl;
import cn.hutool.http.HttpRequest;
import com.alibaba.druid.util.StringUtils;
import com.bonus.sgzb.common.core.constant.UserConstants;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.redis.service.RedisService;
@ -27,9 +28,18 @@ public class SysSmsServiceImpl implements ISysSmsService {
@Resource
private RedisService redisService;
// 短信url
private static final String url = "http://api.ktsms.cn/sms_token?ddtkey=bonus&secretkey=KtyBns@Admin2023!";
@Override
public AjaxResult sendSms(String phone, String msg) {
return sendCodeByPhone(phone, msg);
if (phone == null || StringUtils.isEmpty(msg)) {
return AjaxResult.error("手机号码或短信内容不能为空");
}
if (phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
return AjaxResult.error("手机号格式不正确");
}
return sendMsgByPhone(phone, msg);
}
@Override
@ -39,6 +49,32 @@ public class SysSmsServiceImpl implements ISysSmsService {
}
/**
* 发送消息msg到手机
* @param phone 手机号码
* @return AjaxResult对象
*/
private AjaxResult sendMsgByPhone(String phone, String msg) {
// 校验手机号码
if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
return AjaxResult.error("手机号码不正确");
}
// 发送短信
try {
String url = "http://106.ihuyi.com/webservice/sms.php?method=Submit";
String content = url + "&mobile=" + phone + "&content=【智慧仓储】" + msg + "";
String body = HttpRequest.post(content).execute(false).body();
System.out.println("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body);
if (body == null || !body.contains("ok")) {
return AjaxResult.error("发送失败");
}
return success("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body);
} catch (Exception e) {
return AjaxResult.error("发送失败:" + e.getMessage());
}
}
/**
* 发送验证码到手机
* @param phone 手机号码
@ -46,21 +82,20 @@ public class SysSmsServiceImpl implements ISysSmsService {
*/
private AjaxResult sendCodeByPhone(String phone, String msg) {
// 校验手机号码
if (phone == null || phone.length() != 11) {
return AjaxResult.error("手机号不正确");
if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
return AjaxResult.error("手机号格式错误请输入11位数字号");
}
String code = getSixBitCode();
// 校验验证码
if (code.length() != 6) {
return AjaxResult.error("验证码格式不正确");
if (code.length() != UserConstants.CODE_MIN_LENGTH_LOGIN) {
return AjaxResult.error("验证码格式不正确,生成错误!请联系后台管理员");
}
// 发送短信
try {
String url = "http://api.ktsms.cn/sms_token?ddtkey=bonus&secretkey=KtyBns@Admin2023!";
String content = url + "&mobile=" + phone + "&content=【智慧仓储】您正在进行短信验证,验证码:" + code + "请在5分钟内完成验证。";
String body = HttpRequest.post(content).execute(false).body();
System.out.println("发送短信:" + phone + ",验证码:" + code + ",返回结果:" + body);
if (body == null || !body.contains("success")) {
if (body == null || !body.contains("ok")) {
return AjaxResult.error("发送失败");
}
// 存储验证码至Redis中键值为code_15588886157 , 有效期5时间颗粒度为MINUTES:分钟
@ -94,17 +129,17 @@ public class SysSmsServiceImpl implements ISysSmsService {
}
}
public static void main(String[] args) {
System.out.println(getSixBitCode());
}
/**
* 随机生成6位验证码
*/
private String getSixBitCode() {
private static String getSixBitCode() {
//随机数
StringBuilder sb = new StringBuilder();
Random rand = new Random();
for (int i = 0; i < 6; i++) {
sb.append(rand.nextInt(10));
}
return sb.toString();
Random random = new Random();
return String.valueOf(random.nextInt(900000) + 100000);
}