➕ Feat: add store and commission
This commit is contained in:
parent
5904d1ea61
commit
99b87fbe4b
5
pom.xml
5
pom.xml
@ -123,5 +123,10 @@
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>3.2.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,47 +1,68 @@
|
||||
package top.xinsin.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.xinsin.pojo.Account;
|
||||
import top.xinsin.service.AccountService;
|
||||
import top.xinsin.util.HttpCodes;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:05
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/account")
|
||||
@RequestMapping({"/account"})
|
||||
public class AccountController {
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
@RequestMapping(path = "/changeAccount",method = RequestMethod.POST)
|
||||
public R<String> changeAccount(@RequestBody Account account){
|
||||
return accountService.changeAccount(account);
|
||||
public AccountController() {
|
||||
}
|
||||
@RequestMapping(path = "/changeStatus",method = RequestMethod.GET)
|
||||
public R<String> changeStatus(@RequestParam("userId")Integer userId,@RequestParam("status")Boolean status){
|
||||
return accountService.changeStatus(userId,status);
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/changeAccount"},
|
||||
method = {RequestMethod.POST}
|
||||
)
|
||||
public R<String> changeAccount(@RequestBody Account account) {
|
||||
return this.accountService.changeAccount(account);
|
||||
}
|
||||
@RequestMapping(path = "/changePassword",method = RequestMethod.GET)
|
||||
public R<String> changePassword(@RequestParam("userId")Integer userId,@RequestParam("oldPassword")String oldPassword,@RequestParam("newPassword") String newPassword){
|
||||
return accountService.changePassword(userId,oldPassword,newPassword);
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/changeStatus"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<String> changeStatus(@RequestParam("userId") Integer userId, @RequestParam("status") Boolean status) {
|
||||
return this.accountService.changeStatus(userId, status);
|
||||
}
|
||||
@RequestMapping(path = "/delUser",method = RequestMethod.GET)
|
||||
public R<String> delUser(@RequestParam("id")Integer id){
|
||||
return accountService.delUser(id);
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/changePassword"},
|
||||
method = {RequestMethod.POST}
|
||||
)
|
||||
public R<String> changePassword(@RequestParam("userId") Integer userId, @RequestParam("oldPassword") String oldPassword, @RequestParam("newPassword") String newPassword) {
|
||||
return this.accountService.changePassword(userId, oldPassword, newPassword);
|
||||
}
|
||||
@RequestMapping(path = "/getUser",method = RequestMethod.GET)
|
||||
public R<JSONObject> getUser(@RequestParam("page")Integer page,@RequestParam("num")Integer num){
|
||||
return accountService.getUser(page,num);
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/delUser"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<String> delUser(@RequestParam("id") Integer id) {
|
||||
return this.accountService.delUser(id);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/getUser"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<JSONObject> getUser(@RequestParam("page") Integer page, @RequestParam("num") Integer num) {
|
||||
return this.accountService.getUser(page, num);
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,41 @@
|
||||
package top.xinsin.controller;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.xinsin.pojo.Account;
|
||||
import top.xinsin.service.AccountService;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
import static top.xinsin.util.StringConstant.*;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
* Created On 2023/4/24 21:06
|
||||
* @version 1.0
|
||||
*/
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
@RequestMapping({"/api/auth"})
|
||||
public class AuthorizeController {
|
||||
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
@RequestMapping(path = "/register",method = RequestMethod.POST)
|
||||
public R<String> register(@Pattern(regexp = USERNAME_REGEX) @Length(min = 3,max = 10) @RequestParam("username") String username,
|
||||
@Pattern(regexp = REL_NAME_REGEX) @RequestParam("relName") String relName,
|
||||
@Pattern(regexp = EMAIL_REGEX) @RequestParam("email") String email,
|
||||
@RequestParam("password") String password,
|
||||
@Pattern(regexp = ID_REGEX) @RequestParam("roleId") Integer roleId){
|
||||
public AuthorizeController() {
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/register"},
|
||||
method = {RequestMethod.POST}
|
||||
)
|
||||
public R<String> register(@RequestParam("username") String username, @RequestParam("relName") String relName, @RequestParam("email") String email, @RequestParam("password") String password, @RequestParam("roleId") Integer roleId) {
|
||||
Account account = new Account();
|
||||
account.setUsername(username);
|
||||
account.setPassword(password);
|
||||
account.setRelName(relName);
|
||||
account.setEmail(email);
|
||||
account.setRoleId(roleId);
|
||||
return accountService.register(account);
|
||||
return this.accountService.register(account);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package top.xinsin.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/commission")
|
||||
public class CommissionController {
|
||||
|
||||
}
|
@ -1,25 +1,107 @@
|
||||
package top.xinsin.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.xinsin.enums.OrderStatus;
|
||||
import top.xinsin.enums.SearchType;
|
||||
import top.xinsin.pojo.Order;
|
||||
import top.xinsin.service.OrderService;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-21
|
||||
* Created On 2023/4/24 21:06
|
||||
* @version 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/order")
|
||||
@RequestMapping({"/order"})
|
||||
public class OrderController {
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
public OrderController() {
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/addOrder"},
|
||||
method = {RequestMethod.POST}
|
||||
)
|
||||
public R<String> addOrder(@RequestBody Order order) {
|
||||
return this.orderService.addOrder(order);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/getOrder"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<JSONObject> getOrder(@RequestParam("page") Integer page, @RequestParam("num") Integer num) {
|
||||
return this.orderService.getOrder(page, num);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/getOrderUserInfo"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<Boolean> getOrderUserInfo(@RequestParam("content") String content) {
|
||||
return this.orderService.getOrderUserInfo(content);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/searchUserOrder"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<JSONObject> searchUserOrder(@RequestParam("searchType") SearchType searchType, @RequestParam("searchContent") String searchContent, @RequestParam("batch") Boolean batch, @RequestParam("page") Integer page, @RequestParam("num") Integer num) {
|
||||
return this.orderService.searchUserOrder(searchType, searchContent, batch, page, num);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/addOrderFlag"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<String> addOrderFlag(@RequestParam("orderId") Integer orderId, @RequestParam("flagId") Integer flagId, @RequestParam("flagRemark") String flagRemark) {
|
||||
return this.orderService.addOrderFlag(orderId, flagId, flagRemark);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/changeOrder"},
|
||||
method = {RequestMethod.POST}
|
||||
)
|
||||
public R<String> changeOrder(@RequestBody Order order) {
|
||||
return this.orderService.changeOrder(order);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/delOrder"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<String> delOrder(@RequestParam("orderId") Integer orderId) {
|
||||
return this.orderService.delOrder(orderId);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/confirm"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public R<String> confirm(@RequestParam("orderStatus") OrderStatus orderStatus, @RequestParam("orderId") Integer orderId) {
|
||||
return this.orderService.confirm(orderStatus, orderId);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/downloadTemplate"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
this.orderService.downloadTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = {"/uploadBatch"},
|
||||
method = {RequestMethod.POST}
|
||||
)
|
||||
public void uploadBatch(@RequestParam("file") MultipartFile file) {
|
||||
this.orderService.uploadBatch(file);
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,16 @@
|
||||
package top.xinsin.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:07
|
||||
* @version 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/permissions")
|
||||
@RequestMapping({"/permissions"})
|
||||
public class PermissionsController {
|
||||
|
||||
}
|
||||
public PermissionsController() {
|
||||
}
|
||||
}
|
@ -1,20 +1,16 @@
|
||||
package top.xinsin.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:07
|
||||
* @version 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/roles")
|
||||
@RequestMapping({"/roles"})
|
||||
public class RolesController {
|
||||
|
||||
}
|
||||
public RolesController() {
|
||||
}
|
||||
}
|
20
src/main/java/top/xinsin/controller/StoreController.java
Normal file
20
src/main/java/top/xinsin/controller/StoreController.java
Normal file
@ -0,0 +1,20 @@
|
||||
package top.xinsin.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/store")
|
||||
public class StoreController {
|
||||
|
||||
}
|
10
src/main/java/top/xinsin/enums/OrderStatus.java
Normal file
10
src/main/java/top/xinsin/enums/OrderStatus.java
Normal file
@ -0,0 +1,10 @@
|
||||
package top.xinsin.enums;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
* Created On 2023/4/22 16:40
|
||||
* @version 1.0
|
||||
*/
|
||||
public enum OrderStatus {
|
||||
商家驳回, 已完成, 已确认等待财务审核, 提交, 新建待提交数据, 财务审核已通过, 财务驳回
|
||||
}
|
10
src/main/java/top/xinsin/enums/SearchType.java
Normal file
10
src/main/java/top/xinsin/enums/SearchType.java
Normal file
@ -0,0 +1,10 @@
|
||||
package top.xinsin.enums;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
* Created On 2023/4/22 16:39
|
||||
* @version 1.0
|
||||
*/
|
||||
public enum SearchType {
|
||||
WANG_ID,WECHAT_ID,ALIPAY_ID,PHONE_NUMBER
|
||||
}
|
@ -1,18 +1,14 @@
|
||||
package top.xinsin.mapper;
|
||||
|
||||
import top.xinsin.pojo.Account;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xinsin.pojo.Account;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:08
|
||||
* @version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface AccountMapper extends BaseMapper<Account> {
|
||||
|
||||
}
|
||||
|
18
src/main/java/top/xinsin/mapper/CommissionMapper.java
Normal file
18
src/main/java/top/xinsin/mapper/CommissionMapper.java
Normal file
@ -0,0 +1,18 @@
|
||||
package top.xinsin.mapper;
|
||||
|
||||
import top.xinsin.pojo.Commission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-24
|
||||
*/
|
||||
@Mapper
|
||||
public class CommissionMapper {
|
||||
|
||||
}
|
@ -1,18 +1,14 @@
|
||||
package top.xinsin.mapper;
|
||||
|
||||
import top.xinsin.pojo.Order;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xinsin.pojo.Order;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-21
|
||||
* Created On 2023/4/24 21:08
|
||||
* @version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderMapper extends BaseMapper<Order> {
|
||||
|
||||
}
|
||||
}
|
@ -1,18 +1,14 @@
|
||||
package top.xinsin.mapper;
|
||||
|
||||
import top.xinsin.pojo.Permissions;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xinsin.pojo.Permissions;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:09
|
||||
* @version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface PermissionsMapper extends BaseMapper<Permissions> {
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,14 @@
|
||||
package top.xinsin.mapper;
|
||||
|
||||
import top.xinsin.pojo.Roles;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xinsin.pojo.Roles;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:09
|
||||
* @version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface RolesMapper extends BaseMapper<Roles> {
|
||||
|
||||
}
|
||||
}
|
18
src/main/java/top/xinsin/mapper/StoreMapper.java
Normal file
18
src/main/java/top/xinsin/mapper/StoreMapper.java
Normal file
@ -0,0 +1,18 @@
|
||||
package top.xinsin.mapper;
|
||||
|
||||
import top.xinsin.pojo.Store;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-24
|
||||
*/
|
||||
@Mapper
|
||||
public class StoreMapper{
|
||||
|
||||
}
|
@ -4,59 +4,57 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
*/
|
||||
* @author xinsin
|
||||
* Created On 2023/4/24 21:09
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("account")
|
||||
public class Account implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@TableId(
|
||||
value = "id",
|
||||
type = IdType.AUTO
|
||||
)
|
||||
private Integer id;
|
||||
|
||||
@TableField("username")
|
||||
private String username;
|
||||
|
||||
@TableField("email")
|
||||
private String email;
|
||||
|
||||
@TableField("rel_name")
|
||||
private String relName;
|
||||
|
||||
@TableField("password")
|
||||
private String password;
|
||||
|
||||
@TableField("status")
|
||||
private Boolean status;
|
||||
|
||||
@TableField("role_id")
|
||||
private Integer roleId;
|
||||
|
||||
@TableField("create_time")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss",
|
||||
timezone = "GMT+8"
|
||||
)
|
||||
private Date createTime;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss",
|
||||
timezone = "GMT+8"
|
||||
)
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
@TableField("del")
|
||||
private Boolean del;
|
||||
}
|
||||
}
|
||||
|
45
src/main/java/top/xinsin/pojo/Commission.java
Normal file
45
src/main/java/top/xinsin/pojo/Commission.java
Normal file
@ -0,0 +1,45 @@
|
||||
package top.xinsin.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Blob;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-24
|
||||
*/
|
||||
@Data
|
||||
@TableName("commission")
|
||||
public class Commission implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@TableField("price_min")
|
||||
private Double priceMin;
|
||||
@TableField("price_max")
|
||||
private Double priceMax;
|
||||
@TableField("commission")
|
||||
private Double commission;
|
||||
@TableField("store_id")
|
||||
private Integer storeId;
|
||||
@TableField("cteate_time")
|
||||
private LocalDateTime cteateTime;
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("del")
|
||||
private Integer del;
|
||||
@TableField("status")
|
||||
private Blob status;
|
||||
|
||||
|
||||
}
|
@ -1,67 +1,108 @@
|
||||
package top.xinsin.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-21
|
||||
*/
|
||||
* @author xinsin
|
||||
* Created On 2023/4/24 21:10
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("order")
|
||||
@TableName("shop_order")
|
||||
public class Order implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ExcelIgnore
|
||||
@TableId(
|
||||
value = "id",
|
||||
type = IdType.AUTO
|
||||
)
|
||||
private Integer id;
|
||||
@ExcelProperty({"订单号"})
|
||||
@TableField("order_no")
|
||||
private String orderNo;
|
||||
@ExcelProperty({"下单时间"})
|
||||
@TableField("order_time")
|
||||
private LocalDateTime orderTime;
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss",
|
||||
timezone = "GMT+8"
|
||||
)
|
||||
private Date orderTime;
|
||||
@ExcelProperty({"订单状态"})
|
||||
@TableField("order_status")
|
||||
private String orderStatus;
|
||||
@ExcelProperty({"旺旺号"})
|
||||
@TableField("wang_no")
|
||||
private String wangNo;
|
||||
@ExcelProperty({"微信|qq账号"})
|
||||
@TableField("wechat_no")
|
||||
private String wechatNo;
|
||||
@ExcelProperty({"支付宝账号"})
|
||||
@TableField("alipay_no")
|
||||
private String alipayNo;
|
||||
@ExcelProperty({"付款金额"})
|
||||
@TableField("pay_amt")
|
||||
private Double payAmt;
|
||||
@TableField("shop_town_name")
|
||||
private String shopTownName;
|
||||
@ExcelProperty({"店铺名称"})
|
||||
@TableField("storeId")
|
||||
private Integer storeId;
|
||||
@ExcelProperty({"佣金"})
|
||||
@TableField("commission")
|
||||
private Double commission;
|
||||
@ExcelProperty({"支付宝名称"})
|
||||
@TableField("alipay_name")
|
||||
private String alipayName;
|
||||
@ExcelProperty({"放单人"})
|
||||
@TableField("rp_name")
|
||||
private String rpName;
|
||||
@ExcelProperty({"放单人微信名"})
|
||||
@TableField("rp_wechat_name")
|
||||
private String rpWechatName;
|
||||
@ExcelProperty({"备注"})
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
@ExcelProperty({"买家电话"})
|
||||
@TableField("phone_number")
|
||||
private String phoneNumber;
|
||||
@ExcelProperty({"银行卡号"})
|
||||
@TableField("card_no")
|
||||
private String cardNo;
|
||||
@ExcelProperty({"插旗"})
|
||||
@TableField("flag")
|
||||
private Integer flag;
|
||||
@ExcelProperty({"插旗备注"})
|
||||
@TableField("flag_remark")
|
||||
private String flagRemark;
|
||||
@ExcelProperty({"付款时间"})
|
||||
@TableField("pay_time")
|
||||
private LocalDateTime payTime;
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss",
|
||||
timezone = "GMT+8"
|
||||
)
|
||||
private Date payTime;
|
||||
@ExcelProperty({"收货地址"})
|
||||
@TableField("address")
|
||||
private String address;
|
||||
@ExcelProperty({"商品id"})
|
||||
@TableField("shop_id")
|
||||
private Integer shopId;
|
||||
@ExcelProperty({"sku"})
|
||||
@TableField("sku")
|
||||
private String sku;
|
||||
}
|
||||
}
|
||||
|
@ -4,47 +4,55 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
*/
|
||||
* @author xinsin
|
||||
* Created On 2023/4/24 21:11
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("permissions")
|
||||
public class Permissions implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@TableField("permission_name")
|
||||
private String permissionName;
|
||||
@TableField("permission_code")
|
||||
private String permissionCode;
|
||||
@TableField("description")
|
||||
private String description;
|
||||
@TableField("account_id")
|
||||
private Integer accountId;
|
||||
@TableField("create_time")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime createTime;
|
||||
@TableField("update_time")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("status")
|
||||
private Boolean status;
|
||||
@TableField("del")
|
||||
private Boolean del;
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(
|
||||
value = "id",
|
||||
type = IdType.AUTO
|
||||
)
|
||||
private Integer id;
|
||||
@TableField("permission_name")
|
||||
private String permissionName;
|
||||
@TableField("permission_code")
|
||||
private String permissionCode;
|
||||
@TableField("description")
|
||||
private String description;
|
||||
@TableField("account_id")
|
||||
private Integer accountId;
|
||||
@TableField("create_time")
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss",
|
||||
timezone = "GMT+8"
|
||||
)
|
||||
private LocalDateTime createTime;
|
||||
@TableField("update_time")
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss",
|
||||
timezone = "GMT+8"
|
||||
)
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("status")
|
||||
private Boolean status;
|
||||
@TableField("del")
|
||||
private Boolean del;
|
||||
}
|
||||
|
@ -4,47 +4,53 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
*/
|
||||
* @author xinsin
|
||||
* Created On 2023/4/24 21:11
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("roles")
|
||||
public class Roles implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@TableField("role_name")
|
||||
private String roleName;
|
||||
@TableField("description")
|
||||
private String description;
|
||||
@TableField("account_id")
|
||||
private Integer accountId;
|
||||
@TableField("create_time")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime createTime;
|
||||
@TableField("update_time")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("status")
|
||||
private Boolean status;
|
||||
@TableField("del")
|
||||
private Boolean del;
|
||||
|
||||
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(
|
||||
value = "id",
|
||||
type = IdType.AUTO
|
||||
)
|
||||
private Integer id;
|
||||
@TableField("role_name")
|
||||
private String roleName;
|
||||
@TableField("description")
|
||||
private String description;
|
||||
@TableField("account_id")
|
||||
private Integer accountId;
|
||||
@TableField("create_time")
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss",
|
||||
timezone = "GMT+8"
|
||||
)
|
||||
private LocalDateTime createTime;
|
||||
@TableField("update_time")
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss",
|
||||
timezone = "GMT+8"
|
||||
)
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("status")
|
||||
private Boolean status;
|
||||
@TableField("del")
|
||||
private Boolean del;
|
||||
}
|
||||
|
39
src/main/java/top/xinsin/pojo/Store.java
Normal file
39
src/main/java/top/xinsin/pojo/Store.java
Normal file
@ -0,0 +1,39 @@
|
||||
package top.xinsin.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Blob;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-24
|
||||
*/
|
||||
@Data
|
||||
@TableName("store")
|
||||
public class Store implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@TableField("name")
|
||||
private String name;
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("del")
|
||||
private Integer del;
|
||||
@TableField("status")
|
||||
private Blob status;
|
||||
|
||||
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
@ -12,103 +16,92 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.xinsin.mapper.AccountMapper;
|
||||
import top.xinsin.pojo.Account;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xinsin.util.HttpCodes;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:11
|
||||
* @version 1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AccountService implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private AccountMapper accountMapper;
|
||||
|
||||
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
||||
|
||||
@Override
|
||||
public AccountService() {
|
||||
}
|
||||
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
System.out.println(username);
|
||||
if(username == null) throw new UsernameNotFoundException("用户名不能为空");
|
||||
Account account = accountMapper.selectOne(new LambdaQueryWrapper<Account>()
|
||||
.eq(Account::getUsername,username)
|
||||
.or()
|
||||
.eq(Account::getEmail,username)
|
||||
.eq(Account::getStatus,true));
|
||||
if(account == null) throw new UsernameNotFoundException("用户名或密码错误");
|
||||
return User
|
||||
.withUsername(account.getUsername())
|
||||
.password(account.getPassword())
|
||||
.roles("role=" + account.getRoleId(),"id=" + account.getId())
|
||||
.build();
|
||||
if (username == null) {
|
||||
throw new UsernameNotFoundException("用户名不能为空");
|
||||
} else {
|
||||
Account account = this.accountMapper.selectOne(new LambdaQueryWrapper<Account>().eq(Account::getUsername, username).or().eq(Account::getEmail, username).eq(Account::getStatus, true));
|
||||
if (account == null) {
|
||||
throw new UsernameNotFoundException("用户名或密码错误");
|
||||
} else {
|
||||
return User.withUsername(account.getUsername()).password(account.getPassword()).roles(new String[]{"role=" + account.getRoleId(), "id=" + account.getId()}).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public R<String> register(Account account) {
|
||||
account.setCreateTime(new Date());
|
||||
account.setStatus(true);
|
||||
account.setPassword(encoder.encode(account.getPassword()));
|
||||
int insert = accountMapper.insert(account);
|
||||
return insert == 1 ? R.success("注册成功") : R.failed(HttpCodes.HTTP_CODES555,"注册失败,您的用户名或者邮箱已经被注册过了");
|
||||
account.setPassword(this.encoder.encode(account.getPassword()));
|
||||
int insert = this.accountMapper.insert(account);
|
||||
return insert == 1 ? R.success("注册成功") : R.failed(HttpCodes.HTTP_CODES555, "注册失败,您的用户名或者邮箱已经被注册过了");
|
||||
}
|
||||
|
||||
public R<String> changeAccount(Account account) {
|
||||
if (account.getPassword() != null){
|
||||
account.setPassword(encoder.encode(account.getPassword()));
|
||||
if (account.getPassword() != null) {
|
||||
account.setPassword(this.encoder.encode(account.getPassword()));
|
||||
}
|
||||
int update = accountMapper.updateById(account);
|
||||
return update == 1 ? R.success("修改用户信息成功") : R.failed(HttpCodes.HTTP_CODES555,"修改用户信息失败,请联系服务器管理员");
|
||||
|
||||
int update = this.accountMapper.updateById(account);
|
||||
return update == 1 ? R.success("修改用户信息成功") : R.failed(HttpCodes.HTTP_CODES555, "修改用户信息失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
public R<String> changeStatus(Integer userId, Boolean status) {
|
||||
Account account = new Account();
|
||||
account.setId(userId);
|
||||
account.setStatus(status);
|
||||
int i = accountMapper.updateById(account);
|
||||
if (i == 1){
|
||||
if (status){
|
||||
return R.success("启用该用户成功");
|
||||
}else{
|
||||
return R.success("禁用该用户成功");
|
||||
}
|
||||
}else{
|
||||
return R.failed(HttpCodes.HTTP_CODES555,"修改用户状态失败");
|
||||
int i = this.accountMapper.updateById(account);
|
||||
if (i == 1) {
|
||||
return status ? R.success("启用该用户成功") : R.success("禁用该用户成功");
|
||||
} else {
|
||||
return R.failed(HttpCodes.HTTP_CODES555, "修改用户状态失败");
|
||||
}
|
||||
}
|
||||
|
||||
public R<String> changePassword(Integer userId, String oldPassword, String newPassword) {
|
||||
Account account = new Account();
|
||||
account.setPassword(encoder.encode(newPassword));
|
||||
account.setPassword(this.encoder.encode(newPassword));
|
||||
LambdaQueryWrapper<Account> accountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
accountLambdaQueryWrapper
|
||||
.eq(Account::getId,userId)
|
||||
.eq(Account::getPassword,encoder.encode(oldPassword));
|
||||
int update = accountMapper.update(account, accountLambdaQueryWrapper);
|
||||
return update == 1 ? R.success("修改密码成功") : R.failed(HttpCodes.HTTP_CODES555,"修改密码失败,请联系服务器管理员");
|
||||
accountLambdaQueryWrapper.eq(Account::getId, userId).eq(Account::getPassword, this.encoder.encode(oldPassword));
|
||||
int update = this.accountMapper.update(account, accountLambdaQueryWrapper);
|
||||
return update == 1 ? R.success("修改密码成功") : R.failed(HttpCodes.HTTP_CODES555, "修改密码失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
public R<JSONObject> getUser(Integer page, Integer num) {
|
||||
Page<Account> accountPage = new Page<>(page,num);
|
||||
Page<Account> accountPage1 = accountMapper.selectPage(accountPage, null);
|
||||
Page<Account> accountPage = new Page<>((long)page, (long)num);
|
||||
Page<Account> accountPage1 = this.accountMapper.selectPage(accountPage, null);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
List<Account> collect = accountPage1.getRecords().stream().peek(e -> e.setPassword(null)).toList();
|
||||
jsonObject
|
||||
.fluentPut("info",collect)
|
||||
.fluentPut("total",accountPage1.getTotal());
|
||||
List<Account> collect = accountPage1.getRecords().stream().peek((e) -> {
|
||||
e.setPassword((String)null);
|
||||
}).toList();
|
||||
jsonObject.fluentPut("info", collect).fluentPut("total", accountPage1.getTotal());
|
||||
return R.success(jsonObject);
|
||||
}
|
||||
|
||||
public R<String> delUser(Integer id) {
|
||||
int delete = accountMapper.deleteById(id);
|
||||
return delete == 1 ? R.success("删除用户成功") : R.failed(HttpCodes.HTTP_CODES555,"删除用户失败,请联系服务器管理员");
|
||||
int delete = this.accountMapper.deleteById(id);
|
||||
return delete == 1 ? R.success("删除用户成功") : R.failed(HttpCodes.HTTP_CODES555, "删除用户失败,请联系服务器管理员");
|
||||
}
|
||||
}
|
||||
|
18
src/main/java/top/xinsin/service/CommissionService.java
Normal file
18
src/main/java/top/xinsin/service/CommissionService.java
Normal file
@ -0,0 +1,18 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.xinsin.pojo.Commission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-24
|
||||
*/
|
||||
@Service
|
||||
public class CommissionService {
|
||||
|
||||
}
|
@ -1,21 +1,153 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.xinsin.enums.OrderStatus;
|
||||
import top.xinsin.enums.SearchType;
|
||||
import top.xinsin.mapper.OrderMapper;
|
||||
import top.xinsin.pojo.Order;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xinsin.util.ExcelParserUtil;
|
||||
import top.xinsin.util.HttpCodes;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-21
|
||||
* Created On 2023/4/24 21:12
|
||||
* @version 1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OrderService {
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
public R<String> addOrder(Order order) {
|
||||
order.setOrderTime(new Date());
|
||||
int insert = this.orderMapper.insert(order);
|
||||
return insert == 1 ? R.success("订单添加成功") : R.failed(HttpCodes.HTTP_CODES555, "订单添加失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
public R<JSONObject> getOrder(Integer page, Integer num) {
|
||||
Page<Order> orderPage = new Page<>((long)page, (long)num);
|
||||
Page<Order> orderPage1 = this.orderMapper.selectPage(orderPage, null);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.fluentPut("info", orderPage1.getRecords()).fluentPut("total", orderPage1.getTotal());
|
||||
return R.success(jsonObject);
|
||||
}
|
||||
|
||||
public R<Boolean> getOrderUserInfo(String content) {
|
||||
LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
orderLambdaQueryWrapper.eq(Order::getWechatNo, content).or().eq(Order::getWangNo, content).or().eq(Order::getAlipayNo, content).or().eq(Order::getPhoneNumber, content).or().eq(Order::getAlipayName, content);
|
||||
List<Order> orders = this.orderMapper.selectList(orderLambdaQueryWrapper);
|
||||
return orders.size() == 0 ? R.success(false) : R.success(true);
|
||||
}
|
||||
|
||||
public R<JSONObject> searchUserOrder(SearchType searchType, String searchContent, Boolean batch, Integer page, Integer num) {
|
||||
LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if (batch) {
|
||||
String[] split = searchContent.split(",");
|
||||
String[] var8 = split;
|
||||
int var9 = split.length;
|
||||
|
||||
for(int var10 = 0; var10 < var9; ++var10) {
|
||||
String s = var8[var10];
|
||||
this.searchForWhereOne(searchType, orderLambdaQueryWrapper, s);
|
||||
}
|
||||
} else {
|
||||
this.searchForWhereOne(searchType, orderLambdaQueryWrapper, searchContent);
|
||||
}
|
||||
|
||||
Page<Order> orderPage = new Page<>((long)page, (long)num);
|
||||
Page<Order> orderPage1 = this.orderMapper.selectPage(orderPage, orderLambdaQueryWrapper);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.fluentPut("info", orderPage1.getRecords()).fluentPut("total", orderPage1.getTotal());
|
||||
return R.success(jsonObject);
|
||||
}
|
||||
|
||||
private void searchForWhereOne(SearchType searchType, LambdaQueryWrapper<Order> orderLambdaQueryWrapper, String searchContent) {
|
||||
switch (searchType) {
|
||||
case WANG_ID -> orderLambdaQueryWrapper.like(Order::getWangNo, searchContent);
|
||||
case ALIPAY_ID -> orderLambdaQueryWrapper.like(Order::getAlipayNo, searchContent);
|
||||
case WECHAT_ID -> orderLambdaQueryWrapper.like(Order::getWechatNo, searchContent);
|
||||
case PHONE_NUMBER -> orderLambdaQueryWrapper.like(Order::getPhoneNumber, searchContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public R<String> addOrderFlag(Integer orderId, Integer flagId, String flagRemark) {
|
||||
Order order = new Order();
|
||||
order.setId(orderId);
|
||||
order.setFlag(flagId);
|
||||
order.setFlagRemark(flagRemark);
|
||||
int update = this.orderMapper.updateById(order);
|
||||
return update == 1 ? R.success("订单插旗成功," + flagId + "号旗") : R.failed(HttpCodes.HTTP_CODES555, "订单插旗失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
public R<String> changeOrder(Order order) {
|
||||
int update = this.orderMapper.updateById(order);
|
||||
return update == 1 ? R.success("订单修改成功") : R.failed(HttpCodes.HTTP_CODES555, "订单修改失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
public R<String> delOrder(Integer orderId) {
|
||||
int delete = this.orderMapper.deleteById(orderId);
|
||||
return delete == 1 ? R.success("删除订单成功") : R.failed(HttpCodes.HTTP_CODES555, "删除订单失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
public R<String> confirm(OrderStatus orderStatus, Integer orderId) {
|
||||
Order order = new Order();
|
||||
order.setId(orderId);
|
||||
order.setOrderStatus(orderStatus.name());
|
||||
int update = this.orderMapper.updateById(order);
|
||||
return update == 1 ? R.success("订单确认成功,当前状态:" + orderStatus.name()) : R.failed(HttpCodes.HTTP_CODES555, "订单确认失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
try {
|
||||
File file = new File("template/example.xlsx");
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
|
||||
byte[] bytes = new byte[bufferedInputStream.available()];
|
||||
bufferedInputStream.read(bytes);
|
||||
bufferedInputStream.close();
|
||||
response.reset();
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.addHeader("Content-disposition", "attachment;filename*=utf-8''example.xlsx");
|
||||
response.addHeader("Content-Length", "" + file.length());
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(response.getOutputStream());
|
||||
response.setContentType("application/octet-stream");
|
||||
bufferedOutputStream.write(bytes);
|
||||
bufferedOutputStream.flush();
|
||||
} catch (Throwable var7) {
|
||||
throw var7;
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void uploadBatch(MultipartFile file) {
|
||||
try {
|
||||
EasyExcel.read(file.getInputStream(), Order.class, new ExcelParserUtil(this.orderMapper)).sheet().doRead();
|
||||
} catch (Throwable var3) {
|
||||
throw var3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,14 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.xinsin.pojo.Permissions;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:13
|
||||
* @version 1.0
|
||||
*/
|
||||
@Service
|
||||
public class PermissionsService {
|
||||
|
||||
public PermissionsService() {
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,14 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.xinsin.pojo.Roles;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-12
|
||||
* Created On 2023/4/24 21:13
|
||||
* @version 1.0
|
||||
*/
|
||||
@Service
|
||||
public class RolesService {
|
||||
|
||||
public RolesService() {
|
||||
}
|
||||
}
|
||||
|
16
src/main/java/top/xinsin/service/StoreService.java
Normal file
16
src/main/java/top/xinsin/service/StoreService.java
Normal file
@ -0,0 +1,16 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import top.xinsin.pojo.Store;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xinsin
|
||||
* @since 2023-04-24
|
||||
*/
|
||||
public interface StoreService extends IService<Store> {
|
||||
|
||||
}
|
103
src/main/java/top/xinsin/util/ExcelParserUtil.java
Normal file
103
src/main/java/top/xinsin/util/ExcelParserUtil.java
Normal file
@ -0,0 +1,103 @@
|
||||
package top.xinsin.util;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.alibaba.excel.exception.ExcelDataConvertException;
|
||||
import com.alibaba.excel.read.processor.AnalysisEventProcessor;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.xinsin.mapper.OrderMapper;
|
||||
import top.xinsin.pojo.Order;
|
||||
import top.xinsin.service.OrderService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
* Created On 2023/4/22 22:44
|
||||
* @version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class ExcelParserUtil extends AnalysisEventListener<Order> {
|
||||
/**
|
||||
* 每次读取的最大数据条数
|
||||
*/
|
||||
private static final int MAX_BATCH_COUNT = 100;
|
||||
|
||||
/**
|
||||
* 泛型bean属性
|
||||
*/
|
||||
private OrderMapper dynamicService;
|
||||
|
||||
/**
|
||||
* 可接收任何参数的泛型List集合
|
||||
*/
|
||||
List<Order> list = new ArrayList<>();
|
||||
|
||||
List<Order> total = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* 构造函数注入bean(根据传入的bean动态注入)
|
||||
*
|
||||
* @param dynamicService
|
||||
*/
|
||||
public ExcelParserUtil(OrderMapper dynamicService) {
|
||||
this.dynamicService = dynamicService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(Order data, AnalysisContext analysisContext) {
|
||||
log.info(" ==> 解析一条数据: {}", JSONObject.toJSONString(data));
|
||||
list.add(data);
|
||||
if (list.size() > MAX_BATCH_COUNT) {
|
||||
// 保存数据
|
||||
saveData();
|
||||
// 清空list
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 所有数据解析完成后,会来调用一次
|
||||
* 作用: 避免最后集合中小于 MAX_BATCH_COUNT 条的数据没有被保存
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
saveData();
|
||||
log.info(" ==> 数据解析完成 <==");
|
||||
}
|
||||
/**
|
||||
* 保存数据
|
||||
*/
|
||||
private void saveData() {
|
||||
log.info(" ==> 数据保存开始: {}", list.size());
|
||||
ArrayList<Order> ts = new ArrayList<>();
|
||||
list.forEach(order -> {
|
||||
if (order.getOrderNo() != null && order.getOrderTime() != null && order.getWangNo() != null && order.getPayAmt() != null && order.getShopId() != null && order.getAddress() != null){
|
||||
ts.add(order);
|
||||
}
|
||||
});
|
||||
ts.forEach(dynamicService::insert);
|
||||
log.info(" ==> 数据保存结束 <==");
|
||||
}
|
||||
|
||||
/**
|
||||
* 在转换异常 获取其他异常下会调用本接口。我们如果捕捉并手动抛出异常则停止读取。如果这里不抛出异常则 继续读取下一行。
|
||||
*
|
||||
* @param exception
|
||||
* @param context
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||
log.error(" ==> 数据解析失败,但是继续读取下一行:{}", exception.getMessage());
|
||||
// 如果是某一个单元格的转换异常 能获取到具体行号
|
||||
if (exception instanceof ExcelDataConvertException) {
|
||||
ExcelDataConvertException convertException = (ExcelDataConvertException) exception;
|
||||
log.error("第{}行,第{}列数据解析异常", convertException.getRowIndex(), convertException.getColumnIndex());
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ spring:
|
||||
datasource:
|
||||
username: commerce_system
|
||||
password: Jix656dzD6St4YCn
|
||||
url: jdbc:mysql://wzpmc.cn:3306/commerce_system?serverTimezone=UTC-8
|
||||
url: jdbc:mysql://www.wzpmc.cn:3306/commerce_system?serverTimezone=UTC-8
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# druid配置
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
@ -10,11 +10,11 @@
|
||||
<result column="order_status" property="orderStatus" />
|
||||
<result column="wang_no" property="wangNo" />
|
||||
<result column="wechat_no" property="wechatNo" />
|
||||
<result column="apay_no" property="apayNo" />
|
||||
<result column="alipay_no" property="alipayNo" />
|
||||
<result column="pay_amt" property="payAmt" />
|
||||
<result column="shoptown_name" property="shoptownName" />
|
||||
<result column="shop_town_name" property="shopTownName" />
|
||||
<result column="commission" property="commission" />
|
||||
<result column="apay_name" property="apayName" />
|
||||
<result column="alipay_name" property="alipayName" />
|
||||
<result column="rp_name" property="rpName" />
|
||||
<result column="rp_wechat_name" property="rpWechatName" />
|
||||
<result column="remark" property="remark" />
|
||||
|
@ -14,7 +14,8 @@ import java.util.function.Consumer;
|
||||
public class CodeGenerator {
|
||||
public static void main(String[] args) {
|
||||
List<String> tables = new ArrayList<>();
|
||||
tables.add("order");
|
||||
tables.add("store");
|
||||
tables.add("commission");
|
||||
|
||||
FastAutoGenerator.create("jdbc:mysql://wzpmc.cn:3306/commerce_system?serverTimezone=UTC-8","commerce_system","Jix656dzD6St4YCn")
|
||||
.globalConfig(builder -> {
|
||||
|
BIN
template/example.xlsx
Normal file
BIN
template/example.xlsx
Normal file
Binary file not shown.
BIN
运伦电商软件导图(1).emmx
Normal file
BIN
运伦电商软件导图(1).emmx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user