Fourth day of mall notes

Keywords: Programming REST Attribute Java less

**

I. Functional Realization of Adding Commodities

**
Request url:/item/save
Parameter: Form data. Receive using the pojo type. The pojo attribute name is required to be the same as the attribute name of the form input. Class TBItem.
Return value: Using easyUIResult
The EasyUIResult class code is as follows
: `import java.util.List;

public class EasyUIResult {

private Integer total;

private List<?> rows;

public EasyUIResult(Integer total, List<?> rows) {
	this.total = total;
	this.rows = rows;
}

public EasyUIResult(long total, List<?> rows) {
	this.total = (int) total;
	this.rows = rows;
}

public Integer getTotal() {
	return total;
}
public void setTotal(Integer total) {
	this.total = total;
}
public List<?> getRows() {
	return rows;
}
public void setRows(List<?> rows) {
	this.rows = rows;
}

}`
service Layer Implementation
Completion of commodity attributes:
Generate the primary key strategy: Use to get the current time (accurate to milliseconds) plus two random numbers.
IDUtils:

import java.util.Random;

public class IDUtils {

	/**
	 * Image Name Generation
	 */
	public static String genImageName() {
		//Take the long shaping value of the current time to include milliseconds
		long millis = System.currentTimeMillis();
		//long millis = System.nanoTime();
		//Add three random numbers
		Random random = new Random();
		int end3 = random.nextInt(999);
		//If less than three are added before 0
		String str = millis + String.format("%03d", end3);
		
		return str;
	}
	
	/**
	 * Commodity id generation
	 */
	public static long genItemId() {
		//Take the long shaping value of the current time to include milliseconds
		long millis = System.currentTimeMillis();
		//long millis = System.nanoTime();
		//Add two random numbers
		Random random = new Random();
		int end2 = random.nextInt(99);
		//If you don't have more than two front zero
		String str = millis + String.format("%02d", end2);
		long id = new Long(str);
		return id;
	}
}

Edited goods
Request url:/rest/item/update
Similar to the preservation of goods, the same is true.

Delete merchandise
Request url:/rest/item/delete
Request parameter: ids, received using Long[] ids

Goods on shelves
Request url:/rest/item/instock
Request parameter: ids, received using Long[] ids

Delete merchandise
Request url: /rest/item/reshelf
Request parameter: ids, received using Long[] ids

Posted by ijmccoy on Fri, 25 Jan 2019 21:15:13 -0800