Commit 18d1302e authored by liaoanyuan's avatar liaoanyuan

增加员工管理相应功能

parent 633d57e4
package cn.wisenergy.mapper;
import cn.wisenergy.model.app.Banner;
import cn.wisenergy.model.app.Staff;
import cn.wisenergy.model.dto.StaffDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface StaffMapper extends BaseMapper<Banner> {
/**
* 禁用员工账号
*
* @param staffId 用户id
* @return true 成功 false 失败
*/
int delete(@Param("id") Integer staffId);
/**
* 查询员工信息集合
* @param map 查询信息
* @return 员工信息集合
*/
List<StaffDto> getStaffList(Map<String, Object> map);
/**
* 编辑员工信息
* @param staff 需要编辑的信息
* @return true:成功 false:失败
*/
int editStaff(Staff staff);
/**
* 添加员工信息
* @param staff 需要添加的员工信息
* @return true: 成功 false:失败
*/
int addStaff(Staff staff);
/**
* 查询数据条数
* @param map 查询参数
* @return 数据条数
*/
int getUserNumbers(Map<String, Object> map);
}
......@@ -15,7 +15,7 @@ import java.util.Map;
* @ Author : 86187
* @ Date : 2021/1/6 15:32
*/
@Mapper
public interface UsersMapper extends BaseMapper<User> {
/**
* 添加
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.mapper.StaffMapper">
<resultMap id="staffMap" type="cn.wisenergy.model.app.Staff">
<id column="id" property="id"></id>
<result column="staff_name" property="staffName"/>
<result column="login_name" property="loginName"/>
<result column="password" property="password"/>
<result column="phone" property="phone"/>
<result column="is_delete" property="isDelete"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="table">
staff
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
staff_name,login_name,password, phone,is_delete,create_time,update_time
</sql>
<sql id="vals">
#{staffName},#{loginName},#{password},#{phone},
#{isDelete},now(),now()
</sql>
<sql id="updateCondition">
<if test="staffName != null">staff_name = #{staffName},</if>
<if test="loginName !=null">login_name = #{loginName},</if>
<if test="password != null">password =#{password},</if>
<if test="phone != null">phone =#{phone},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
update_time =now()
</sql>
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="staffName != null">and staff_name = #{staffName}</if>
<if test="loginName !=null">and login_name = #{login_name}</if>
<if test="password != null">and password =#{password}</if>
<if test="phone != null">and phone =#{phone}</if>
<if test="isDelete != null">and is_delete = #{isDelete}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql>
<insert id="addStaff" parameterType="cn.wisenergy.model.app.Staff">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<update id="editStaff" parameterType="cn.wisenergy.model.app.Staff">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<select id="getStaffList" resultMap="staffMap" parameterType="map">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
is_delete=0
<if test="staffName != null">and staff_name like ('%' #{staffName} '%')</if>
<if test="phone != null">and phone like ('%' #{phone} '%')</if>
order by create_time desc
<if test="pageNo != null">
limit #{pageNo},#{pageSize}
</if>
</where>
</select>
<update id="delete" parameterType="int">
UPDATE
<include refid="table"/>
<set>
is_delete = 1
</set>
<where>
id = #{id}
</where>
</update>
<select id="getUserNumbers" resultType="java.lang.Integer">
SELECT COUNT(id)
FROM
<include refid="table"/>
<where>
is_delete=0
<if test="staffName != null">and staff_name like ('%' #{staffName} '%')</if>
<if test="phone != null">and phone like ('%' #{phone} '%')</if>
</where>
</select>
</mapper>
\ No newline at end of file
package cn.wisenergy.model.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
@ApiModel(value = "Staff")
public class Staff implements Serializable {
private static final long serialVersionUID = 4095937153880920505L;
/**
* 主键id
*/
@ApiModelProperty(name = "id", value = "员工主键id")
private Integer id;
/**
* 员工名称
*/
@ApiModelProperty(name = "staffName",value = "员工名字")
private String staffName;
/**
* 员工登录名
*/
@ApiModelProperty(name = "loginName",value = "员工登录名")
private String loginName;
/**
* 登录密码
*/
@ApiModelProperty(name = "password",value = "密码")
private String password;
/**
* 员工电话号码
*/
@ApiModelProperty(name = "phone",value = "电话号码")
private String phone;
/**
* 是否删除
*/
@ApiModelProperty(name = "isDelete", value = "是否删除 0:正常 1:删除")
private Integer isDelete;
/**
* 创建时间
*/
@ApiModelProperty(name = "createTime", value = "创建时间")
private Date createTime;
/**
* 修改时间
*/
@ApiModelProperty(name = "updateTime", value = "修改时间")
private Date updateTime;
}
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
public class StaffDto implements Serializable {
private static final long serialVersionUID = -7701107348928870362L;
/**
* 主键id
*/
@ApiModelProperty(name = "id", value = "员工主键id")
private Integer id;
/**
* 员工名称
*/
@ApiModelProperty(name = "staffName",value = "员工名字")
private String staffName;
/**
* 员工电话号码
*/
@ApiModelProperty(name = "phone",value = "电话号码")
private String phone;
}
......@@ -41,7 +41,7 @@ public class UserCommitDto implements Serializable {
/**
* 性别
*/
@ApiModelProperty(value = "学校", name = "school")
@ApiModelProperty(value = "性别", name = "sex")
private Integer sex;
/**
......
package cn.wisenergy.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("QueryVo")
public class QueryVo implements Serializable {
private static final long serialVersionUID = -7817033236623876957L;
/**
* 起始页
*/
@ApiModelProperty(value = "起始页", name = "pageNo")
private Integer pageNo;
/**
* 页大小
*/
@ApiModelProperty(value = "页大小", name = "pageSize")
private Integer pageSize;
/**
* 员工名称
*/
@ApiModelProperty(value= "员工名" ,name="staffName")
private String staffName;
/**
* 电话号码
*/
@ApiModelProperty(name = "phone",value = "手机号")
private String phone;
}
package cn.wisenergy.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("StaffVo")
public class StaffVo implements Serializable {
private static final long serialVersionUID = -5826590025217033638L;
/**
* 主键id
*/
@ApiModelProperty(name = "id", value = "员工主键id")
private Integer id;
/**
* 员工名称
*/
@ApiModelProperty(name = "staffName",value = "员工名字")
private String staffName;
/**
* 员工登录名
*/
@ApiModelProperty(name = "loginName",value = "员工登录名")
private String loginName;
/**
* 员工电话号码
*/
@ApiModelProperty(name = "phone",value = "电话号码")
private String phone;
}
package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.Staff;
import cn.wisenergy.model.dto.StaffDto;
import cn.wisenergy.model.vo.QueryVo;
import cn.wisenergy.model.vo.StaffVo;
import com.github.pagehelper.PageInfo;
/**
* 员工接口
*/
public interface StaffService {
/**
* 禁用员工账号
*
* @param staffId 用户id
* @return true 成功 false 失败
*/
R<Boolean> delete(Integer staffId);
/**
* 查询员工信息集合
* @param queryVo 查询信息
* @return 员工信息集合
*/
R<PageInfo<StaffDto>> getStaffList(QueryVo queryVo);
/**
* 编辑员工信息
* @param staff 需要编辑的信息
* @return true:成功 false:失败
*/
R<Boolean> editStaff(StaffVo staff);
/**
* 添加员工信息
* @param staff 需要添加的员工信息
* @return true: 成功 false:失败
*/
R<Boolean> addStaff(StaffVo staff);
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.Md5Util;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.StaffMapper;
import cn.wisenergy.model.app.Staff;
import cn.wisenergy.model.dto.StaffDto;
import cn.wisenergy.model.dto.UserInfoDto;
import cn.wisenergy.model.vo.QueryVo;
import cn.wisenergy.model.vo.StaffVo;
import cn.wisenergy.service.app.StaffService;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class StaffServiceImpl implements StaffService {
@Autowired
private StaffMapper staffMapper;
//初始密码
private static final String PASSWORD="123456";
/**
* 禁用员工登录
* @param staffId 用户id
* @return true:成功 false:失败
*/
@Override
public R<Boolean> delete(Integer staffId) {
log.info("StaffServiceImpl[].delete[].int.param:"+staffId);
if (null==staffId) {
R.error("输入参数为空");
}
int delete = staffMapper.delete(staffId);
if (delete==0) {
R.ok(1,false);
}
return R.ok(0,true);
}
/**
* 获取员工信息集合
* @param queryVo 查询信息
* @return 员工信息集合
*/
@Override
public R<PageInfo<StaffDto>> getStaffList(QueryVo queryVo) {
log.info("StaffServiceImpl[].getStaffList[].input.param:"+queryVo);
if (null==queryVo) {
return R.error("传入参数为空");
}
//创建参数容器
Map<String, Object> map = new HashMap<>(4);
Integer pageNum = queryVo.getPageNo();
Integer pageSize = queryVo.getPageSize();
if (null == pageSize || pageSize == 0) {
queryVo.setPageSize(10);
}
if (null == pageNum || pageNum == 0) {
queryVo.setPageNo(1);
}
//将参数放入容器中
if (null!=queryVo.getPageNo()||null!=queryVo.getPageSize()){
map.put("pageNo", (queryVo.getPageNo() - 1) * queryVo.getPageSize());
map.put("pageSize", queryVo.getPageSize());
}
map.put("staffName", queryVo.getStaffName());
map.put("phone", queryVo.getPhone());
List<StaffDto> staffList = staffMapper.getStaffList(map);
PageInfo<StaffDto> info = new PageInfo<>();
info.setPageSize(null==queryVo.getPageSize()?0:queryVo.getPageSize());
info.setPageNum(null==queryVo.getPageNo()?0:queryVo.getPageNo());
info.setTotal(staffList.size());
info.setList(staffList);
return R.ok(0,info);
}
/**
* 修改员工信息
* @param staff 需要编辑的信息
* @return true:成功 false:失败
*/
@Override
public R<Boolean> editStaff(StaffVo staff) {
log.info("StaffServiceImpl[].editStaff[].input.param:"+staff);
if (null==staff) {
R.error("传入参数为空");
}
//将参数转移到staff对象中
Staff staff2 = new Staff();
BeanUtils.copyProperties(staff,staff2);
int i = staffMapper.editStaff(staff2);
if (i==0) {
return R.ok(1,false);
}
return R.ok(0,true);
}
/**
* 添加员工信息
* @param staff 需要添加的员工信息
* @return true:成功 false:失败
*/
@Override
public R<Boolean> addStaff(StaffVo staff) {
log.info("StaffServiceImpl[].addStaff[].input.param:"+staff);
if (null==staff) {
return R.error("传入参数为空");
}
//将参数转移到staff对象中
Staff staff2 = new Staff();
staff2.setIsDelete(0);
staff2.setPassword(Md5Util.digestMD5(PASSWORD));
BeanUtils.copyProperties(staff,staff2);
int i = staffMapper.addStaff(staff2);
if (i==0){
return R.ok(1,false);
}
return R.ok(0,true);
}
}
package cn.wisenergy.service.util;
import cn.wisenergy.model.dto.PayPageDto;
import cn.wisenergy.service.httpClient.WechatPayHttpClientBuilder;
import cn.wisenergy.service.httpClient.auth.AutoUpdateCertificatesVerifier;
import cn.wisenergy.service.httpClient.auth.PrivateKeySigner;
......@@ -7,6 +9,7 @@ import cn.wisenergy.service.httpClient.auth.WechatPay2Credentials;
import cn.wisenergy.service.httpClient.auth.WechatPay2Validator;
import cn.wisenergy.service.httpClient.util.PemUtil;
import cn.wisenergy.service.wxpay.WxCommon;
import com.alibaba.fastjson.JSONObject;
import okhttp3.HttpUrl;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
......@@ -88,16 +91,16 @@ public class WxPayUtil {
// 请求body参数
String reqdata = "{"
+ "\"time_expire\":\"2021-02-07T10:34:56+08:00\","
+ "\"amount\": {"
+ "\"amount\":{"
+ "\"total\":100,"
+ "\"currency\":\"CNY\""
+ "},"
+ "\"mchid\":\"" + WxCommon.MCHID + "\","
+ "\"mchid\":\""+WxCommon.MCHID+"\","
+ "\"description\":\"Image形象店-深圳腾大-QQ公仔\","
+ "\"notify_url\":\"" + WxCommon.NOTIFY_URL + "\","
+ "\"out_trade_no\":\"" + tradeNo + "\","
+ "\"notify_url\":\""+WxCommon.NOTIFY_URL+"\","
+ "\"out_trade_no\":\""+tradeNo+"\","
+ "\"goods_tag\":\"WXG\","
+ "\"appid\":\"" + WxCommon.APP_ID + "\","
+ "\"appid\":\""+WxCommon.APP_ID+"\""
// + "\"attach\":\"自定义数据说明\","
// + "\"detail\": {"
// + "\"invoice_id\":\"wx123\","
......@@ -137,17 +140,18 @@ public class WxPayUtil {
// //构造签名参数
// //构造签名参数
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("appid", WxCommon.APP_ID);
// jsonObject.put("mchid", WxCommon.MCHID);
// jsonObject.put("description", "充值");
// jsonObject.put("out_trade_no", tradeNo);
// jsonObject.put("notify_url", WxCommon.NOTIFY_URL);
// JSONObject jsonObject = new JSONObject();jsonObject.put("appid", WxCommon.APP_ID);
// jsonObject.put("mchid", WxCommon.MCHID);
// jsonObject.put("description", "充值");
// jsonObject.put("out_trade_no", tradeNo);
// jsonObject.put("notify_url", WxCommon.NOTIFY_URL);
// jsonObject.put("signType", "RSA");
// PayPageDto payPageDto=new PayPageDto();
// payPageDto.setTotal(100);
// jsonObject.put("amount", payPageDto);
// String token = SignDemo.getToken(method, httpurl, jsonObject.toJSONString(), nonceStr, timestamp);
// String token = SignDemo.getToken(method, httpurl,jsonObject.toJSONString() , nonceStr, timestamp);
// httpPost.setHeader("Authorization", "WECHATPAY2-SHA256-RSA2048" + " " + token);
// httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//完成签名并执行请求
CloseableHttpResponse response = httpClient.execute(httpPost);
......
......@@ -55,6 +55,7 @@ public class PayController {
@ApiImplicitParam(name = "payPageDto", value = "参数", dataType = "PayPageDto")
@PostMapping("/page")
public R<String> doPost(@RequestBody PayPageDto payPageDto, HttpServletRequest request, HttpServletResponse httpResponse) {
return aliPayService.doPost(payPageDto,request,httpResponse);
}
......
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.dto.StaffDto;
import cn.wisenergy.model.vo.QueryVo;
import cn.wisenergy.model.vo.StaffVo;
import cn.wisenergy.service.app.StaffService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(tags = "员工管理")
@RequestMapping("/staff")
@Slf4j
public class StaffController {
@Autowired
private StaffService staffService;
@ApiOperation(value = "添加员工信息",notes = "添加员工信息",httpMethod = "POST")
@ApiImplicitParam(name = "staff",value = "员工信息",dataType = "StaffVo")
@PostMapping("/add")
public R<Boolean> addStaff(@RequestBody StaffVo staff){
log.info("StaffController[].addStaff[].input.param:"+staff);
return staffService.addStaff(staff);
}
@ApiOperation(value = "编辑员工信息",notes = "编辑员工信息",httpMethod = "POST")
@ApiImplicitParam(name = "staff",value = "员工信息",dataType = "StaffVo")
@PostMapping("/edit")
public R<Boolean> editStaff(@RequestBody StaffVo staff){
log.info("StaffController[].editStaff[].input.param:"+staff);
return staffService.editStaff(staff);
}
@ApiOperation(value = "获取员工信息列表",notes = "获取员工信息列表",httpMethod = "POST")
@ApiImplicitParam(name = "queryVo",value = "员工信息",dataType = "QueryVo")
@PostMapping("/getList")
public R<PageInfo<StaffDto>> getStaffList(@RequestBody QueryVo queryVo){
log.info("StaffController[].getStaffList[].input.param:"+queryVo);
return staffService.getStaffList(queryVo);
}
@ApiOperation(value = "禁用员工登录",notes = "禁用员工登录",httpMethod = "GET")
@ApiImplicitParam(name = "staffId",value = "员工id",dataType = "int")
@GetMapping("/delete")
public R<Boolean> delete(Integer staffId){
log.info("StaffController[].delete[].input.param:"+staffId);
return staffService.delete(staffId);
}
}
......@@ -74,6 +74,7 @@ public class JwtUtil {
* @return
*/
public String generateToken(User userDetails) {
return createJWT(JSON.toJSONString(userDetails));
}
......@@ -83,6 +84,7 @@ public class JwtUtil {
* @return
*/
public User getUserFromToken(Claims claims) {
return JSON.parseObject(claims.getSubject(), User.class);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment