Style: 格式化代码样式

This commit is contained in:
xinsin 2023-04-24 21:57:50 +08:00
parent 99b87fbe4b
commit b724e1cdec
16 changed files with 199 additions and 266 deletions

View File

@ -18,51 +18,23 @@ import top.xinsin.util.R;
*/
@RestController
@RequestMapping({"/account"})
@RequestMapping("/account")
public class AccountController {
@Autowired
private AccountService accountService;
public AccountController() {
}
@RequestMapping(path = "/changeAccount", method = RequestMethod.POST)
public R<String> changeAccount(@RequestBody Account account) {return this.accountService.changeAccount(account);}
@RequestMapping(
path = {"/changeAccount"},
method = {RequestMethod.POST}
)
public R<String> changeAccount(@RequestBody Account account) {
return this.accountService.changeAccount(account);
}
@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 = {"/changeStatus"},
method = {RequestMethod.GET}
)
public R<String> changeStatus(@RequestParam("userId") Integer userId, @RequestParam("status") Boolean status) {
return this.accountService.changeStatus(userId, status);
}
@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 = {"/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 = "/delUser", method = RequestMethod.GET)
public R<String> delUser(@RequestParam("id") Integer id) {return this.accountService.delUser(id);}
@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);
}
@RequestMapping(path = "/getUser", method = RequestMethod.GET)
public R<JSONObject> getUser(@RequestParam("page") Integer page, @RequestParam("num") Integer num) {return this.accountService.getUser(page, num);}
}

View File

@ -17,18 +17,12 @@ import top.xinsin.util.R;
*/
@Validated
@RestController
@RequestMapping({"/api/auth"})
@RequestMapping("/api/auth")
public class AuthorizeController {
@Autowired
private AccountService accountService;
public AuthorizeController() {
}
@RequestMapping(
path = {"/register"},
method = {RequestMethod.POST}
)
@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);

View File

@ -17,91 +17,37 @@ import top.xinsin.util.R;
* @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 = {"/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 = {"/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 = {"/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 = {"/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 = {"/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 = {"/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 = {"/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 = {"/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);
}
@RequestMapping(path = "/uploadBatch", method = RequestMethod.POST)
public void uploadBatch(@RequestParam("file") MultipartFile file) {this.orderService.uploadBatch(file);}
}

View File

@ -9,8 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
* @version 1.0
*/
@RestController
@RequestMapping({"/permissions"})
@RequestMapping("/permissions")
public class PermissionsController {
public PermissionsController() {
}
}

View File

@ -9,8 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
* @version 1.0
*/
@RestController
@RequestMapping({"/roles"})
@RequestMapping("/roles")
public class RolesController {
public RolesController() {
}
}

View File

@ -1,9 +1,15 @@
package top.xinsin.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import top.xinsin.pojo.Store;
import top.xinsin.service.StoreService;
import top.xinsin.util.R;
import java.util.List;
/**
* <p>
@ -17,4 +23,17 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/store")
public class StoreController {
@Autowired
private StoreService storeService;
@RequestMapping(path = "/addStore",method = RequestMethod.POST)
public R<Boolean> addStore(@RequestBody Store store){return storeService.addStore(store);}
@RequestMapping(path = "/changeStore",method = RequestMethod.POST)
public R<Boolean> changeStore(@RequestBody Store store){return storeService.changStore(store);}
@RequestMapping(path = "/delStore",method = RequestMethod.GET)
public R<Boolean> delStore(@RequestParam("id")Integer id){return storeService.delStore(id);}
@RequestMapping(path = "/getStore",method = RequestMethod.GET)
public R<JSONObject> getStore(@RequestParam("page")Integer page, @RequestParam("num")Integer num){return storeService.getStore(page,num);}
@RequestMapping(path = "/getAllStore",method = RequestMethod.GET)
public R<List<Store>> getAllStore(){return storeService.getAllStore();}
}

View File

@ -13,6 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2023-04-24
*/
@Mapper
public class CommissionMapper {
public interface CommissionMapper extends BaseMapper<Commission> {
}

View File

@ -13,6 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2023-04-24
*/
@Mapper
public class StoreMapper{
public interface StoreMapper extends BaseMapper<Store> {
}

View File

@ -1,13 +1,11 @@
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 com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
@ -19,11 +17,9 @@ import java.util.Date;
@Data
@TableName("account")
public class Account implements Serializable {
@Serial
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;
@ -38,23 +34,14 @@ public class Account implements Serializable {
@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")
@TableLogic
private Boolean del;
}

View File

@ -1,13 +1,15 @@
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;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serial;
import java.io.Serializable;
import java.sql.Blob;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
@ -17,29 +19,32 @@ package top.xinsin.pojo;
* @author xinsin
* @since 2023-04-24
*/
@Data
@TableName("commission")
public class Commission implements Serializable {
@Data
@TableName("commission")
public class Commission implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("price_min")
@TableField("price_min")
private Double priceMin;
@TableField("price_max")
@TableField("price_max")
private Double priceMax;
@TableField("commission")
@TableField("commission")
private Double commission;
@TableField("store_id")
@TableField("store_id")
private Integer storeId;
@TableField("cteate_time")
private LocalDateTime cteateTime;
@TableField("update_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField("create_time")
private LocalDateTime createTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField("update_time")
private LocalDateTime updateTime;
@TableField("del")
@TableField("del")
@TableLogic
private Integer del;
@TableField("status")
private Blob status;
@TableField("status")
private Boolean status;
}

View File

@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
@ -21,25 +22,18 @@ import java.util.Date;
@Data
@TableName("shop_order")
public class Order implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ExcelIgnore
@TableId(
value = "id",
type = IdType.AUTO
)
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ExcelProperty({"订单号"})
@TableField("order_no")
private String orderNo;
@ExcelProperty({"下单时间"})
@TableField("order_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 orderTime;
@ExcelProperty({"订单状态"})
@TableField("order_status")
@ -57,7 +51,7 @@ public class Order implements Serializable {
@TableField("pay_amt")
private Double payAmt;
@ExcelProperty({"店铺名称"})
@TableField("storeId")
@TableField("store_id")
private Integer storeId;
@ExcelProperty({"佣金"})
@TableField("commission")
@ -88,13 +82,8 @@ public class Order implements Serializable {
private String flagRemark;
@ExcelProperty({"付款时间"})
@TableField("pay_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 payTime;
@ExcelProperty({"收货地址"})
@TableField("address")

View File

@ -1,13 +1,11 @@
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 com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
@ -19,11 +17,9 @@ import java.time.LocalDateTime;
@Data
@TableName("permissions")
public class Permissions implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@TableId(
value = "id",
type = IdType.AUTO
)
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("permission_name")
private String permissionName;
@ -34,25 +30,16 @@ public class Permissions implements Serializable {
@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"
)
@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"
)
@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")
@TableLogic
private Boolean del;
}

View File

@ -1,13 +1,11 @@
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 com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
@ -19,11 +17,9 @@ import java.time.LocalDateTime;
@Data
@TableName("roles")
public class Roles implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@TableId(
value = "id",
type = IdType.AUTO
)
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("role_name")
private String roleName;
@ -32,25 +28,16 @@ public class Roles implements Serializable {
@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"
)
@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"
)
@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")
@TableLogic
private Boolean del;
}

View File

@ -1,13 +1,16 @@
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 com.baomidou.mybatisplus.annotation.*;
import java.io.Serial;
import java.io.Serializable;
import java.sql.Blob;
import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
@ -17,23 +20,26 @@ package top.xinsin.pojo;
* @author xinsin
* @since 2023-04-24
*/
@Data
@TableName("store")
public class Store implements Serializable {
@Data
@TableName("store")
public class Store implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("name")
@TableField("name")
private String name;
@TableField("create_time")
private LocalDateTime createTime;
@TableField("update_time")
private LocalDateTime updateTime;
@TableField("del")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField("create_time")
private Date createTime;
@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")
@TableLogic
private Integer del;
@TableField("status")
private Blob status;
@TableField("status")
private Boolean status;
}

View File

@ -84,10 +84,10 @@ public class OrderService {
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);
case WANG_ID -> orderLambdaQueryWrapper.like(Order::getWangNo, searchContent).or();
case ALIPAY_ID -> orderLambdaQueryWrapper.like(Order::getAlipayNo, searchContent).or();
case WECHAT_ID -> orderLambdaQueryWrapper.like(Order::getWechatNo, searchContent).or();
case PHONE_NUMBER -> orderLambdaQueryWrapper.like(Order::getPhoneNumber, searchContent).or();
}
}

View File

@ -1,7 +1,18 @@
package top.xinsin.service;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.xinsin.mapper.StoreMapper;
import top.xinsin.pojo.Store;
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;
/**
* <p>
@ -11,6 +22,38 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @author xinsin
* @since 2023-04-24
*/
public interface StoreService extends IService<Store> {
@Service
@Slf4j
public class StoreService {
@Autowired
private StoreMapper storeMapper;
public R<Boolean> addStore(Store store) {
store.setCreateTime(new Date());
int insert = storeMapper.insert(store);
return insert != 0 ? R.success(true) : R.failed(HttpCodes.HTTP_CODES555,false);
}
public R<Boolean> changStore(Store store) {
store.setUpdateTime(new Date());
int update = storeMapper.updateById(store);
return update != 0 ? R.success(true) : R.failed(HttpCodes.HTTP_CODES555,false);
}
public R<Boolean> delStore(Integer id) {
int delete = storeMapper.deleteById(id);
return delete != 0 ? R.success(true) : R.failed(HttpCodes.HTTP_CODES555,false);
}
public R<JSONObject> getStore(Integer page, Integer num) {
JSONObject jsonObject = new JSONObject();
Page<Store> storePage = new Page<>(page,num);
Page<Store> storePage1 = storeMapper.selectPage(storePage, null);
jsonObject.fluentPut("info",storePage1.getRecords()).fluentPut("total",storePage1.getTotal());
return R.success(jsonObject);
}
public R<List<Store>> getAllStore() {
return R.success(storeMapper.selectList(null));
}
}